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

Upgrade to current Lucene 5.0.0 snapshot #8588

Closed
wants to merge 4 commits into from

Conversation

mikemccand
Copy link
Contributor

A few recent lucene changes to fold in:

We've removed IndexWriter.unLock in Lucene, so I also removed "clear
lock on startup" in Elasticsearch. A couple test cases were missing
engine.close() before opening a new engine.

I exposed the new SerbianNormalizationFilterFactory.

I noticed that we silently use NoLockFactory if you have a typo in
your index.store.fs.fs_lock; I changed this to throw
StoreException instead. I think it's scary to be lenient
here?

The trickiest change was DistributorDirectory, and how it tracks the
file created by the lock factory. For the writeFiles boolean, I had
to remove the check that "lockFactory instanceof FSLockFactory"; maybe
we could use reflection to get this, if it's really necessary? (Do we
really support using NoLockFactory w/ FSDirectory?). Or maybe instead
we could check if the class name of the lock/factory is NoLock, but
MockDirWrapper wraps in AssertingLock...

I added some harmless "synchronized" to methods (all callers of these
private methods are already sync'd) just to make it clear on quick
look that all access/changes to nameDirMapping are in fact sync'd.

I also fixed ConcurrentMergeSchedulerProvider to disable Lucene's CMS
stalling (override w/ an empty maybeStall method). We can simplify
things here: remove EnableMergeScheduler, the separate MERGE thread
pool, let IndexWriter launch merges when they are needed (not
separately, once every second), etc., since Lucene won't stall
indexing threads anymore ... I'll open a separate issue for this.

@@ -82,10 +84,10 @@ public NodeEnvironment(Settings settings, Environment environment) throws IOExce
if (Files.exists(dir) == false) {
Files.createDirectories(dir);
}
logger.trace("obtaining node lock on {} ...", dir.toAbsolutePath());
Directory luceneDir = FSDirectory.open(dir);
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use try / with here?

@s1monw
Copy link
Contributor

s1monw commented Nov 23, 2014

left once comment - LGTM otherwise

@rmuir
Copy link
Contributor

rmuir commented Nov 23, 2014

looks good to me. Maybe @uschindler is curious about lockfactory changes.

NativeFSLockFactory lockFactory = new NativeFSLockFactory(dir);
Lock tmpLock = lockFactory.makeLock("node.lock");
logger.trace("obtaining node lock on {} ...", dir.toAbsolutePath());
Lock tmpLock = NativeFSLockFactory.INSTANCE.makeLock(luceneDir, "node.lock");
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be: Lock tmpLock = luceneDir.makeLock("node.lock");
(using LockFactories directly is no longer wanted, they are no first class citizen anymore - the actual locking is responsibility of the Directory impl, BaseDirectory in Lucene just delegates to a lock factory, but thats an impl detail).
And if you want NativeFSLockFactory explicit, pass it to the FSDirectory ctor/factory.

@mikemccand
Copy link
Contributor Author

Thank you for all the feedback, I folded it all in @uschindler

public synchronized String getLockID() {
return distributor.primary().getLockID();
/** Called by makeLock's wrapped lock, to record the lock file. */
synchronized void addNameDirMapping(String name, Directory dir) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this method can be private now

@uschindler
Copy link
Contributor

See my comments above. Otherwise its correct API-wise. It also took me a long time while refactoring LockFactory in Lucene that you don't need one in most cases. LockFactory is just an implementation detail of BaseDirectory which should only be used for actual "real" directory implementations. Everything that wraps or filters should use Directory (for complex delegation like FileSwitchDirectory) or FilterDirectory (for simple delagation).

@mikemccand
Copy link
Contributor Author

I pushed another commit w/ feedback from @uschindler (thanks Uwe!); I think it's ready.

@s1monw
Copy link
Contributor

s1monw commented Nov 24, 2014

LGTM

@uschindler
Copy link
Contributor

+1

mikemccand added a commit that referenced this pull request Dec 11, 2014
It's dangerous to release this lock because it means another ES
somehow still has an IndexWriter open on the directory, which can
lead to corruption.

Instead, we don't release the lock, and the user will see an exception
on init.

This was already fixed on master with #8588; I'm backporting to 1.x
here.

Closes #8892
mikemccand added a commit that referenced this pull request Dec 11, 2014
It's dangerous to release this lock because it means another ES
somehow still has an IndexWriter open on the directory, which can
lead to corruption.

Instead, we don't release the lock, and the user will see an exception
on init.

This was already fixed on master with #8588; I'm backporting to 1.x
here.

Closes #8892
mikemccand added a commit that referenced this pull request Dec 11, 2014
It's dangerous to release this lock because it means another ES
somehow still has an IndexWriter open on the directory, which can
lead to corruption.

Instead, we don't release the lock, and the user will see an exception
on init.

This was already fixed on master with #8588; I'm backporting to 1.x
here.

Closes #8892
@clintongormley clintongormley changed the title Core: upgrade to current Lucene 5.0.0 snapshot Upgrade to current Lucene 5.0.0 snapshot Jun 8, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
It's dangerous to release this lock because it means another ES
somehow still has an IndexWriter open on the directory, which can
lead to corruption.

Instead, we don't release the lock, and the user will see an exception
on init.

This was already fixed on master with elastic#8588; I'm backporting to 1.x
here.

Closes elastic#8892
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
It's dangerous to release this lock because it means another ES
somehow still has an IndexWriter open on the directory, which can
lead to corruption.

Instead, we don't release the lock, and the user will see an exception
on init.

This was already fixed on master with elastic#8588; I'm backporting to 1.x
here.

Closes elastic#8892
@clintongormley clintongormley added :Core/Infra/Core Core issues without another label and removed :Core/Infra/Core Core issues without another label >enhancement labels Aug 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >upgrade v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants