Skip to content
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

Ensure shards are deleted under lock on close #8579

Merged
merged 1 commit into from Nov 21, 2014

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Nov 20, 2014

Today there is a race condition between the actual deletion of
the shard and the release of the lock in the store. This race can cause
rare imports of dangeling indices if the cluster state update loop
tires to import the dangeling index in that particular windonw. This commit
adds more safety to the import of dangeling indices and removes the race
condition by holding on to the lock on store closing while the listener
is notified.

@@ -357,7 +358,8 @@ public void onAllShardsClosed(Index index, List<Throwable> failures) {
@Override
public void onShardClosed(ShardId shardId) {
try {
nodeEnv.deleteShardDirectorySafe(shardId);
// this is called under the shard lock - we can safely delete it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add that this method is called while the shard lock is held to the javadocs for IndexCloseListener.onShardClosed? Currently it says "Invoked once the last resource using the given shard ID is released" which isn't accurate since the lock is still held

@dakrone
Copy link
Member

dakrone commented Nov 21, 2014

@s1monw left a couple of comments

@s1monw
Copy link
Contributor Author

s1monw commented Nov 21, 2014

@dakrone updated based on your comments

@dakrone
Copy link
Member

dakrone commented Nov 21, 2014

LGTM, thanks for adding the documentation

Today there is a race condition between the actual deletion of
the shard and the release of the lock in the store. This race can cause
rare imports of dangeling indices if the cluster state update loop
tires to import the dangeling index in that particular windonw. This commit
adds more safety to the import of dangeling indices and removes the race
condition by holding on to the lock on store closing while the listener
is notified.
@s1monw s1monw merged commit a6e6c4e into elastic:master Nov 21, 2014
@clintongormley clintongormley added :Core/Infra/Core Core issues without another label >enhancement and removed review labels Mar 19, 2015
@clintongormley clintongormley changed the title [CORE] Ensure shards are deleted under lock on close Ensure shards are deleted under lock on close Jun 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants