Issue Type: Bug Bug
Affects Versions: 4.2.0.Final
Assignee: Unassigned
Attachments: locking_indefinitely_fix.diff
Components: engine
Created: 11/May/13 9:47 AM
Description:

We've observed an issue in SharedIndexWorkspaceImpl that appears to be a bug.

Due to the nature of the bug (requires running two separate jvms) creating a test case would be difficult, however it is pretty simple to reason through.

within
SharedIndexWorkspaceImpl#getIndexWriter()
SharedIndexWorkspaceImpl#getIndexWriter(ErrorContextBuilder errorContextBuilder)

The openWritersUsers is incremented before an IndexWriter is successfully obtained.

We are seeing a scenario with two separate jvms writing to the same index where one process holds a lock long enough to cause a locktimeout and the second process fails to obtain an IndexWriter (yet it still increments the openWritersUsers). Subsequent writes from the second process create a lock which is never closed due to openWriterUsers being > 0.

Our fix:
@Override
public IndexWriter getIndexWriter() {
synchronized ( lock ) {
IndexWriter indexWriter = super.getIndexWriter();
if(indexWriter != null)

{ openWriterUsers++; }
return indexWriter;
}
}

public IndexWriter getIndexWriter(ErrorContextBuilder errorContextBuilder) {
synchronized ( lock ) {
IndexWriter indexWriter = super.getIndexWriter( errorContextBuilder );
if(indexWriter != null) { openWriterUsers++; }

return indexWriter;
}
}

Thanks,
Tobias

Environment: hibernate-search 4.2.0.Final, any db
Project: Hibernate Search
Labels: locks
Priority: Major Major
Reporter: Tobias Carson
Original Estimate: 1h
Remaining Estimate: 1h
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira