cockroachdb / cockroachdb/cockroach

changefeedccl: clamp timestamps to avoid protobuf encoding failures

Open
#151,890 1 comment 0 reactions 0 assignees View on GitHub
A-cdc C-enhancement T-cdc
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.