通过 IndexWriter.UpdateDocument 更新文档在 IndexWriter.Commit 提交时报错 "invalid docCount"
Lucene.Net.Index.CorruptIndexException: invalid docCount: 2 maxDoc: 1 (resource=MMapIndexInput(path="/zzk/index/blogpost/_afj.cfs") [slice=_afj_Lucene41_0.tim])
at Lucene.Net.Codecs.BlockTreeTermsReader..ctor(Directory dir, FieldInfos fieldInfos, SegmentInfo info, PostingsReaderBase postingsReader, IOContext ioContext, String segmentSuffix, Int32 indexDivisor)
at Lucene.Net.Codecs.Lucene41.Lucene41PostingsFormat.FieldsProducer(SegmentReadState state)
at Lucene.Net.Codecs.PerField.PerFieldPostingsFormat.FieldsReader..ctor(SegmentReadState readState)
at Lucene.Net.Index.SegmentCoreReaders..ctor(SegmentReader owner, Directory dir, SegmentCommitInfo si, IOContext context, Int32 termsIndexDivisor)
at Lucene.Net.Index.SegmentReader..ctor(SegmentCommitInfo si, Int32 termInfosIndexDivisor, IOContext context)
at Lucene.Net.Index.ReadersAndUpdates.GetReader(IOContext context)
at Lucene.Net.Index.BufferedUpdatesStream.ApplyDeletesAndUpdates(ReaderPool readerPool, IList`1 infos)
at Lucene.Net.Index.IndexWriter.ApplyAllDeletesAndUpdates()
at Lucene.Net.Index.IndexWriter.MaybeApplyDeletes(Boolean applyAllDeletes)
at Lucene.Net.Index.IndexWriter.PrepareCommitInternal()
at Lucene.Net.Index.IndexWriter.CommitInternal()
请问如何解决?
问题是并发更新索引引起的,改为以队列方式更新索引后问题就消失了,目前队列用的是 Coravel 的 IQueue,接下来准备基于 dapr 实现(本来就是订阅 dapr 消息更新索引的) https://q.cnblogs.com/q/142679/
cfs 是 Compound File 的缩写
– dudu 1年前