From 59703fd5be2dbca4ad4d657144816a118cca530a Mon Sep 17 00:00:00 2001 From: liningrui Date: Thu, 7 Jan 2021 14:35:18 +0800 Subject: [PATCH 1/3] Fix add schema from follower then list all without it Change-Id: I3fa86e813fba61b4d77493e78317ebb451e58785 --- .../hugegraph/backend/cache/CachedSchemaTransaction.java | 2 ++ .../hugegraph/backend/store/raft/StoreStateMachine.java | 8 +++++++- .../hugegraph/backend/store/rocksdb/RocksDBOptions.java | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java index 91926b5d41..bce43f9c31 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java @@ -124,6 +124,8 @@ private void listenChanges() { schema.name()); this.nameCache.invalidate(prefixedName); } + // Set the cache all flag of the schema type to false + this.cachedTypes().put(type, false); return true; } else if (ACTION_CLEAR.equals(args[0])) { this.clearCache(); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/raft/StoreStateMachine.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/raft/StoreStateMachine.java index 670cd6a627..42cfefb37b 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/raft/StoreStateMachine.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/raft/StoreStateMachine.java @@ -196,7 +196,7 @@ private void applyCommand(StoreType type, StoreAction action, @Override public void onSnapshotSave(SnapshotWriter writer, Closure done) { - LOG.debug("The node {} start snapshot save", this.node().nodeId()); + LOG.info("The node {} start snapshot saving", this.node().nodeId()); this.snapshotFile.save(writer, done, this.context.snapshotExecutor()); } @@ -206,6 +206,12 @@ public boolean onSnapshotLoad(SnapshotReader reader) { LOG.warn("Leader is not supposed to load snapshot."); return false; } + /* + * Snapshot load occured in RaftNode constructor, specifically at step + * `this.node = this.initRaftNode()`, at this time the NodeImpl is null + * in RaftNode so we can't call `this.node().nodeId()` + */ + LOG.info("The node {} start snapshot loading", this.context.endpoint()); return this.snapshotFile.load(reader); } diff --git a/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBOptions.java b/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBOptions.java index ae1844d6fd..713aa251b8 100644 --- a/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBOptions.java +++ b/hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBOptions.java @@ -65,9 +65,9 @@ public static synchronized RocksDBOptions instance() { "rocksdb.data_disks", false, "The optimized disks for storing data of RocksDB. " + - "The format of each element: `STORE/TABLE: /path/to/disk`." + - "Allowed keys are [graph/vertex, graph/edge_out, graph/edge_in, " + - "graph/secondary_index, graph/range_index]", + "The format of each element: `STORE/TABLE: /path/disk`." + + "Allowed keys are [g/vertex, g/edge_out, g/edge_in, " + + "g/secondary_index, g/range_index]", null, String.class, ImmutableList.of() From 8d127a26c84b90353f01a0e6cd7bd4225e9d9373 Mon Sep 17 00:00:00 2001 From: liningrui Date: Thu, 7 Jan 2021 20:16:54 +0800 Subject: [PATCH 2/3] tiny improve Change-Id: I8995bbe6604a9c6f50b6fcf89eafeff623fc1313 --- .../hugegraph/backend/cache/CachedSchemaTransaction.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java index bce43f9c31..7cc0279c82 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java @@ -124,8 +124,7 @@ private void listenChanges() { schema.name()); this.nameCache.invalidate(prefixedName); } - // Set the cache all flag of the schema type to false - this.cachedTypes().put(type, false); + this.resetCachedAll(type); return true; } else if (ACTION_CLEAR.equals(args[0])) { this.clearCache(); @@ -297,6 +296,11 @@ protected List getAllSchema(HugeType type) { } } + private final void resetCachedAll(HugeType type) { + // Set the cache all flag of the schema type to false + this.cachedTypes().put(type, false); + } + private static final class SchemaCaches { private final int size; From ba72d44eee278f6fc33fcf3033701c22d4434f59 Mon Sep 17 00:00:00 2001 From: liningrui Date: Mon, 11 Jan 2021 19:52:41 +0800 Subject: [PATCH 3/3] tiny improve Change-Id: Iad9d80cabb3d6a874ac66c52de22cc2682debfca --- .../backend/cache/CachedSchemaTransaction.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java index 7cc0279c82..1b3bbeccc6 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java @@ -138,6 +138,11 @@ private void listenChanges() { } } + private final void resetCachedAll(HugeType type) { + // Set the cache all flag of the schema type to false + this.cachedTypes().put(type, false); + } + private void clearCache() { this.idCache.clear(); this.nameCache.clear(); @@ -296,11 +301,6 @@ protected List getAllSchema(HugeType type) { } } - private final void resetCachedAll(HugeType type) { - // Set the cache all flag of the schema type to false - this.cachedTypes().put(type, false); - } - private static final class SchemaCaches { private final int size;