mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
only check and clear write locks (not commit locks)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2424 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -860,6 +860,20 @@ public abstract class LuceneBase implements Lockable
|
|||||||
getLuceneIndexLock().getReadLock(store);
|
getLuceneIndexLock().getReadLock(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isWriteLocked(String directory) throws IOException
|
||||||
|
{
|
||||||
|
Directory dir = FSDirectory.getDirectory(directory, false);
|
||||||
|
boolean result = isWriteLocked(dir);
|
||||||
|
dir.close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWriteLocked(Directory directory) throws IOException
|
||||||
|
{
|
||||||
|
return directory.makeLock(IndexWriter.WRITE_LOCK_NAME).isLocked();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private int writeLockCount = 0;
|
private int writeLockCount = 0;
|
||||||
|
|
||||||
public void getWriteLock() throws LuceneIndexException
|
public void getWriteLock() throws LuceneIndexException
|
||||||
@@ -870,11 +884,18 @@ public abstract class LuceneBase implements Lockable
|
|||||||
// We must have the lock
|
// We must have the lock
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (((writeLockCount == 1) && IndexReader.indexExists(baseDir) && (IndexReader.isLocked(baseDir.getPath()))))
|
if (((writeLockCount == 1) && IndexReader.indexExists(baseDir) && (LuceneBase.isWriteLocked(baseDir
|
||||||
|
.getPath()))))
|
||||||
{
|
{
|
||||||
Directory dir = FSDirectory.getDirectory(baseDir, false);
|
Directory dir = FSDirectory.getDirectory(baseDir, false);
|
||||||
IndexReader.unlock(dir);
|
try
|
||||||
dir.close();
|
{
|
||||||
|
dir.makeLock(IndexWriter.WRITE_LOCK_NAME).release();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
dir.close();
|
||||||
|
}
|
||||||
s_logger.warn("Releasing unexpected lucene index write lock for " + baseDir);
|
s_logger.warn("Releasing unexpected lucene index write lock for " + baseDir);
|
||||||
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||||
for (StackTraceElement el : trace)
|
for (StackTraceElement el : trace)
|
||||||
@@ -902,12 +923,18 @@ public abstract class LuceneBase implements Lockable
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (((writeLockCount == 1) && IndexReader.indexExists(baseDir) && (IndexReader.isLocked(baseDir
|
if (((writeLockCount == 1) && IndexReader.indexExists(baseDir) && (LuceneBase.isWriteLocked(baseDir
|
||||||
.getPath()))))
|
.getPath()))))
|
||||||
{
|
{
|
||||||
Directory dir = FSDirectory.getDirectory(baseDir, false);
|
Directory dir = FSDirectory.getDirectory(baseDir, false);
|
||||||
IndexReader.unlock(dir);
|
try
|
||||||
dir.close();
|
{
|
||||||
|
dir.makeLock(IndexWriter.WRITE_LOCK_NAME).release();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
dir.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
Reference in New Issue
Block a user