cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

server: recover from index out of range panic in MuxRangeFeed Send

Open tbg opened this issue 3 weeks ago • 1 comments

We suspect a data race in rangefeed checkpoint marshaling where a RangeFeedEvent containing a RangeFeedCheckpoint can be modified while being marshaled. This causes panics with "index out of range" errors because marshaling computes the size needed first, then creates a buffer, and the buffer ends up too small when the underlying data changes.

This commit adds panic recovery in lockedMuxStream.Send to catch these specific panics and convert them to errors instead of crashing. Other panics are still re-raised after logging.

This patch backports with relative ease all the way back to 24.1.

Informs: https://github.com/cockroachdb/cockroach/issues/159166 Informs: https://github.com/cockroachdb/cockroach/issues/157882 Informs: https://github.com/cockroachdb/cockroach/issues/138895 Informs: https://github.com/cockroachdb/cockroach/issues/158166 Informs: https://github.com/cockroachlabs/support/issues/3506

Release note: None

tbg avatar Dec 11 '25 12:12 tbg

This change is Reviewable

cockroach-teamcity avatar Dec 11 '25 12:12 cockroach-teamcity