Hello,

There is a crash in IndexWrite.cpp IndexWrite::flushDocStores()
I have gone through some searches in the Lucene pages. It is mentioned to be a 
problem but no fix is visible.

Could you confirm the following fix I have done below.
Thanks
Roger Bosshard

In IndexWrite.cpp
bool IndexWriter::flushDocStores() {
       SCOPED_LOCK_MUTEX(THIS_LOCK)

  // Roger: 05.05.2014
  // If index writer useCompoundDocStore, then files will be deleted in 
closeDocStore()
  // Later on, CompoundFileWriter would crash as files is not valid anymore
  // To prevent this, unlink _files from docWriter if the index writer is 
useCompoundDocStore
  //const std::vector<std::string>& files = docWriter->files();
  std::vector<std::string>* filesptr = 
docWriter->filesptr(mergePolicy->useCompoundDocStore(segmentInfos));
  const std::vector<std::string>& files = *filesptr;

  bool useCompoundDocStore = false;

  if (files.size() > 0) {
    string docStoreSegment;

    bool success = false;
    try {
      docStoreSegment = docWriter->closeDocStore();
      success = true;
    } _CLFINALLY (
      if (!success) {
        if (infoStream != NULL)
          message(string("hit exception closing doc store segment"));
        docWriter->abort(NULL);
      }
    )

    useCompoundDocStore = mergePolicy->useCompoundDocStore(segmentInfos);

    if (useCompoundDocStore && !docStoreSegment.empty()) {
      // Now build compound doc store file

      success = false;

      const int32_t numSegments = segmentInfos->size();
      const string compoundFileName = docStoreSegment + "." + 
IndexFileNames::COMPOUND_FILE_STORE_EXTENSION;

      try {
        CompoundFileWriter cfsWriter(directory, compoundFileName.c_str());
        const size_t size = files.size();
        for(size_t i=0;i<size;++i)
          cfsWriter.addFile(files[i].c_str());

        // Perform the merge
        cfsWriter.close();

        for(int32_t i=0;i<numSegments;i++) {
          SegmentInfo* si = segmentInfos->info(i);
          if (si->getDocStoreOffset() != -1 &&
              si->getDocStoreSegment().compare(docStoreSegment)==0)
            si->setDocStoreIsCompoundFile(true);
        }
        checkpoint();
        success = true;
      } _CLFINALLY (
        if (!success) {

          if (infoStream != NULL)
            message("hit exception building compound file doc store for segment 
" + docStoreSegment);

          // Rollback to no compound file
          for(int32_t i=0;i<numSegments;i++) {
            SegmentInfo* si = segmentInfos->info(i);
            if (si->getDocStoreOffset() != -1 &&
                si->getDocStoreSegment().compare(docStoreSegment)==0 )
              si->setDocStoreIsCompoundFile(false);
          }
          deleter->deleteFile(compoundFileName.c_str());
          deletePartialSegmentsFile();
        }
      )

      deleter->checkpoint(segmentInfos, false);
    }
    if (useCompoundDocStore)
      _CLLDELETE(filesptr); // Roger: 05.05.2014: delete if it has been unlinked
  }

  return useCompoundDocStore;
}

**
In DocumentWriter.cpp
std::vector<std::string>* DocumentsWriter::filesptr(bool unlink) {
       SCOPED_LOCK_MUTEX(THIS_LOCK)

   files(); // Build _files if not already built
   if (unlink) {
      std::vector<std::string>* unlinkptr = _files;
      _files = NULL; // unlink; caller must free ptr
      return unlinkptr;
   }
   else
      return _files;
}

In _DocumentWrite.h
  /* Returns list of files in use by this instance,
   * including any flushed segments. */
  const std::vector<std::string>& files();
  std::vector<std::string>* filesptr(bool unlink);


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
CLucene-developers mailing list
CLucene-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/clucene-developers

Reply via email to