Skip to content

Commit

Permalink
TEST: resync operation on replica should acquire shard permit (#33103)
Browse files Browse the repository at this point in the history
This change makes sure that resync operations on replicas in the test
framework are executed under shard permits as the production code.
  • Loading branch information
dnhatn committed Aug 25, 2018
1 parent 1e9144d commit 739a8d3
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ protected PrimaryResult performOnPrimary(IndexShard primary, ResyncReplicationRe

@Override
protected void performOnReplica(ResyncReplicationRequest request, IndexShard replica) throws Exception {
executeResyncOnReplica(replica, request);
executeResyncOnReplica(replica, request, getPrimaryShard().getPendingPrimaryTerm(), getPrimaryShard().getGlobalCheckpoint());
}
}

Expand All @@ -741,8 +741,15 @@ private TransportWriteAction.WritePrimaryResult<ResyncReplicationRequest, Resync
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);
}
}

0 comments on commit 739a8d3

Please sign in to comment.