Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#220 IndexWriter multi-thread deadlock

open
nobody
core (32)
9
2013-04-04
2013-04-04
Xiaoman Dong
No

The IndexWriter is supposed to be thread-safe, which means one IndexWriter class can be invoked by multiple threads to write index. But I find that it will deadlock in current implementation.

I have created a unit test file to write bogus strings to file and the deadlock can be repeated easily. The .cpp test is attached, you will need visual studio 2010 (or 2011) + boost 1.53 to run the example.

I have also investigated the issue and provided my local fix for the deadlock. The fix I believe will work, the modified files are also attached, you can compare to see the changes.

I would like to contribute to the CLucene development as a CLucene core developer, but I am not sure how to proceed.

Sorry for not creating my test cross-platform. I will try to improve gradually.

Discussion

  • Xiaoman Dong
    Xiaoman Dong
    2013-04-04

    The test file for showing threaded deadlock

     
    Attachments
  • Xiaoman Dong
    Xiaoman Dong
    2013-04-04

    The modified DocumentsWriter.cpp. It can pass the threaded unit test and maintain correctness

     
    Attachments
  • Xiaoman Dong
    Xiaoman Dong
    2013-04-04

    There are two member variables in _DocumentWriter.h file that should be at least mark as "volatile". The best way is to change to boost::atomic<T> implementation if boost is later than 1.52.
    I have also attached the updated _DocumentWriter.h

     
  • Xiaoman Dong
    Xiaoman Dong
    2013-04-04

    • priority: 5 --> 9
     
  • Xiaoman Dong
    Xiaoman Dong
    2013-04-04

    The updated _DocumentWriter.h file, it is not mandatory change, but it is safer if we use volatile or boost::atomic<T>

     
    Attachments