Skip to content

Commit

Permalink
Preserve thread context when waiting for segment generation in RTG (e…
Browse files Browse the repository at this point in the history
…lastic#117148)

The multi-get counterpart of
elastic#114623.
  • Loading branch information
pxsalehi authored Nov 22, 2024
1 parent a1247b3 commit bcb29b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/117148.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 117148
summary: Preserve thread context when waiting for segment generation in RTG
area: CRUD
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.admin.indices.refresh.TransportShardRefreshAction;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.ContextPreservingActionListener;
import org.elasticsearch.action.support.TransportActions;
import org.elasticsearch.action.support.replication.BasicReplicationRequest;
import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
Expand Down Expand Up @@ -280,15 +281,15 @@ private void tryShardMultiGetFromTranslog(
} else {
assert r.segmentGeneration() > -1L;
assert r.primaryTerm() > Engine.UNKNOWN_PRIMARY_TERM;
indexShard.waitForPrimaryTermAndGeneration(
r.primaryTerm(),
r.segmentGeneration(),
final ActionListener<Long> termAndGenerationListener = ContextPreservingActionListener.wrapPreservingContext(
listener.delegateFailureAndWrap(
(ll, aLong) -> getExecutor(request, shardId).execute(
ActionRunnable.supply(ll, () -> handleLocalGets(request, r.multiGetShardResponse(), shardId))
)
)
),
threadPool.getThreadContext()
);
indexShard.waitForPrimaryTermAndGeneration(r.primaryTerm(), r.segmentGeneration(), termAndGenerationListener);
}
}
}), TransportShardMultiGetFomTranslogAction.Response::new, getExecutor(request, shardId))
Expand Down

0 comments on commit bcb29b7

Please sign in to comment.