diff --git a/go/streamlog/streamlog.go b/go/streamlog/streamlog.go index 721c0d28dc3..ef34c595079 100644 --- a/go/streamlog/streamlog.go +++ b/go/streamlog/streamlog.go @@ -42,11 +42,13 @@ var ( deliveredCount = stats.NewCountersWithMultiLabels( "StreamlogDelivered", "Stream log delivered", - []string{"Log", "Subscriber"}) + []string{"Log", "Subscriber"}, + ) deliveryDropCount = stats.NewCountersWithMultiLabels( "StreamlogDeliveryDroppedMessages", "Dropped messages by streamlog delivery", - []string{"Log", "Subscriber"}) + []string{"Log", "Subscriber"}, + ) ) const ( @@ -290,6 +292,13 @@ func (qlConfig QueryLogConfig) shouldSampleQuery() bool { // It also returns an EmitReason which is a comma-separated-string to indicate all the conditions triggered for log emit. // If both TimeThreshold and FilterTag condition are met, EmitReason will be time,filtertag func (qlConfig QueryLogConfig) ShouldEmitLog(sql string, rowsAffected, rowsReturned uint64, totalTime time.Duration, hasError bool) (bool, string) { + // MySQL 8.4+ clients send "select $$" at connection time to probe dollar-quote + // syntax support. This is hardcoded client behavior that cannot be disabled; + // suppress it to avoid log noise. + if strings.EqualFold(strings.TrimSpace(sql), "select $$") { + return false, "" + } + var aMatch, allMatches bool var aReason string reasons := []string{} diff --git a/go/streamlog/streamlog_test.go b/go/streamlog/streamlog_test.go index e6e29e204ac..dc14489f07b 100644 --- a/go/streamlog/streamlog_test.go +++ b/go/streamlog/streamlog_test.go @@ -372,6 +372,26 @@ func TestShouldEmitLog(t *testing.T) { ok: true, emitReason: "error", }, + { + sql: "select $$", + ok: false, + emitReason: "", + }, + { + sql: "SELECT $$", + ok: false, + emitReason: "", + }, + { + sql: " select $$ ", + ok: false, + emitReason: "", + }, + { + sql: "select $$ from dual", + ok: true, + emitReason: "", + }, } for _, tt := range tests {