asp.net - Does Lucene.Net manage multiple threads accessing the same index, one indexing while the other is searching? -
when using lucene.net asp.net, can imagine 1 web request can trigger update index while web request performing search. lucene.net have built in ability manage concurrent access, or have manage it, avoid "being used process" errors?
edit: after reading docs , experimentation, think i've learned: there 2 issues, thread safety , concurrency. multithreading "safe" in can't bad index. but, it's safe @ cost of 1 object having lock on index @ 1 time. second object come along , throw exception. so, can't leave search open , expect writer in thread able update index. , if thread busy updating index, trying create searcher fail.
also, searchers see index @ time open it, if keep them around, , update index, won't see updates.
i wanted searchers see latest updates.
my design, , seems working far, writers , searchers share lock, don't fail - wait - until current write or search done.
according this page,
indexing , searching not thread safe, process safe. means that:
- multiple index searchers can read lucene index files @ same time.
- an index writer or reader can edit lucene index files while searches ongoing
- multiple index writers or readers can try edit lucene index files @ same time (it's important index writer/reader closed release file lock). however, query parser not thread safe, each thread using index should have own query parser.
the index writer however, thread safe, can update index while people searching it. however, have make sure threads open index searchers close them , open new ones, newly updated data.
Comments
Post a Comment