Lock obtain timed out: simplefslock @ E: // your ource // your Etest // index // write. Lock exception

Source: Internet
Author: User

Lock obtain timed out: simplefslock @ E: // cause of javasource // deleetest // index // write. Lock exception:

 

1. When Lucene writes an index, it is used to create a write under the index directory. lock file to identify the lock. the lock file will be deleted only after the close () method is executed. if this file exists, other indexedProgramAn error is reported:

Caught a class org. Apache. Lucene. Store. lockobtainfailedexception

With message: Lock obtain timed out: simplefslock @ E: // your ource // your Etest // index // write. Lock

Therefore, be sure to disable indexwrite. If an exception occurs, use finally to disable it. Otherwise, the next index write will fail.

 

2. If the Lucene index directory contains a lot of files, it is definitely a problem. several aspects. when Lucene performs a write operation, it first writes a Write statement in the directory. lock file to lock this directory, to avoid other indexes and then operate on this path. otherwise, it will be messy. after the lock, start to write the index. When writing the index, Lucene creates several or dozens of temporary fragment files, which all seem to be short and messy characters. CFS file. after the index is created, no indexwriter is executed. optimize (); method, it will not merge those messy files. therefore, after the index is created, you must execute the above optimization method to keep three files in the directory. that is, many temporary files will be merged into one file. you cannot delete it. however, when there is a large amount of data, we will consider other strategies.

3. Add indexes in batches. What should I do if I want to add indexes cyclically in batches? First, please note: indexwriter = new indexwriter (indexdir,

New thesaurusanalyzer (), false); the last parameter "false" indicates that data is continuously added to the index. If it is set to true, all data is deleted and restarted each time.

4. When adding indexes in batches, the program can always Execute

Indexwriter. adddocument (DOC); but cannot be optimized all the time: indexwriter. optimize (); because the optimization method is time-consuming, especially when the index is large, pay attention to it. because of the optimization, it just seems that the optimization will consume a lot of time and CPU. so this time. it does not matter if there are several more files.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.