lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Digy (JIRA)" <>
Subject [jira] Commented: (LUCENENET-135) Race condition in DocumentsWriter.UpdateDocument
Date Fri, 08 Aug 2008 17:29:44 GMT


Digy commented on LUCENENET-135:


 1) SupportClass.patch fixes "Index/TestIndexWriter/TestDocumentsWriterExceptionThreads"
 2) In fact , There is no race condition  in DocumentsWriter(at least for now). It all started
when I saw two threads entering the "GetThreadState" at the same time which is a synchronized
method. So, I falsely determined that it was a race condition.  And finally, It turned out
to be a bug in ThreadClass.

ThreadClass'es static "Current" method always returns a new instance of ThreadClass,
and because it is used as a key to HashTable "threadBindings"(DocumentsWriter.GetThreadState),

ThreadState state = (ThreadState) threadBindings[SupportClass.ThreadClass.Current()];
if (state == null)
   threadBindings[SupportClass.ThreadClass.Current()] = state;
"State==null" never gets false and ,everytime, initializations of the first-time call are

I think the patch is correct. But after applying that patch the following simple test case
fails with an exception "Index was outside the bounds of the array".
        public void TestIndexWriter1()
            RAMDirectory dir = new RAMDirectory();
            IndexWriter wr = new IndexWriter(dir,new WhitespaceAnalyzer(), true);

            Document doc = new Document();
            Field f1 = new Field("field1", "", Field.Store.YES, Field.Index.TOKENIZED);

            for (int i = 0; i < 200000; i++)
                f1.SetValue("some text, some more text,some text, some more text,some text,
some more text,");
                    //if (i % 100 == 0) wr.Flush(); //Make that pass
                catch (Exception ex)
                    Console.WriteLine("loop:" + i + "\n" + ex.Message + "\n" + ex.StackTrace);
                    throw ex;

*Any Idea?*

PS1:*Uncommenting Flush statement in the code makes that test pass*

PS2: If you decide to close this issue, please take a look at the DocumentsWriter.patch(which
has nothing to do with any test case but applied to after the release of 2.3.1)


> Race condition in DocumentsWriter.UpdateDocument
> ------------------------------------------------
>                 Key: LUCENENET-135
>                 URL:
>             Project: Lucene.Net
>          Issue Type: Bug
>         Environment: 2.3.1
>            Reporter: Digy
>         Attachments: DocumentsWriter+SupportClass.rar, DocumentsWriter-Temp.patch, DocumentsWriter.patch,
DocumentsWriter.patch, SupportClass.patch, SupportClass.patch
> There is a race condition in DocumentsWriter.UpdateDocument. Locking the whole method
solves the problem but this is not what  is intended in java version
> (testcase:  Index/TestIndexWriter/TestDocumentsWriterExceptionThreads)
> I am working on it.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message