lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "wenjie zheng" <wenjie.zh...@gmail.com>
Subject Problem when deleting files from index
Date Sun, 05 Mar 2006 01:36:34 GMT
 My program loops thru a list of email records, first searches in index for
its docid.
Once it gets the docid, it will try to remove the doc from the index.

The problem I ran into was:
4 out 10 times I ran the program, I got "Lock obtain timed out:
Lock@/tmp/lucene-6c36cae1cb524a61cdbb38a32f2ef684-write.lock" on the last
email record I tried to delete.
5 out 10 times it finished just fine.
1 out 10 times it got Lock error when there were more than one email records
left to delete (there are totally 29 docs in the index)

Here is the code:
int i = 0;
Iterator<EmailRecord> it = v.iterator(); //v is the vector contains email
records
while(it.hasNext()){
EmailRecord eml = (EmailRecord)it.next();
// local search function to get the docId, searcher and Directory are closed
after search is done
int docid = lSearcher.search(eml);
// if doc not found, change the status updator
if(docid == SystemConfig.ERROR_DOC_NOT_FOUND){
// update database entry
updator.setStatus(i, SystemConfig.ERROR_DOC_NOT_FOUND);
}else{
Directory indexDir = null;
IndexModifier modifier = null;
try{
indexDir = FSDirectory.getDirectory(index, false);
modifier = new IndexModifier(indexDir, new StandardAnalyzer(), false);
modifier.deleteDocument(docid);

modifier.flush(); // make sure all the changes pushed to the disk
modifier.close();
indexDir.close();
}catch(IOException e){
logger.error("Cannot delete " + docid + " th doc from the index: " +
eml.getUsername() + " " + e.getMessage());
updator.setStatus(i, SystemConfig.ERROR_CANNOT_DELETE);
}
// try to sleep between two deletions
try{
Thread.sleep(100);
}catch(InterruptedException e){
logger.error("Cannot sleep after one deletion... " + e.getMessage());
}
}
i++;
}

Thanks

Wenjie

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message