Skip to content

Commit 6bf3f1d

Browse files
committed
use docId directly
1 parent 58c0686 commit 6bf3f1d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

server/src/main/java/org/elasticsearch/common/lucene/uid/VersionsAndSeqNoResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public static long lookupPrimaryTerm(final DirectoryReader directoryReader, fina
229229
int docId;
230230
while ((docId = docIdSetIterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
231231
// make sure to skip the non-root nested documents
232-
if (primaryTermDV.advanceExact(docId - leaf.docBase) && primaryTermDV.longValue() > 0) {
232+
if (primaryTermDV.advanceExact(docId) && primaryTermDV.longValue() > 0) {
233233
return primaryTermDV.longValue();
234234
}
235235
}

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/index/engine/FollowingEngineTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,17 +574,21 @@ public void testProcessOnceOnPrimary() throws Exception {
574574
}
575575
}
576576
Randomness.shuffle(operations);
577+
final long oldTerm = randomLongBetween(1, Integer.MAX_VALUE);
578+
primaryTerm.set(oldTerm);
577579
try (Store store = createStore(shardId, indexSettings, newDirectory())) {
578580
final EngineConfig engineConfig = engineConfig(shardId, indexSettings, threadPool, store, logger, xContentRegistry());
579581
try (FollowingEngine followingEngine = createEngine(store, engineConfig)) {
580582
followingEngine.advanceMaxSeqNoOfUpdatesOrDeletes(operations.size() - 1L);
581-
final long oldTerm = randomLongBetween(1, Integer.MAX_VALUE);
582583
final Map<Long,Long> operationWithTerms = new HashMap<>();
583584
for (Engine.Operation op : operations) {
584585
long term = randomLongBetween(1, oldTerm);
585586
Engine.Result result = applyOperation(followingEngine, op, term, randomFrom(Engine.Operation.Origin.values()));
586587
assertThat(result.getResultType(), equalTo(Engine.Result.Type.SUCCESS));
587588
operationWithTerms.put(op.seqNo(), term);
589+
if (rarely()) {
590+
followingEngine.refresh("test");
591+
}
588592
}
589593
// Primary should reject duplicates
590594
final long newTerm = randomLongBetween(oldTerm + 1, Long.MAX_VALUE);

0 commit comments

Comments
 (0)