Skip to content

Commit bcb29b7

Browse files
authored
Preserve thread context when waiting for segment generation in RTG (#117148)
The multi-get counterpart of #114623.
1 parent a1247b3 commit bcb29b7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docs/changelog/117148.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 117148
2+
summary: Preserve thread context when waiting for segment generation in RTG
3+
area: CRUD
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.action.ActionType;
2020
import org.elasticsearch.action.admin.indices.refresh.TransportShardRefreshAction;
2121
import org.elasticsearch.action.support.ActionFilters;
22+
import org.elasticsearch.action.support.ContextPreservingActionListener;
2223
import org.elasticsearch.action.support.TransportActions;
2324
import org.elasticsearch.action.support.replication.BasicReplicationRequest;
2425
import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
@@ -280,15 +281,15 @@ private void tryShardMultiGetFromTranslog(
280281
} else {
281282
assert r.segmentGeneration() > -1L;
282283
assert r.primaryTerm() > Engine.UNKNOWN_PRIMARY_TERM;
283-
indexShard.waitForPrimaryTermAndGeneration(
284-
r.primaryTerm(),
285-
r.segmentGeneration(),
284+
final ActionListener<Long> termAndGenerationListener = ContextPreservingActionListener.wrapPreservingContext(
286285
listener.delegateFailureAndWrap(
287286
(ll, aLong) -> getExecutor(request, shardId).execute(
288287
ActionRunnable.supply(ll, () -> handleLocalGets(request, r.multiGetShardResponse(), shardId))
289288
)
290-
)
289+
),
290+
threadPool.getThreadContext()
291291
);
292+
indexShard.waitForPrimaryTermAndGeneration(r.primaryTerm(), r.segmentGeneration(), termAndGenerationListener);
292293
}
293294
}
294295
}), TransportShardMultiGetFomTranslogAction.Response::new, getExecutor(request, shardId))

0 commit comments

Comments
 (0)