Skip to content

Commit

Permalink
fix: disable vacuum at startup for reporting (#5325)
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr authored Dec 2, 2024
1 parent e4cb7f1 commit d8fb8be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 9 additions & 6 deletions enterprise/reporting/error_reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
8 changes: 5 additions & 3 deletions enterprise/reporting/reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d8fb8be

Please sign in to comment.