Skip to content

Commit 68d7548

Browse files
committed
crosscluster/producer: add debug setting to drop all data
For debugging purposes, it can be useful to run the replication flow but drop rather than emit all data changes. As this loses all data, it is gated behind the unsafe setting interlock. Release note: none. Epic: none.
1 parent bfdd9d4 commit 68d7548

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/crosscluster/producer/event_stream.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,27 @@ func (s *eventStream) maybeFlushBatch(ctx context.Context) error {
366366
return nil
367367
}
368368

369+
var debugSettingDropData = settings.RegisterBoolSetting(
370+
settings.ApplicationLevel,
371+
"physical_replication.producer.unsafe_debug.discard_all_data.enabled",
372+
"discard all row data during cluster replication (for experimental debugging purposes only)",
373+
false,
374+
settings.WithUnsafe,
375+
)
376+
369377
func (s *eventStream) flushBatch(ctx context.Context, reason streampb.FlushReason) error {
370378
if s.seb.size == 0 {
371379
return nil
372380
}
381+
defer s.seb.reset()
382+
383+
if debugSettingDropData.Get(s.execCfg.SV()) {
384+
return nil
385+
}
386+
373387
s.seqNum++
374388
s.debug.Flushed(int64(s.seb.size), reason, s.seqNum)
375389

376-
defer s.seb.reset()
377-
378390
return s.sendFlush(ctx, &streampb.StreamEvent{StreamSeq: s.seqNum, Batch: &s.seb.batch})
379391
}
380392
func (s *eventStream) sendFlush(ctx context.Context, event *streampb.StreamEvent) error {

0 commit comments

Comments
 (0)