guojialiang92 commented on issue #14362:
URL: https://github.com/apache/lucene/issues/14362#issuecomment-2747968162
Hi @vigyasharma
I will explain the usage scenarios.
In the **segment replication** scenario, the file name and content of the
replica and the primary shard will be consistent. Usually, the replica shard
uses **ReadOnlyEngine** and does not hold IndexWriter. The primary shard uses
**ReadWriteEngine** and uses IndexWriter for segment building.
When there is **replica promotion** or **primary shard relocation**, we need
to increase the segment count of the **new primary shard** to the specified
value according to the algorithm (such as the raft). We need to avoid the new
primary shard generating files with the same name but different content as the
old primary shard.
In the current situation, we will not be able to increase the segment
counter when the primary shard is created.
In the replica promotion scenario, a current alternative is to add
`SegmentInfos#counter` when the replica shard is closed, and execute
`SegmentInfos#commit` to persist the file to disk. When the new primary shard
initializes **ReadWriteEngine**, it reads the updated `segment_N` file from
disk.
However, this alternative solution has some drawbacks. For example, when the
replica exits abnormally, it cannot guarantee the successful update of the
segment counter. At the same time, in the primary shard relocation scenario, it
is impossible to modify the segment counter in InterWriter (you can only use
**ReadOnlyEngine** like replica promotion, and then switch to
**ReadWriteEngine**, which will cause serious write blocking).
Looking forward to your reply.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]