Skip to content

Commit 3369fee

Browse files
committed
log: fix missing logs for internal events
previously the logs were only flowing for the non-internal events Epic: None Release note (bug fix): Previously, CockroachDB would not log events for TxnRowsRead and TxnRowsWritten guardrail for internal queries into SQL_INTERNAL_PERF channel. The bug has been present since 21.2 and has now been fixed.
1 parent 1ae7b24 commit 3369fee

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

pkg/sql/conn_executor_exec.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,6 +3097,7 @@ func (ex *connExecutor) handleTxnRowsGuardrails(
30973097
if shouldLog {
30983098
commonSQLEventDetails := ex.planner.getCommonSQLEventDetails()
30993099
var event logpb.EventPayload
3100+
var migrator log.StructuredEventMigrator
31003101
if ex.executorType == executorTypeInternal {
31013102
if isRead {
31023103
event = &eventpb.TxnRowsReadLimitInternal{
@@ -3109,6 +3110,9 @@ func (ex *connExecutor) handleTxnRowsGuardrails(
31093110
CommonTxnRowsLimitDetails: commonTxnRowsLimitDetails,
31103111
}
31113112
}
3113+
migrator = log.NewStructuredEventMigrator(func() bool {
3114+
return log.ShouldMigrateEvent(ex.planner.ExecCfg().SV())
3115+
}, logpb.Channel_SQL_INTERNAL_PERF)
31123116
} else {
31133117
if isRead {
31143118
event = &eventpb.TxnRowsReadLimit{
@@ -3121,12 +3125,12 @@ func (ex *connExecutor) handleTxnRowsGuardrails(
31213125
CommonTxnRowsLimitDetails: commonTxnRowsLimitDetails,
31223126
}
31233127
}
3124-
migrator := log.NewStructuredEventMigrator(func() bool {
3128+
migrator = log.NewStructuredEventMigrator(func() bool {
31253129
return log.ShouldMigrateEvent(ex.planner.ExecCfg().SV())
31263130
}, logpb.Channel_SQL_PERF)
3127-
migrator.StructuredEvent(ctx, severity.INFO, event)
3128-
logCounter.Inc(1)
31293131
}
3132+
migrator.StructuredEvent(ctx, severity.INFO, event)
3133+
logCounter.Inc(1)
31303134
}
31313135
if shouldErr {
31323136
if isRead {

pkg/sql/row/helper.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,18 @@ func (rh *RowHelper) CheckRowSize(
470470
rh.metrics.MaxRowSizeLogCount.Inc(1)
471471
}
472472
var event logpb.EventPayload
473+
var migrator log.StructuredEventMigrator
473474
if rh.sd.Internal {
474475
event = &eventpb.LargeRowInternal{CommonLargeRowDetails: details}
476+
migrator = log.NewStructuredEventMigrator(func() bool {
477+
return rh.migrateLargeRowLog
478+
}, logpb.Channel_SQL_INTERNAL_PERF)
475479
} else {
476480
event = &eventpb.LargeRow{CommonLargeRowDetails: details}
481+
migrator = log.NewStructuredEventMigrator(func() bool {
482+
return rh.migrateLargeRowLog
483+
}, logpb.Channel_SQL_PERF)
477484
}
478-
migrator := log.NewStructuredEventMigrator(func() bool {
479-
return rh.migrateLargeRowLog
480-
}, logpb.Channel_SQL_PERF)
481485
migrator.StructuredEvent(ctx, severity.INFO, event)
482486
}
483487
if shouldErr {

0 commit comments

Comments
 (0)