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

Fail point-in-time WAL recovery upon IOError reading WAL #6963

Closed
wants to merge 2 commits into from

Conversation

riversand963
Copy link
Contributor

If options.wal_recovery_mode == WALRecoveryMode::kPointInTimeRecovery, RocksDB stops replaying WAL once hitting an error and discards the rest of the WAL. This can lead to data loss if the error occurs at an offset smaller than the last sync'ed offset.
Ideally, RocksDB point-in-time recovery should permit recovery if the error occurs after last synced offset while fail recovery if error occurs before the last synced offset. However, RocksDB does not track the synced offset of WALs. Consequently, RocksDB does not know whether an error occurs before or after the last synced offset. An error can be one of the following.

  • WAL record checksum mismatch. This can result from both corruption of synced data and dropping of unsynced data during shutdown. We cannot be sure which one. In order not to defeat the original motivation to permit the latter case, we keep the original behavior of point-in-time WAL recovery.
  • IOError. This means the WAL can be bad, an indicator of whole file becoming unavailable, not to mention synced part of the WAL. Therefore, we choose to modify the behavior of point-in-time recovery and fail the database recovery.

Test plan (devserver):
make check

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I wonder if we should reject Open() for all errors returned by the underlying Env. It's difficult right now because we can't distinguish where status->IsCorruption() originates -- it could either be from the underlying Env or from RocksDB detecting checksum mismatch. In any case I think this PR is a step forward and should be landed.

@riversand963
Copy link
Contributor Author

LGTM!

I wonder if we should reject Open() for all errors returned by the underlying Env. It's difficult right now because we can't distinguish where status->IsCorruption() originates -- it could either be from the underlying Env or from RocksDB detecting checksum mismatch. In any case I think this PR is a step forward and should be landed.

In other places such as https://github.com/facebook/rocksdb/blob/master/db/version_set.h#L1162, RocksDB uses a separate status variable to keep track of IO errors. We probably can follow similar approach by adding a member variable to log::Reader::Reporter.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@riversand963 merged this pull request in 717749f.

@riversand963 riversand963 deleted the wal-replay-ioerror branch June 12, 2020 03:19
@yiwu-arbug
Copy link
Contributor

Thanks for the improvement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Point-in-time recovery should fail on IO error when reading WAL
4 participants