From d8fb8be7a5ace45b6198579283b4f3b77cf71fbd Mon Sep 17 00:00:00 2001 From: Akash Chetty Date: Mon, 2 Dec 2024 16:42:56 +0530 Subject: [PATCH] fix: disable vacuum at startup for reporting (#5325) --- enterprise/reporting/error_reporting.go | 15 +++++++++------ enterprise/reporting/reporting.go | 8 +++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/enterprise/reporting/error_reporting.go b/enterprise/reporting/error_reporting.go index 43b8d93c39..9ffd456e0b 100644 --- a/enterprise/reporting/error_reporting.go +++ b/enterprise/reporting/error_reporting.go @@ -28,6 +28,7 @@ import ( "github.com/rudderlabs/rudder-go-kit/stats/collectors" obskit "github.com/rudderlabs/rudder-observability-kit/go/labels" + migrator "github.com/rudderlabs/rudder-server/services/sql-migrator" "github.com/rudderlabs/rudder-server/utils/httputil" . "github.com/rudderlabs/rudder-server/utils/tx" //nolint:staticcheck @@ -160,12 +161,14 @@ func (edr *ErrorDetailReporter) DatabaseSyncer(c types.SyncerConfig) types.Repor if !edr.config.GetBool("Reporting.errorReporting.syncer.enabled", true) { return func() {} } - if _, err := dbHandle.ExecContext( - context.Background(), - fmt.Sprintf("vacuum full analyze %s", pq.QuoteIdentifier(ErrorDetailReportsTable)), - ); err != nil { - edr.log.Errorn("error full vacuuming", logger.NewStringField("table", ErrorDetailReportsTable), obskit.Error(err)) - panic(err) + if edr.config.GetBool("Reporting.errorReporting.vacuumAtStartup", false) { + if _, err := dbHandle.ExecContext( + context.Background(), + fmt.Sprintf("vacuum full analyze %s", pq.QuoteIdentifier(ErrorDetailReportsTable)), + ); err != nil { + edr.log.Errorn("error full vacuuming", logger.NewStringField("table", ErrorDetailReportsTable), obskit.Error(err)) + panic(err) + } } return func() { diff --git a/enterprise/reporting/reporting.go b/enterprise/reporting/reporting.go index 80048b10d8..88715f474b 100644 --- a/enterprise/reporting/reporting.go +++ b/enterprise/reporting/reporting.go @@ -161,9 +161,11 @@ func (r *DefaultReporter) DatabaseSyncer(c types.SyncerConfig) types.ReportingSy if !config.GetBool("Reporting.syncer.enabled", true) { return func() {} } - if _, err := dbHandle.ExecContext(context.Background(), `vacuum full analyze reports;`); err != nil { - r.log.Errorn(`[ Reporting ]: Error full vacuuming reports table`, logger.NewErrorField(err)) - panic(err) + if config.GetBool("Reporting.syncer.vacuumAtStartup", false) { + if _, err := dbHandle.ExecContext(context.Background(), `vacuum full analyze reports;`); err != nil { + r.log.Errorn(`[ Reporting ]: Error full vacuuming reports table`, logger.NewErrorField(err)) + panic(err) + } } return func() { r.g.Go(func() error {