GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fixed schema and graph operations executed on a replica server (#205) · humemai/arcadedb-embedded-python@a40baea

This repository was archived by the owner on Nov 21, 2026. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • engine/src/main/java/com/arcadedb
    • database
      • EmbeddedDatabase.java
      • TransactionContext.java
    • index
      • IndexFactory.java
      • IndexFactoryHandler.java
      • lsm
        • LSMTreeFullTextIndex.java
        • LSMTreeIndex.java
    • log
      • DefaultLogger.java
    • query
      • QueryEngine.java
      • cypher
        • CypherQueryEngine.java
      • gremlin
        • GremlinQueryEngine.java
      • mongo
        • MongoQueryEngine.java
      • sql
        • SQLQueryEngine.java
        • executor
          • InternalResultSet.java
          • IteratorResultSet.java
        • parser
          • Statement.java
    • schema
      • EmbeddedSchema.java
  • server/src
    • main/java/com/arcadedb/server/ha
      • HAServer.java
      • Leader2ReplicaNetworkExecutor.java
      • ReplicatedDatabase.java
      • message
        • CommandForwardRequest.java
    • test/java/com/arcadedb/server
      • BaseGraphServerTest.java
      • ha
        • HTTP2ServersIT.java
        • ReplicationChangeSchemaIT.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎engine/src/main/java/com/arcadedb/database/EmbeddedDatabase.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/database/EmbeddedDatabase.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,10 @@ public void setWrapper(final String name, final Object instance) {
14441444
this.wrappers.put(name, instance);
14451445
}
14461446

1447+
public QueryEngineManager getQueryEngineManager() {
1448+
return queryEngineManager;
1449+
}
1450+
14471451
public void saveConfiguration() throws IOException {
14481452
FileUtils.writeFile(configurationFile, configuration.toJSON());
14491453
}
Collapse file

‎engine/src/main/java/com/arcadedb/database/TransactionContext.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/database/TransactionContext.java
+32-14Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import com.arcadedb.index.Index;
3434
import com.arcadedb.index.lsm.LSMTreeIndexAbstract;
3535
import com.arcadedb.log.LogManager;
36-
import com.arcadedb.utility.Pair;
3736

3837
import java.io.*;
3938
import java.util.*;
@@ -70,6 +69,16 @@ public class TransactionContext implements Transaction {
7069

7170
public enum STATUS {INACTIVE, BEGUN, COMMIT_1ST_PHASE, COMMIT_2ND_PHASE}
7271

72+
public class TransactionPhase1 {
73+
public final Binary result;
74+
public final List<MutablePage> modifiedPages;
75+
76+
public TransactionPhase1(final Binary result, final List<MutablePage> modifiedPages) {
77+
this.result = result;
78+
this.modifiedPages = modifiedPages;
79+
}
80+
}
81+
7382
public TransactionContext(final DatabaseInternal database) {
7483
this.database = database;
7584
this.walFlush = WALFile.getWALFlushType(database.getConfiguration().getValueAsInteger(GlobalConfiguration.TX_WAL_FLUSH));
@@ -99,17 +108,17 @@ public Binary commit() {
99108
if (status != STATUS.BEGUN)
100109
throw new TransactionException("Transaction already in commit phase");
101110

102-
final Pair<Binary, List<MutablePage>> changes = commit1stPhase(true);
111+
final TransactionPhase1 phase1 = commit1stPhase(true);
103112

104-
if (changes != null)
105-
commit2ndPhase(changes);
113+
if (phase1 != null)
114+
commit2ndPhase(phase1);
106115
else
107116
reset();
108117

109118
if (database.getSchema().getEmbedded().isDirty())
110119
database.getSchema().getEmbedded().saveConfiguration();
111120

112-
return changes != null ? changes.getFirst() : null;
121+
return phase1 != null ? phase1.result : null;
113122
}
114123

115124
public Record getRecordFromCache(final RID rid) {
@@ -377,6 +386,9 @@ public void commitFromReplica(final WALFile.WALTransaction buffer,
377386
indexChanges.setKeys(keysTx);
378387
indexChanges.addFilesToLock(modifiedFiles);
379388

389+
final int dictionaryFileId = database.getSchema().getDictionary().getId();
390+
boolean dictionaryModified = false;
391+
380392
for (WALFile.WALPage p : buffer.pages) {
381393
final PaginatedFile file = database.getFileManager().getFile(p.fileId);
382394
final int pageSize = file.getPageSize();
@@ -396,10 +408,16 @@ public void commitFromReplica(final WALFile.WALTransaction buffer,
396408
newPageCounters.put(pageId.getFileId(), pageId.getPageNumber() + 1);
397409
} else
398410
modifiedPages.put(pageId, page);
411+
412+
if (!dictionaryModified && dictionaryFileId == pageId.getFileId())
413+
dictionaryModified = true;
399414
}
400415

401416
database.commit();
402417

418+
if (dictionaryModified)
419+
database.getSchema().getDictionary().reload();
420+
403421
} catch (ConcurrentModificationException e) {
404422
rollback();
405423
throw e;
@@ -412,7 +430,7 @@ public void commitFromReplica(final WALFile.WALTransaction buffer,
412430
/**
413431
* Locks the files in order, then checks all the pre-conditions.
414432
*/
415-
public Pair<Binary, List<MutablePage>> commit1stPhase(final boolean isLeader) {
433+
public TransactionPhase1 commit1stPhase(final boolean isLeader) {
416434
if (status == STATUS.INACTIVE)
417435
throw new TransactionException("Transaction not started");
418436

@@ -453,7 +471,6 @@ public Pair<Binary, List<MutablePage>> commit1stPhase(final boolean isLeader) {
453471

454472
// CHECK THE VERSIONS FIRST
455473
final List<MutablePage> pages = new ArrayList<>();
456-
457474
final PageManager pageManager = database.getPageManager();
458475

459476
for (final Iterator<MutablePage> it = modifiedPages.values().iterator(); it.hasNext(); ) {
@@ -481,13 +498,11 @@ public Pair<Binary, List<MutablePage>> commit1stPhase(final boolean isLeader) {
481498

482499
if (useWAL) {
483500
txId = database.getTransactionManager().getNextTransactionId();
484-
485-
LogManager.instance().log(this, Level.FINE, "Creating buffer for TX %d (threadId=%d)", null, txId, Thread.currentThread().getId());
486-
501+
//LogManager.instance().log(this, Level.FINE, "Creating buffer for TX %d (threadId=%d)", null, txId, Thread.currentThread().getId());
487502
result = database.getTransactionManager().createTransactionBuffer(txId, pages);
488503
}
489504

490-
return new Pair<>(result, pages);
505+
return new TransactionPhase1(result, pages);
491506

492507
} catch (DuplicatedKeyException | ConcurrentModificationException e) {
493508
rollback();
@@ -499,7 +514,10 @@ public Pair<Binary, List<MutablePage>> commit1stPhase(final boolean isLeader) {
499514
}
500515
}
501516

502-
public void commit2ndPhase(final Pair<Binary, List<MutablePage>> changes) {
517+
public void commit2ndPhase(final TransactionContext.TransactionPhase1 changes) {
518+
if (changes == null)
519+
return;
520+
503521
if (database.getMode() == PaginatedFile.MODE.READ_ONLY)
504522
throw new TransactionException("Cannot commit changes because the database is open in read-only mode");
505523

@@ -511,9 +529,9 @@ public void commit2ndPhase(final Pair<Binary, List<MutablePage>> changes) {
511529
final PageManager pageManager = database.getPageManager();
512530

513531
try {
514-
if (changes.getFirst() != null)
532+
if (changes.result != null)
515533
// WRITE TO THE WAL FIRST
516-
database.getTransactionManager().writeTransactionToWAL(changes.getSecond(), walFlush, txId, changes.getFirst());
534+
database.getTransactionManager().writeTransactionToWAL(changes.modifiedPages, walFlush, txId, changes.result);
517535

518536
// AT THIS POINT, LOCK + VERSION CHECK, THERE IS NO NEED TO MANAGE ROLLBACK BECAUSE THERE CANNOT BE CONCURRENT TX THAT UPDATE THE SAME PAGE CONCURRENTLY
519537
// UPDATE PAGE COUNTER FIRST
Collapse file

‎engine/src/main/java/com/arcadedb/index/IndexFactory.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/index/IndexFactory.java
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.arcadedb.index.lsm.LSMTreeIndexAbstract;
2121
import com.arcadedb.schema.Type;
2222

23-
import java.io.*;
2423
import java.util.*;
2524

2625
public class IndexFactory {
@@ -32,7 +31,7 @@ public void register(final String type, final IndexFactoryHandler handler) {
3231

3332
public IndexInternal createIndex(final String indexType, final DatabaseInternal database, final String indexName, final boolean unique, final String filePath,
3433
final PaginatedFile.MODE mode, final Type[] keyTypes, final int pageSize, final LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy,
35-
final Index.BuildIndexCallback callback) throws IOException {
34+
final Index.BuildIndexCallback callback) {
3635
final IndexFactoryHandler handler = map.get(indexType);
3736

3837
if (handler == null)
Collapse file

‎engine/src/main/java/com/arcadedb/index/IndexFactoryHandler.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/index/IndexFactoryHandler.java
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
import com.arcadedb.index.lsm.LSMTreeIndexAbstract;
2121
import com.arcadedb.schema.Type;
2222

23-
import java.io.*;
24-
2523
public interface IndexFactoryHandler {
2624
IndexInternal create(DatabaseInternal database, String name, boolean unique, String filePath, PaginatedFile.MODE mode, Type[] keyTypes, int pageSize,
27-
LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback) throws IOException;
25+
LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback);
2826
}
Collapse file

‎engine/src/main/java/com/arcadedb/index/lsm/LSMTreeFullTextIndex.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/index/lsm/LSMTreeFullTextIndex.java
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public class LSMTreeFullTextIndex implements Index, IndexInternal {
6565
public static class IndexFactoryHandler implements com.arcadedb.index.IndexFactoryHandler {
6666
@Override
6767
public IndexInternal create(final DatabaseInternal database, final String name, final boolean unique, final String filePath, final PaginatedFile.MODE mode,
68-
final Type[] keyTypes, final int pageSize, final LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, final BuildIndexCallback callback)
69-
throws IOException {
68+
final Type[] keyTypes, final int pageSize, final LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, final BuildIndexCallback callback) {
7069
return new LSMTreeFullTextIndex(database, name, filePath, mode, pageSize, callback);
7170
}
7271
}
@@ -85,12 +84,8 @@ public PaginatedComponent createOnLoad(final DatabaseInternal database, final St
8584
*/
8685
public LSMTreeFullTextIndex(final DatabaseInternal database, final String name, final String filePath, final PaginatedFile.MODE mode, final int pageSize,
8786
final BuildIndexCallback callback) {
88-
try {
89-
analyzer = new StandardAnalyzer();
90-
underlyingIndex = new LSMTreeIndex(database, name, false, filePath, mode, new Type[] { Type.STRING }, pageSize, LSMTreeIndexAbstract.NULL_STRATEGY.ERROR);
91-
} catch (IOException e) {
92-
throw new IndexException("Cannot create search engine (error=" + e + ")", e);
93-
}
87+
analyzer = new StandardAnalyzer();
88+
underlyingIndex = new LSMTreeIndex(database, name, false, filePath, mode, new Type[] { Type.STRING }, pageSize, LSMTreeIndexAbstract.NULL_STRATEGY.ERROR);
9489
}
9590

9691
/**
Collapse file

‎engine/src/main/java/com/arcadedb/index/lsm/LSMTreeIndex.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/index/lsm/LSMTreeIndex.java
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public class LSMTreeIndex implements RangeIndex, IndexInternal {
6767
public static class IndexFactoryHandler implements com.arcadedb.index.IndexFactoryHandler {
6868
@Override
6969
public IndexInternal create(final DatabaseInternal database, final String name, final boolean unique, final String filePath, final PaginatedFile.MODE mode,
70-
final Type[] keyTypes, final int pageSize, final LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, final BuildIndexCallback callback)
71-
throws IOException {
70+
final Type[] keyTypes, final int pageSize, final LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, final BuildIndexCallback callback) {
7271
return new LSMTreeIndex(database, name, unique, filePath, mode, keyTypes, pageSize, nullStrategy);
7372
}
7473
}
@@ -99,9 +98,13 @@ public PaginatedComponent createOnLoad(final DatabaseInternal database, final St
9998
* Called at creation time.
10099
*/
101100
public LSMTreeIndex(final DatabaseInternal database, final String name, final boolean unique, String filePath, final PaginatedFile.MODE mode,
102-
final Type[] keyTypes, final int pageSize, final LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy) throws IOException {
103-
this.name = name;
104-
this.mutable = new LSMTreeIndexMutable(this, database, name, unique, filePath, mode, keyTypes, pageSize, nullStrategy);
101+
final Type[] keyTypes, final int pageSize, final LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy) {
102+
try {
103+
this.name = name;
104+
this.mutable = new LSMTreeIndexMutable(this, database, name, unique, filePath, mode, keyTypes, pageSize, nullStrategy);
105+
} catch (IOException e) {
106+
throw new IndexException("Error on creating index '" + name + "'", e);
107+
}
105108
}
106109

107110
/**
Collapse file

‎engine/src/main/java/com/arcadedb/log/DefaultLogger.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/log/DefaultLogger.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ public void installCustomFormatter() {
6969
}
7070
}
7171

72-
public void log(final Object requester, final Level level, String message, final Throwable exception, final String context, final Object arg1,
72+
public void log(final Object requester, Level level, String message, final Throwable exception, final String context, final Object arg1,
7373
final Object arg2, final Object arg3, final Object arg4, final Object arg5, final Object arg6, final Object arg7, final Object arg8, final Object arg9,
7474
final Object arg10, final Object arg11, final Object arg12, final Object arg13, final Object arg14, final Object arg15, final Object arg16,
7575
final Object arg17) {
7676
if (message == null)
7777
return;
7878

79+
//level = Level.SEVERE;
80+
7981
final String requesterName;
8082
if (requester instanceof String)
8183
requesterName = (String) requester;
Collapse file

‎engine/src/main/java/com/arcadedb/query/QueryEngine.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/query/QueryEngine.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
import java.util.*;
2222

2323
public interface QueryEngine {
24+
interface AnalyzedQuery {
25+
boolean isIdempotent();
26+
27+
boolean isDDL();
28+
}
29+
2430
interface QueryEngineFactory {
2531
boolean isAvailable();
2632

@@ -29,6 +35,8 @@ interface QueryEngineFactory {
2935
QueryEngine getInstance(DatabaseInternal database);
3036
}
3137

38+
AnalyzedQuery analyze(String query);
39+
3240
ResultSet query(String query, Map<String, Object> parameters);
3341

3442
ResultSet query(String query, Object... parameters);
Collapse file

‎engine/src/main/java/com/arcadedb/query/cypher/CypherQueryEngine.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/query/cypher/CypherQueryEngine.java
+21-9Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,18 @@
2525
import com.arcadedb.query.sql.executor.Result;
2626
import com.arcadedb.query.sql.executor.ResultInternal;
2727
import com.arcadedb.query.sql.executor.ResultSet;
28-
import java.lang.reflect.InvocationTargetException;
2928

30-
import java.util.HashMap;
31-
import java.util.List;
32-
import java.util.Map;
33-
import java.util.Set;
34-
import java.util.logging.Level;
35-
import java.util.stream.Collectors;
29+
import java.lang.reflect.*;
30+
import java.util.*;
31+
import java.util.logging.*;
32+
import java.util.stream.*;
3633

3734
public class CypherQueryEngine implements QueryEngine {
3835
private static final String ENGINE_NAME = "cypher-engine";
39-
private final Object arcadeGraph;
36+
private final Object arcadeGraph;
4037

4138
public static class CypherQueryEngineFactory implements QueryEngineFactory {
42-
private static Boolean available = null;
39+
private static Boolean available = null;
4340
private static Class<?> arcadeGraphClass;
4441
private static Class<?> arcadeCypherClass;
4542

@@ -84,6 +81,21 @@ protected CypherQueryEngine(final Object arcadeGraph) {
8481
this.arcadeGraph = arcadeGraph;
8582
}
8683

84+
@Override
85+
public AnalyzedQuery analyze(String query) {
86+
return new AnalyzedQuery() {
87+
@Override
88+
public boolean isIdempotent() {
89+
return false;
90+
}
91+
92+
@Override
93+
public boolean isDDL() {
94+
return false;
95+
}
96+
};
97+
}
98+
8799
@Override
88100
public ResultSet query(final String query, final Map<String, Object> parameters) {
89101
return command(query, parameters);
Collapse file

‎engine/src/main/java/com/arcadedb/query/gremlin/GremlinQueryEngine.java‎

Copy file name to clipboardExpand all lines: engine/src/main/java/com/arcadedb/query/gremlin/GremlinQueryEngine.java
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,20 @@ public ResultSet command(final String query, final Object... parameters) {
107107
map.put((String) parameters[i], parameters[i + 1]);
108108
return command(query, map);
109109
}
110+
111+
@Override
112+
public AnalyzedQuery analyze(String query) {
113+
return new AnalyzedQuery() {
114+
@Override
115+
public boolean isIdempotent() {
116+
return false;
117+
}
118+
119+
@Override
120+
public boolean isDDL() {
121+
return false;
122+
}
123+
};
124+
}
125+
110126
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.