Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>
  • Loading branch information
Rishikesh1159 committed Mar 9, 2023
1 parent 0a79735 commit f285ba3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ protected long replicaOperationSize(BulkShardRequest request) {
public static Tuple<Translog.Location, Long> performOnReplica(BulkShardRequest request, IndexShard replica) throws Exception {
Translog.Location location = null;
long maxSeqNo = SequenceNumbers.NO_OPS_PERFORMED;
final boolean isSegRepEnabled = replica.indexSettings().isSegRepEnabled();
for (int i = 0; i < request.items().length; i++) {
final BulkItemRequest item = request.items()[i];
final BulkItemResponse response = item.getPrimaryResponse();
Expand All @@ -814,14 +815,18 @@ public static Tuple<Translog.Location, Long> performOnReplica(BulkShardRequest r
primaryTerm,
response.getFailure().getMessage()
);
maxSeqNo = Math.max(response.getFailure().getSeqNo(), maxSeqNo);
if (isSegRepEnabled) {
maxSeqNo = Math.max(response.getFailure().getSeqNo(), maxSeqNo);
}
} else {
if (response.getResponse().getResult() == DocWriteResponse.Result.NOOP) {
continue; // ignore replication as it's a noop
}
assert response.getResponse().getSeqNo() != SequenceNumbers.UNASSIGNED_SEQ_NO;
operationResult = performOpOnReplica(response.getResponse(), item.request(), replica);
maxSeqNo = Math.max(response.getResponse().getSeqNo(), maxSeqNo);
if (isSegRepEnabled) {
maxSeqNo = Math.max(response.getResponse().getSeqNo(), maxSeqNo);
}
}
assert operationResult != null : "operation result must never be null when primary response has no failure";
location = syncOperationResultOrThrow(operationResult, location);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void setupListeners() throws Exception {
logger,
threadPool.getThreadContext(),
refreshMetric,
this::returnSeqNo
() -> 10L
);

IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index", Settings.EMPTY);
Expand Down Expand Up @@ -181,10 +181,6 @@ public void tearDownListeners() throws Exception {
terminate(threadPool);
}

public Long returnSeqNo() {
return 10L;
}

public void testBeforeRefresh() throws Exception {
assertEquals(0, listeners.pendingCount());
Engine.IndexResult index = index("1");
Expand Down

0 comments on commit f285ba3

Please sign in to comment.