cockroachdb / cockroachdb/cockroach
changefeedccl: clamp timestamps to avoid protobuf encoding failures
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
[BenchmarkEncoders()](https://github.com/cockroachdb/cockroach/blob/master/pkg/ccl/changefeedccl/encoder_test.go#L924) uses a row generator that can produce TIMESTAMP / TIMESTAMPTZ values outside the valid range for google.protobuf.Timestamp (0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z). This causes types.TimestampProto(...) in datumToProtoValue to return an error, which makes the benchmark fail.
Currently we have introduced a temporary fallback inside datumToProtoValue that detects out-of-range protobuf timestamp errors and encodes those values as strings instead of failing.
This is not production safe as a general approach - in production we want to fail on such data, since it should never occur in a normal operation.
Proposed Long-Term Fix: remove the fallback from datumToProtoValue and handle this problem at the test/generator level. Clamp or filter generated timestamps so they’re always within the protobuf-valid range either on the test end or the encoder end.
Jira issue: CRDB-53514
Contributor guide
Assessment
This issue has not been assessed yet.