Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions engine/src/main/java/com/arcadedb/database/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ public interface Database extends AutoCloseable {
*/
String getCurrentUserName();

/**
* Returns true if there is a transaction active. A transaction is active if it is in the following states: `{BEGUN, COMMIT_1ST_PHASE, COMMIT_2ND_PHASE}`.
*/
boolean isTransactionActive();

boolean checkTransactionIsActive(boolean createTx);

/**
* Executes a lambda in the transaction scope. If there is an active transaction, then the current transaction is parked and a new sub-transaction is begun.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
import com.arcadedb.exception.ArcadeDBException;
import com.arcadedb.schema.DocumentType;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.io.*;
import java.util.*;

/**
* Compares 2 databases if are identical.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ enum CALLBACK_EVENT {

void checkPermissionsOnFile(int fileId, SecurityDatabaseUser.ACCESS access);

boolean checkTransactionIsActive(boolean createTx);

long getResultSetLimit();

long getReadTimeout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ public void transaction(final TransactionScope txBlock) {

@Override
public boolean transaction(final TransactionScope txBlock, final boolean joinCurrentTx) {
return transaction(txBlock, joinCurrentTx, configuration.getValueAsInteger(GlobalConfiguration.TX_RETRIES));
return transaction(txBlock, joinCurrentTx, configuration.getValueAsInteger(GlobalConfiguration.TX_RETRIES), null, null);
}

@Override
Expand Down
5 changes: 2 additions & 3 deletions engine/src/main/java/com/arcadedb/schema/DocumentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,7 @@ public boolean isSubTypeOf(final String type) {
return false;
}

protected void recordFileChanges(final Callable<Object> callback) {
schema.recordFileChanges(callback);
schema.saveConfiguration();
protected <RET> RET recordFileChanges(final Callable<Object> callback) {
return schema.recordFileChanges(callback);
}
}
17 changes: 16 additions & 1 deletion engine/src/main/java/com/arcadedb/schema/EmbeddedSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,21 @@ protected <RET> RET recordFileChanges(final Callable<Object> callback) {
}
}

return database.getWrappedDatabaseInstance().recordFileChanges(callback);
final boolean madeDirty = !dirtyConfiguration;
if (madeDirty)
dirtyConfiguration = true;

boolean executed = false;
try {
final RET result = database.getWrappedDatabaseInstance().recordFileChanges(callback);
executed = true;
saveConfiguration();
return result;

} finally {
if (!executed && madeDirty)
// ROLLBACK THE DIRTY STATUS
dirtyConfiguration = false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,9 @@ public <RET> RET recordFileChanges(final Callable<Object> callback) {

final List<FileManager.FileChange> fileChanges = proxied.getFileManager().getRecordedChanges();

if (fileChanges.isEmpty() && proxied.getSchema().getEmbedded().getVersion() == schemaVersionBefore)
if (fileChanges.isEmpty() &&//
!proxied.getSchema().getEmbedded().isDirty() && //
proxied.getSchema().getEmbedded().getVersion() == schemaVersionBefore)
// NO CHANGES
return null;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public void testReplication() {

final Database database0 = getServerDatabase(0, getDatabaseName());
final VertexType type0 = database0.getSchema().createVertexType("RuntimeVertex0");
type0.createProperty("id", Type.STRING);
type0.createProperty("nameNotFoundInDictionary", Type.STRING);

final Database database1 = getServerDatabase(1, getDatabaseName());

Assertions.assertNotNull(database1.getSchema().getType("RuntimeVertex0"));
Assertions.assertNotNull(database1.getSchema().getType("RuntimeVertex0").getProperty("id"));
Assertions.assertNotNull(database1.getSchema().getType("RuntimeVertex0").getProperty("nameNotFoundInDictionary"));

try {
database1.getSchema().createVertexType("RuntimeVertex1");
Expand Down