Skip to content

Commit 3a30066

Browse files
committed
rangefeed: remove panic in buffered sender
Epic: none Release note: None
1 parent 3135118 commit 3a30066

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

pkg/kv/kvserver/rangefeed/buffered_sender.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
1515
"github.com/cockroachdb/cockroach/pkg/settings"
1616
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
17-
"github.com/cockroachdb/cockroach/pkg/util/buildutil"
1817
"github.com/cockroachdb/cockroach/pkg/util/retry"
1918
"github.com/cockroachdb/cockroach/pkg/util/stop"
2019
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
@@ -169,11 +168,13 @@ func (bs *BufferedSender) sendBuffered(
169168
// The unbufferedRegistration is the only component that sends non-error
170169
// events to our stream. In response to the error we return when moving to
171170
// stateOverflowing, it should immediately send us an error and mark itself
172-
// as disconnected. As a result, no non-error events are expected.
173-
if ev.Error == nil {
174-
panic("only error events expected after stream has exceeded capacity")
171+
// as disconnected.
172+
//
173+
// The only unfortunate exception is if we get disconnected while flushing
174+
// the catch-up scan buffer.
175+
if ev.Error != nil {
176+
status.state = streamOverflowed
175177
}
176-
status.state = streamOverflowed
177178
case streamOverflowed:
178179
// If we are overflowed, we don't expect any further events because the
179180
// registration should have disconnected in response to the error.
@@ -253,8 +254,6 @@ func (bs *BufferedSender) popFront() (e sharedMuxEvent, success bool) {
253254
if streamFound {
254255
state.queueItems -= 1
255256
bs.queueMu.byStream[event.ev.StreamID] = state
256-
} else {
257-
assumedUnreachable("event found in queue with no state in byStream")
258257
}
259258
}
260259
return event, ok
@@ -305,9 +304,3 @@ func (bs *BufferedSender) waitForEmptyBuffer(ctx context.Context) error {
305304
}
306305
return errors.New("buffered sender failed to send in time")
307306
}
308-
309-
func assumedUnreachable(msg string) {
310-
if buildutil.CrdbTestBuild {
311-
panic(fmt.Sprintf("assumed unreachable code reached: %v", msg))
312-
}
313-
}

0 commit comments

Comments
 (0)