Skip to content

Commit

Permalink
Backport: Fix race condition in initial point sync #729 (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
aprudhomme authored Sep 30, 2024
1 parent ccfa829 commit 7ef3630
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,19 +340,30 @@ public void syncFromCurrentPrimary(long primaryWaitMs, long maxTimeMs) throws IO
// updates, or we are unable to start a new copy job. This is needed since long running nrt
// points may fail if the primary cleans up old commit files.
while (curVersion < primaryIndexVersion && (System.currentTimeMillis() - startMS < maxTimeMs)) {
CopyJob job = newNRTPoint(lastPrimaryGen, Long.MAX_VALUE);
CopyJob job = newNRTPoint(lastPrimaryGen, primaryIndexVersion);
if (job == null) {
// A job won't be started if we are already at the target version,
// check if that is the case
curVersion = getCurrentSearchingVersion();
if (curVersion >= primaryIndexVersion) {
break;
}
// The job failed to start for another reason, abort
logger.info("Nrt sync: failed to start copy job, aborting");
return;
}
logger.info("Nrt sync: started new copy job");
logger.info(
"Nrt sync: started new copy job, my version: {}, job version: {}",
curVersion,
job.getCopyState().version);
while (true) {
curVersion = getCurrentSearchingVersion();
if (curVersion >= primaryIndexVersion) {
break;
}
synchronized (this) {
if (curNRTCopy == null) {
curVersion = getCurrentSearchingVersion();
break;
}
}
Expand Down

0 comments on commit 7ef3630

Please sign in to comment.