You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Li Bing <lb...@gmail.com> on 2010/07/25 19:04:17 UTC

Lucene.Net.Store.LockObtainFailedException

Dear all,

In the past, I use C# concurrency control to manage multi-threads when
manipulating Lucene indexes. After talking with experts in the mailing list,
I know Lucene is thread-safety. So I use a single IndexWriter and get
IndexReaders from it. All of the C# concurrency control code are removed.
However, I got the following exceptions.

   Lucene.Net.Store.LockObtainFailedException: Lock obtain timed out:
Lucene.Net.Store.SingleInstanceLock: write.lock

This happens when I tries to delete one record from Lucene index. The code
is listed as follows.

            try
            {
                List<int> documentIDList =
DBMemSearcher.SearchDocumentIDBySingleKey(indexPath, keyFieldName,
keyFieldValue, DBConstants.MIN_HITS);
                IndexReader reader =
IndexReader.Open(GetIndexRAMDirectory(indexPath), false); // Get IndexReader
from RAMDirectory.
                foreach (int id in documentIDList)
                {
                    reader.DeleteDocument(id);
                }
                reader.Close();
                return true;
            }
            catch (Exception e)
            {
                return false;
            }

I need to indicate that the IndexReader is not obtained from the single
IndexWriter but from the RAMDirectory. I got an exception that the
IndexReader was read-only when it was got from the single IndexWriter. So I
have to change it to the current solution.

Could you tell me how to solve the problem?

Thanks,
Li Bing

Re: Lucene.Net.Store.LockObtainFailedException

Posted by Li Bing <lb...@gmail.com>.
Digy,

Thank you so much!

The code shown in the previous email was implemented when I used Lucene.NET
2.0. Now I use indexWriter.DeleteDocuments instead. The problem is solved!

LB

On Mon, Jul 26, 2010 at 2:05 AM, Digy <di...@gmail.com> wrote:

> indexWriter.DeleteDocuments ?
> DIGY
>
> -----Original Message-----
> From: Li Bing [mailto:lblabs@gmail.com]
> Sent: Sunday, July 25, 2010 8:04 PM
> To: lucene-net-user@incubator.apache.org
> Cc: Li Bing - Gmail
> Subject: Lucene.Net.Store.LockObtainFailedException
>
> Dear all,
>
> In the past, I use C# concurrency control to manage multi-threads when
> manipulating Lucene indexes. After talking with experts in the mailing
> list,
> I know Lucene is thread-safety. So I use a single IndexWriter and get
> IndexReaders from it. All of the C# concurrency control code are removed.
> However, I got the following exceptions.
>
>   Lucene.Net.Store.LockObtainFailedException: Lock obtain timed out:
> Lucene.Net.Store.SingleInstanceLock: write.lock
>
> This happens when I tries to delete one record from Lucene index. The code
> is listed as follows.
>
>            try
>            {
>                List<int> documentIDList =
> DBMemSearcher.SearchDocumentIDBySingleKey(indexPath, keyFieldName,
> keyFieldValue, DBConstants.MIN_HITS);
>                IndexReader reader =
> IndexReader.Open(GetIndexRAMDirectory(indexPath), false); // Get
> IndexReader
> from RAMDirectory.
>                foreach (int id in documentIDList)
>                {
>                    reader.DeleteDocument(id);
>                }
>                reader.Close();
>                return true;
>            }
>            catch (Exception e)
>            {
>                return false;
>            }
>
> I need to indicate that the IndexReader is not obtained from the single
> IndexWriter but from the RAMDirectory. I got an exception that the
> IndexReader was read-only when it was got from the single IndexWriter. So I
> have to change it to the current solution.
>
> Could you tell me how to solve the problem?
>
> Thanks,
> Li Bing
>
>

RE: Lucene.Net.Store.LockObtainFailedException

Posted by Digy <di...@gmail.com>.
indexWriter.DeleteDocuments ?
DIGY

-----Original Message-----
From: Li Bing [mailto:lblabs@gmail.com] 
Sent: Sunday, July 25, 2010 8:04 PM
To: lucene-net-user@incubator.apache.org
Cc: Li Bing - Gmail
Subject: Lucene.Net.Store.LockObtainFailedException

Dear all,

In the past, I use C# concurrency control to manage multi-threads when
manipulating Lucene indexes. After talking with experts in the mailing list,
I know Lucene is thread-safety. So I use a single IndexWriter and get
IndexReaders from it. All of the C# concurrency control code are removed.
However, I got the following exceptions.

   Lucene.Net.Store.LockObtainFailedException: Lock obtain timed out:
Lucene.Net.Store.SingleInstanceLock: write.lock

This happens when I tries to delete one record from Lucene index. The code
is listed as follows.

            try
            {
                List<int> documentIDList =
DBMemSearcher.SearchDocumentIDBySingleKey(indexPath, keyFieldName,
keyFieldValue, DBConstants.MIN_HITS);
                IndexReader reader =
IndexReader.Open(GetIndexRAMDirectory(indexPath), false); // Get IndexReader
from RAMDirectory.
                foreach (int id in documentIDList)
                {
                    reader.DeleteDocument(id);
                }
                reader.Close();
                return true;
            }
            catch (Exception e)
            {
                return false;
            }

I need to indicate that the IndexReader is not obtained from the single
IndexWriter but from the RAMDirectory. I got an exception that the
IndexReader was read-only when it was got from the single IndexWriter. So I
have to change it to the current solution.

Could you tell me how to solve the problem?

Thanks,
Li Bing