Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit fcb4d36

Browse files
committed
Limit logging errors
1 parent 4e03bae commit fcb4d36

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

platform/ingest/processor.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ type (
6868
ingestFieldStatisticsLock sync.Mutex
6969
virtualTableStorage persistence.JSONDatabase
7070
tableResolver table_resolver.TableResolver
71+
72+
ingestErrorLoggerCount atomic.Int64
7173
}
7274
TableMap = util.SyncMap[string, *chLib.Table]
7375
SchemaMap = map[string]interface{} // TODO remove
@@ -883,7 +885,27 @@ func (ip *IngestProcessor) executeStatements(ctx context.Context, queries []stri
883885

884886
err := ip.execute(ctx, q)
885887
if err != nil {
886-
logger.ErrorFull(ctx, "error executing ingest statement", err).Msgf("query: %s", q)
888+
count := ip.ingestErrorLoggerCount.Add(1)
889+
890+
// Limit the number of error logs to avoid flooding the logs.
891+
892+
// logging only first 50 errors, it should be enough for troubleshooting
893+
if count < 50 {
894+
895+
// only first 10 errors will be logged with full query
896+
if count > 5 {
897+
if len(q) > 100 {
898+
q = q[:100] + "..."
899+
}
900+
}
901+
logger.ErrorWithCtx(ctx).Msgf("error executing ingest statement: %s, query: %s", err, q)
902+
} else {
903+
// log every 1000th error, just to keep track of errors
904+
if count%1000 == 0 {
905+
logger.WarnWithCtx(ctx).Msgf("got %d total errors executing ingest statements. last error: %s, last query: %s", count, err, q)
906+
}
907+
}
908+
887909
return err
888910
}
889911
}

0 commit comments

Comments
 (0)