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

Consolidate directory lock obtain code #11390

Merged
merged 1 commit into from May 28, 2015
Merged

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented May 28, 2015

The Directory#makeLock API is trappy and can easily lead to unexpected
lock release if native locks are used. see LUCENE-6507 for details.
This commit consolidates the lock lock into one place and only returns
the lock instance if we actually acquired it.

* This method uses the {@link IndexWriterConfig#getDefaultWriteLockTimeout()} as the lock timeout.
*/
public static Lock acquireWriteLock(Directory directory) throws IOException {
return acuquireLock(directory, IndexWriter.WRITE_LOCK_NAME, IndexWriterConfig.getDefaultWriteLockTimeout());
Copy link
Contributor

Choose a reason for hiding this comment

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

acuquire -> acquire

@rmuir
Copy link
Contributor

rmuir commented May 28, 2015

looks good. it simplifies callers usage of locks. but this wont' avoid any problems from LUCENE-6507, its just a good cleanup.

The Directory#makeLock API is trappy and can easily lead to unexpected
lock release if native locks are used. see LUCENE-6507 for details.
This commit consolidates the lock lock into one place and only returns
the lock instance if we actually acquired it.
@s1monw s1monw merged commit a4c88b7 into elastic:master May 28, 2015
@s1monw s1monw deleted the fix_acquire_lock branch May 28, 2015 14:16
@clintongormley clintongormley added the :Distributed/Store Issues around managing unopened Lucene indices. If it touches Store.java, this is a likely label. label May 29, 2015
@clintongormley clintongormley added :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. and removed :Distributed/Store Issues around managing unopened Lucene indices. If it touches Store.java, this is a likely label. labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Engine Anything around managing Lucene and the Translog in an open shard. >enhancement v1.6.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants