Repository navigation
refactor: replay the AOF through the keyspace - #416
Merged
Merged
Conversation
Recovery repeated the effect of every write command against a HashMap in ember-persistence, a second copy of the command logic that could drift from the keyspace. ember-persistence now only reads the files and hands entries and records to a Recover target. The shard implements it with its keyspace: each record becomes the request that wrote it and runs through dispatch. The AOF is scanned once before anything is applied, so a file corrupt mid-way is still skipped as a whole.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ember-persistence/src/recovery.rsreplayed the AOF against its ownHashMap<String, (RecoveredValue, ttl)>, with a hand-written copy of every write command's effect: INCR, LPUSH, LTRIM, ZADD, HINCRBY, vectors and the rest. That was about 560 lines of command logic outside the keyspace, and it had already drifted. For example, anEXPIRErecord could bring back a snapshot key whose TTL had run out, because the map kept expired keys until the end.Now:
ember-persistenceonly reads files.recover_shardhands snapshot entries toRecover::restoreand AOF records toRecover::apply.Recoverwith its keyspace (shard/persistence.rs). A snapshot entry goes throughKeyspace::restore. An AOF record becomes the request that wrote it, viafrom_aof_recordfrom refactor: move the AOF record to request converter into ember-core #415, and runs throughdispatch, the same path as a live command.RecoveredValue,RecoveredEntryand the shard's ownRecoveredValuetoValueconversion are removed.Tests:
About 1,200 fewer lines in total.