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

storage,util/hlc: convert hlc.Timestamp to proto3 #18910

Merged

Conversation

petermattis
Copy link
Collaborator

Convert hlc.Timestamp to proto3 so that a logical component of 0 will
not be encoded on the wire. This is complicated by needing to leave the
"below raft" encoding for MVCCMetadata unchanged. Added LegacyTimestamp
to accomplish this which is convertible to Timestamp but has the legacy
encoding. Changed the MVCCMetadata timestamp fields to use
LegacyTimestamp. Note that the timestamp in MVCCMetadata.Txn (type
TxnMeta) does not need to change because we never encoding an
MVCCMetadata with a non-nil Txn field below raft. Extended the
TrackRaftProtos mechanism to verify that TxnMeta is never encoded blow
raft.

@petermattis petermattis requested review from a team September 29, 2017 14:26
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Convert hlc.Timestamp to proto3 so that a logical component of 0 will
not be encoded on the wire. This is complicated by needing to leave the
"below raft" encoding for MVCCMetadata unchanged. Added LegacyTimestamp
to accomplish this which is convertible to Timestamp but has the legacy
encoding. Changed the MVCCMetadata timestamp fields to use
LegacyTimestamp. Note that the timestamp in MVCCMetadata.Txn (type
TxnMeta) does not need to change because we never encoding an
MVCCMetadata with a non-nil Txn field below raft. Extended the
TrackRaftProtos mechanism to verify that TxnMeta is never encoded blow
raft.
@bdarnell
Copy link
Member

:lgtm:


Reviewed 21 of 21 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful.


pkg/storage/track_raft_protos.go, line 62 at r1 (raw file):

		t := reflect.TypeOf(pb)

		// Special handling for MVCCMetadata: we expect MVCCMetadata to be

I don't understand why this is needed. Shouldn't this be traversed automatically?


Comments from Reviewable

@petermattis
Copy link
Collaborator Author

Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful.


pkg/storage/track_raft_protos.go, line 62 at r1 (raw file):

Previously, bdarnell (Ben Darnell) wrote…

I don't understand why this is needed. Shouldn't this be traversed automatically?

That's what I thought initially, but that's not the way protoutil.Interceptor works. The interceptor is only invoked for the top-level proto.Message passed to prototutil.Marshal.


Comments from Reviewable

@petermattis petermattis merged commit a710e14 into cockroachdb:master Sep 30, 2017
@petermattis petermattis deleted the pmattis/hlc-timestamp-encoding branch September 30, 2017 00:35
petermattis added a commit to petermattis/cockroach that referenced this pull request Oct 2, 2017
The encoding of `storage.Liveness` changed in cockroachdb#18910 which caused node
liveness updates to fail in mixed version clusters due to failed
conditional puts. Because the encoding changed, continued attempts to
update the liveness would never succeed. Changed `Liveness.expiration`
to use the `LegacyTimestamp` type.

Audited the code and the only protos that are used as the expected value
in conditional put operations are `storage.Liveness` and
`roachpb.RangeDescriptor`. Extended TestBelowRaftProtos to verify the
encoding of these protos does not change unexpectedly.

Consistency checks were failing in mixed version clusters because of an
explicit call to marshal an `hlc.Timestamp` in `Replica.sha512`.

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

Successfully merging this pull request may close these issues.

None yet

3 participants