-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix IndexMetaData loads after rollover #33394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,15 +69,18 @@ public class TransportNodesListGatewayStartedShards extends | |
public static final String ACTION_NAME = "internal:gateway/local/started_shards"; | ||
private final NodeEnvironment nodeEnv; | ||
private final IndicesService indicesService; | ||
private final NamedXContentRegistry namedXContentRegistry; | ||
|
||
@Inject | ||
public TransportNodesListGatewayStartedShards(Settings settings, ThreadPool threadPool, ClusterService clusterService, | ||
TransportService transportService, ActionFilters actionFilters, | ||
NodeEnvironment env, IndicesService indicesService) { | ||
NodeEnvironment env, IndicesService indicesService, | ||
NamedXContentRegistry namedXContentRegistry) { | ||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, | ||
Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STARTED, NodeGatewayStartedShards.class); | ||
this.nodeEnv = env; | ||
this.indicesService = indicesService; | ||
this.namedXContentRegistry = namedXContentRegistry; | ||
} | ||
|
||
@Override | ||
|
@@ -112,15 +115,15 @@ protected NodeGatewayStartedShards nodeOperation(NodeRequest request) { | |
try { | ||
final ShardId shardId = request.getShardId(); | ||
logger.trace("{} loading local shard state info", shardId); | ||
ShardStateMetaData shardStateMetaData = ShardStateMetaData.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, | ||
ShardStateMetaData shardStateMetaData = ShardStateMetaData.FORMAT.loadLatestState(logger, namedXContentRegistry, | ||
nodeEnv.availableShardPaths(request.shardId)); | ||
if (shardStateMetaData != null) { | ||
IndexMetaData metaData = clusterService.state().metaData().index(shardId.getIndex()); | ||
if (metaData == null) { | ||
// we may send this requests while processing the cluster state that recovered the index | ||
// sometimes the request comes in before the local node processed that cluster state | ||
// in such cases we can load it from disk | ||
metaData = IndexMetaData.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, | ||
metaData = IndexMetaData.FORMAT.loadLatestState(logger, namedXContentRegistry, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I'm 99% sure this change is correct, I don't know of a way to trigger this code locally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow. What do you mean with triggering code locally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This branch looks like the kind of thing that won't kick in much. Do we have a test that'll call it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we only have general IT tests ci runs. This class is not wel tested :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I stuck an exception there and found |
||
nodeEnv.indexPaths(shardId.getIndex())); | ||
} | ||
if (metaData == null) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,17 +67,19 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesAction<T | |
public static final String ACTION_NAME = "internal:cluster/nodes/indices/shard/store"; | ||
|
||
private final IndicesService indicesService; | ||
|
||
private final NodeEnvironment nodeEnv; | ||
private final NamedXContentRegistry namedXContentRegistry; | ||
|
||
@Inject | ||
public TransportNodesListShardStoreMetaData(Settings settings, ThreadPool threadPool, | ||
ClusterService clusterService, TransportService transportService, | ||
IndicesService indicesService, NodeEnvironment nodeEnv, ActionFilters actionFilters) { | ||
IndicesService indicesService, NodeEnvironment nodeEnv, | ||
ActionFilters actionFilters, NamedXContentRegistry namedXContentRegistry) { | ||
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, | ||
Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STORE, NodeStoreFilesMetaData.class); | ||
this.indicesService = indicesService; | ||
this.nodeEnv = nodeEnv; | ||
this.namedXContentRegistry = namedXContentRegistry; | ||
} | ||
|
||
@Override | ||
|
@@ -129,7 +131,7 @@ private StoreFilesMetaData listStoreMetaData(ShardId shardId) throws IOException | |
// we may send this requests while processing the cluster state that recovered the index | ||
// sometimes the request comes in before the local node processed that cluster state | ||
// in such cases we can load it from disk | ||
metaData = IndexMetaData.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, | ||
metaData = IndexMetaData.FORMAT.loadLatestState(logger, namedXContentRegistry, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I'm 99% sure this change is correct, I don't know of a way to trigger this code locally. |
||
nodeEnv.indexPaths(shardId.getIndex())); | ||
} | ||
if (metaData == null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1