-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
storage: Replica.String, Replica.Desc, and Replica logging refactor #7871
Conversation
Review status: 0 of 3 files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. storage/replica.go, line 207 [r1] (raw file):
storage/replica.go, line 208 [r1] (raw file):
storage/replica.go, line 633 [r1] (raw file):
@bdarnell I'm not familiar enough with the subtleties of this code to know if this is kosher. It would be a more conservative change to leave this method untouched and to change storage/replica.go, line 787 [r1] (raw file):
You should get rid of the Comments from Reviewable |
Reviewed 3 of 3 files at r1. storage/replica.go, line 211 [r1] (raw file):
why is it better to have this in two places? either we need atomic-with-other-things updates or we don't. storage/replica.go, line 396 [r1] (raw file):
why not %+v the ident? Comments from Reviewable |
Review status: all files reviewed at latest revision, 6 unresolved discussions, all commit checks successful. storage/replica.go, line 396 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 6 unresolved discussions, all commit checks successful. storage/replica.go, line 396 [r1] (raw file):
|
Context: replica.String used to call replica.Desc, which used to acquire the replica.mu lock. Its use was thus restricted to places where the lock was not already acquired (see cockroachdb#7852). Add a new atomically readable rangeDescriptor to replica, under mu.rangeDesc, which is a duplicate of the existing mu.state.Desc. mu.rangeDesc is updated alongside mu.state.Desc under the replica.mu lock, but it is read freely without locking. Change replica.String to use this new atomically readable non-locking rangeDescriptor, so they no longer acquire any locks. Conservatively leave replica.Desc unchanged.
f82e4ca
to
571033c
Compare
Review status: 1 of 3 files reviewed at latest revision, 6 unresolved discussions, some commit checks pending. storage/replica.go, line 207 [r1] (raw file):
|
Still Review status: 1 of 3 files reviewed at latest revision, 2 unresolved discussions, some commit checks pending. Comments from Reviewable |
571033c
to
485ca49
Compare
Added changes in Review status: 1 of 4 files reviewed at latest revision, 2 unresolved discussions, some commit checks pending. Comments from Reviewable |
Review status: 1 of 4 files reviewed at latest revision, 3 unresolved discussions, some commit checks pending. storage/replica_raftstorage.go, line 435 [r3] (raw file):
You need to include Comments from Reviewable |
replica.String used to acquire the replica.mu lock (via a call to replica.Desc). It was therefore not used in places where the lock was already acquired. replica.String no longer acquires this lock, so it now safe to call liberally. Refactor all logs in replica.go, replica_command.go, and replica_raftstorage.go to prepend information from replica.String (unless they already print context information). Closes cockroachdb#7852.
485ca49
to
9af718e
Compare
storage/replica_raftstorage.go, line 435 [r3] (raw file):
|
Review status: 1 of 4 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. storage/replica.go, line 211 [r1] (raw file):
|
In cockroachdb#7871, replica.String() was refactored to use a new atomically readable copy of the RangeDescriptor. replica.Desc() could use this as well (so as to not lock replica.mu), but this change was conservatively deferred. However, with the issue of replica.Desc() acquiring locks being raised in cockroachdb#7888, and after discussion with @bdarnell, it should be safe to refactor replica.Desc() as well. Finally replica.mu.rangeDesc is moved outside mu to replica.rangeDesc to maintain the semantics of replica.mu
Reviewed 2 of 2 files at r2, 1 of 1 files at r4. Comments from Reviewable |
In cockroachdb#7871, replica.String() was refactored to use a new atomically readable copy of the RangeDescriptor. replica.Desc() could use this as well (so as to not lock replica.mu), but this change was conservatively deferred. However, with the issue of replica.Desc() acquiring locks being raised in cockroachdb#7888, and after discussion with @bdarnell, it should be safe to refactor replica.Desc() as well. Finally replica.mu.rangeDesc is moved outside mu to replica.rangeDesc to maintain the semantics of replica.mu
In cockroachdb#7871, replica.String() was refactored to use a new atomically readable copy of the RangeDescriptor. replica.Desc() could use this as well (so as to not lock replica.mu), but this change was conservatively deferred. However, with the issue of replica.Desc() acquiring locks being raised in cockroachdb#7888, and after discussion with @bdarnell, it should be safe to refactor replica.Desc() as well. Finally replica.mu.rangeDesc is moved outside mu to replica.rangeDesc to maintain the semantics of replica.mu
Fixes #7852.
This change is