Skip to content

Commit 72e0a64

Browse files
committed
TEST: resync operation on replica should acquire shard permit (#33103)
This change makes sure that resync operations on replicas in the test framework are executed under shard permits as the production code.
1 parent 3b9965b commit 72e0a64

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ protected PrimaryResult performOnPrimary(IndexShard primary, ResyncReplicationRe
728728

729729
@Override
730730
protected void performOnReplica(ResyncReplicationRequest request, IndexShard replica) throws Exception {
731-
executeResyncOnReplica(replica, request);
731+
executeResyncOnReplica(replica, request, getPrimaryShard().getPendingPrimaryTerm(), getPrimaryShard().getGlobalCheckpoint());
732732
}
733733
}
734734

@@ -741,8 +741,15 @@ private TransportWriteAction.WritePrimaryResult<ResyncReplicationRequest, Resync
741741
return result;
742742
}
743743

744-
private void executeResyncOnReplica(IndexShard replica, ResyncReplicationRequest request) throws Exception {
745-
final Translog.Location location = TransportResyncReplicationAction.performOnReplica(request, replica);
744+
private void executeResyncOnReplica(IndexShard replica, ResyncReplicationRequest request,
745+
long operationPrimaryTerm, long globalCheckpointOnPrimary) throws Exception {
746+
final Translog.Location location;
747+
final PlainActionFuture<Releasable> acquirePermitFuture = new PlainActionFuture<>();
748+
replica.acquireReplicaOperationPermit(
749+
operationPrimaryTerm, globalCheckpointOnPrimary, acquirePermitFuture, ThreadPool.Names.SAME, request);
750+
try (Releasable ignored = acquirePermitFuture.actionGet()) {
751+
location = TransportResyncReplicationAction.performOnReplica(request, replica);
752+
}
746753
TransportWriteActionTestHelper.performPostWriteActions(replica, request, location, logger);
747754
}
748755
}

0 commit comments

Comments
 (0)