Skip to content

Commit

Permalink
Cannot rebuild a replicated database. This feature must be integrated…
Browse files Browse the repository at this point in the history
… into the restore phase.
  • Loading branch information
broneill committed Nov 12, 2024
1 parent 780d15d commit d34ad9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/cojen/tupl/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static Database connect(SocketAddress addr, SSLContext context, long... t
* @param numThreads pass 0 for default, or if negative, the actual number will be {@code
* (-numThreads * availableProcessors)}.
* @return the newly built database
* @throws IllegalStateException if the new database already exists
* @throws IllegalStateException if the new database already exists or if either is replicated
*/
public static Database rebuild(DatabaseConfig oldConfig, DatabaseConfig newConfig,
int numThreads)
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/cojen/tupl/core/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ EnumSet<OpenOption> createOpenOptions() {
return options;
}

boolean isReplicated() {
return mRepl != null || mReplConfig != null;
}

/**
* @return true if mRepl was assigned a new replicator
*/
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/cojen/tupl/core/Rebuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public CoreDatabase run() throws IOException {
private void doRun() throws IOException {
// Prepare configuration and perform basic configuration checks.

if (mOldLauncher.isReplicated() || mNewLauncher.isReplicated()) {
// Both databases must not be concurrently modified by any other threads. This is
// always possible with a replicated database.
throw new IllegalStateException("Cannot rebuild a replicated database");
}

// Page access mode must be consistent in order for the parallelCopy method to work.
if (mNewLauncher.mDirectPageAccess == null) {
mNewLauncher.mDirectPageAccess = mOldLauncher.mDirectPageAccess;
Expand Down

0 comments on commit d34ad9f

Please sign in to comment.