TEST: resync operation on replica should acquire shard permit
This change makes sure that resync operations on replicas in the test
framework are executed under shard permits as the production code.
@@ -728,7 +728,7 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
@Override
protected void performOnReplica(ResyncReplicationRequest request, IndexShard replica) throws Exception {
- executeResyncOnReplica(replica, request);
+ executeResyncOnReplica(replica, request, getPrimaryShard().getPendingPrimaryTerm(), getPrimaryShard().getGlobalCheckpoint());
}
}
@@ -741,8 +741,15 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
return result;
}
- private void executeResyncOnReplica(IndexShard replica, ResyncReplicationRequest request) throws Exception {
- final Translog.Location location = TransportResyncReplicationAction.performOnReplica(request, replica);
+ private void executeResyncOnReplica(IndexShard replica, ResyncReplicationRequest request,
+ long operationPrimaryTerm, long globalCheckpointOnPrimary) throws Exception {
+ final Translog.Location location;
+ final PlainActionFuture<Releasable> acquirePermitFuture = new PlainActionFuture<>();
+ replica.acquireReplicaOperationPermit(
+ operationPrimaryTerm, globalCheckpointOnPrimary, acquirePermitFuture, ThreadPool.Names.SAME, request);
+ try (Releasable ignored = acquirePermitFuture.actionGet()) {
+ location = TransportResyncReplicationAction.performOnReplica(request, replica);
+ }
TransportWriteActionTestHelper.performPostWriteActions(replica, request, location, logger);
}
}
