Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Segment Replication] Swap replica to writeable engine during failover. #3989

Closed
Tracked by #2212 ...
mch2 opened this issue Jul 22, 2022 · 1 comment · Fixed by #4135
Closed
Tracked by #2212 ...

[Segment Replication] Swap replica to writeable engine during failover. #3989

mch2 opened this issue Jul 22, 2022 · 1 comment · Fixed by #4135
Assignees
Labels
distributed framework enhancement Enhancement or improvement to existing feature or request

Comments

@mch2
Copy link
Member

mch2 commented Jul 22, 2022

As part of #2212, after a new primary has been selected we will need to convert its engine from an NRTReplicationEngine to InternalEngine.

The logic we are looking for here is similar to IndexShard's resetEngineToGlobalCheckpoint. However, we cannot simply close and reopen the engine. Replicas may have uncommitted operations in the index if it had synced from a refresh point of the previous primary. Lucene does not currently provide a way for us to convert from a directory reader that refreshes on an externally provided segmentInfos back to one that refreshes on an IW. This means we will only be able to open the InternalEngine with its writer from disk.

A suggested sequence for replica promotion:

  • Invoke a SegmentInfos.commit on the replica, creating a new commit point (Segments_N). We are safe committing here outside of an IW because there are no buffers that need to be flushed / new segments that need to be created. This commit should also include the latest local cp on the replica in userdata.
  • manually fsync the store with directory.sync so the commit point is durably persisted.
  • purge the xlog up to the local cp.
  • close and open up a new InternalEngine.
  • Replay any ops remaining in the xlog.
  • Refresh to push out latest checkpoint to replicas.
@mch2 mch2 added enhancement Enhancement or improvement to existing feature or request distributed framework labels Jul 22, 2022
@mch2 mch2 changed the title [Segment Replication] Swap newly assigned primary to writeable engine. [Segment Replication] Swap between writeable / RO replica engines during failover. Jul 22, 2022
@mch2 mch2 changed the title [Segment Replication] Swap between writeable / RO replica engines during failover. [Segment Replication] Swap between writeable / read-only replica engines during failover. Jul 22, 2022
@mch2 mch2 self-assigned this Jul 25, 2022
@mch2 mch2 changed the title [Segment Replication] Swap between writeable / read-only replica engines during failover. [Segment Replication] Swap replica to writeable engine during failover. Jul 25, 2022
@mch2
Copy link
Member Author

mch2 commented Jul 26, 2022

Checklist for me as I go through this...

  • commit SegmentInfos on the replica storing checkpoints.
  • Write a test asserting the engine type is swapped during failover.
  • xlog is purged up to the local cp on the commit and that remaining ops are indexed.
  • Accuracy of the local cp on the replica, this is being sent as seqNo during replication, it should be set by reading the index.
  • Prevent reindexing after promotion - engine should not revert to a previous safe commit & reindex up to global cp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed framework enhancement Enhancement or improvement to existing feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant