-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Reimplement snapshots as a new implementation of Engine interface. #256
Conversation
This fixes a TODO in the code and helpful to upcoming changes to implement asynchronous scans of ranges for custodial work. Without, more Engine method variants taking snapshot IDs would be necessary. This change is more in keeping with how we do Batch engines and is simpler. Also remove the InternalSnapshotCopy method, which will be replaced by an in-Raft mechanism whereby the leader feeds the snapshot directly to a requesting follower.
@@ -835,113 +816,6 @@ func TestRangeIdempotence(t *testing.T) { | |||
} | |||
} | |||
|
|||
// TestRangeSnapshot. | |||
func TestRangeSnapshot(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think you'd want some tests that the various snapshot methods do what you expect. Am I just missing where this testing is being done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, added unittests for all snapshot methods.
Changed NewSnapshot behavior to log an error and return nil if called from a snapshot.
Reimplement snapshots as a new implementation of Engine interface.
// read-only rocksDBSnapshot engine. | ||
func (r *RocksDB) NewSnapshot() Engine { | ||
if r.rdb == nil { | ||
log.Errorf("RocksDB is not initialized yet") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I think it's better to panic than to log an error and return nil (when we cannot return an error
) (here and inMemSnapshot.New{Batch,Snapshot})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #257
LGTM |
This fixes a TODO in the code and helpful to upcoming changes to
implement asynchronous scans of ranges for custodial work. Without,
more Engine method variants taking snapshot IDs would be necessary.
This change is more in keeping with how we do Batch engines and is
simpler.
Also remove the InternalSnapshotCopy method, which will be replaced
by an in-Raft mechanism whereby the leader feeds the snapshot directly
to a requesting follower.