Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ apache-hugegraph-*/
**/docker-compose*.yaml
**/*.md
docs/
# The Store assembly packages this upgrade guide.
!docs/
docs/*
!docs/graphid-upgrade.md
3 changes: 3 additions & 0 deletions .github/workflows/pd-store-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ jobs:
run: |
mvn editorconfig:check -pl hugegraph-store/hg-store-test -am -ntp

- name: Check Store GraphID checker launcher
run: bash hugegraph-store/hg-store-dist/src/assembly/travis/test-store-check-launcher.sh

- name: Run Store docker entrypoint rocksdb memory tests
run: |
$TRAVIS_DIR/test-store-docker-entrypoint.sh
Expand Down
277 changes: 277 additions & 0 deletions docs/graphid-upgrade.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,10 @@ sys.exit(int((work / 'child-exit').read_text()))
os.kill(int((work / 'bin/pid').read_text()), signal.SIGKILL)
else:
status = 42 if mode in ['partition42', 'partitionDiagnostic42'] else int(mode[4:])
(work / 'child-exit').write_text(str(status))
# Publish the exit code only after its contents are complete.
pending_exit = work / 'child-exit.tmp'
pending_exit.write_text(str(status))
pending_exit.replace(work / 'child-exit')
actual = process.wait(timeout=5)
assert actual == expected, (mode, expected, actual, (work / 'output').read_text())
diagnostic = (work / 'output').read_text()
Expand Down
4 changes: 4 additions & 0 deletions hugegraph-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ For detailed architecture, Raft consensus mechanisms, and partition management,
For lightweight Raft dashboard counters and the detailed metrics contract, see
[Store monitoring metrics](docs/monitoring.md).

## Upgrading from 1.7

Before starting 1.8 on existing HStore data, follow the [GraphID upgrade checks and recovery guide](../docs/graphid-upgrade.md). The Store distribution includes a read-only `bin/hugegraph-store-check.sh --check` command.

## Quick Start

### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -115,13 +116,15 @@
import org.apache.hugegraph.store.schema.SchemaGraph;
import org.apache.hugegraph.store.term.Bits;
import org.apache.hugegraph.store.term.HgPair;
import org.apache.hugegraph.store.upgrade.LegacyGraphIdChecker;
import org.apache.hugegraph.store.util.DefaultThreadFactory;
import org.apache.hugegraph.store.util.ExecutorUtil;
import org.apache.hugegraph.store.util.HgStoreException;
import org.apache.hugegraph.structure.BaseElement;
import org.apache.hugegraph.util.Bytes;
import org.rocksdb.Cache;
import org.rocksdb.MemoryUsageType;
import org.rocksdb.RocksDBException;

import com.alipay.sofa.jraft.util.Utils;
import com.google.protobuf.ByteString;
Expand Down Expand Up @@ -1194,6 +1197,17 @@ public void saveSnapshot(String snapshotPath, String graph, int partId) throws
@Override
public void loadSnapshot(String snapshotPath, String graph, int partId, long v1) throws
HgStoreException {
// Validate incoming data before getSession() can create or prune local DB versions.
try {
LegacyGraphIdChecker.checkDatabase(Path.of(snapshotPath), factory.getHugeConfig());
} catch (IOException | RocksDBException | IllegalStateException e) {
HgStoreException failure = new HgStoreException(
HgStoreException.EC_RKDB_IMPORT_SNAPSHOT_FAIL,
"GraphID upgrade preflight rejected snapshot %s for partition %d: %s",
snapshotPath, partId, e.getMessage());
failure.initCause(e);
throw failure;
}
try (RocksDBSession dbSession = getSession(graph, partId)) {
dbSession.loadSnapshot(snapshotPath, v1);
keyCreator.clearCache(partId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ public void onSnapshotSave(final SnapshotWriter writer, final Closure done) {

@Override
public boolean onSnapshotLoad(final SnapshotReader reader) {
final long snapshotIndex;
try {
RaftOutter.SnapshotMeta meta = reader.load();
if (meta != null) {
this.committedIndex = meta.getLastIncludedIndex();
log.info("onSnapshotLoad committedIndex = {}", this.committedIndex);
snapshotIndex = meta.getLastIncludedIndex();
} else {
log.error("onSnapshotLoad failed to get SnapshotMeta");
return false;
Expand All @@ -241,8 +241,9 @@ public boolean onSnapshotLoad(final SnapshotReader reader) {
return false;
}
try {
snapshotHandler.onSnapshotLoad(reader, this.committedIndex);
log.info("Raft {} onSnapshotLoad success", groupId);
snapshotHandler.onSnapshotLoad(reader, snapshotIndex);
this.committedIndex = snapshotIndex;
log.info("Raft {} onSnapshotLoad success, committedIndex = {}", groupId, snapshotIndex);
return true;
} catch (HgStoreException e) {
log.error(String.format("Raft %s onSnapshotLoad failed. ", groupId), e);
Expand Down
Loading
Loading