Add PostgreSQL checkpoint functionality and update related database operations
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-16 09:21:00 +11:00
parent ff1ec3f4aa
commit 6da2da3e82
8 changed files with 412 additions and 34 deletions

View File

@@ -202,11 +202,13 @@ func (c *CronTask) aggregateDailySummary(ctx context.Context, targetTime time.Ti
}
c.Logger.Debug("Generated daily report", "table", summaryTable, "duration", time.Since(reportStart))
checkpointStart := time.Now()
c.Logger.Debug("Checkpointing sqlite after daily aggregation", "table", summaryTable)
if err := db.CheckpointSQLite(ctx, dbConn); err != nil {
c.Logger.Warn("failed to checkpoint sqlite after daily aggregation", "error", err)
driver := strings.ToLower(dbConn.DriverName())
c.Logger.Debug("Running database checkpoint after daily aggregation", "table", summaryTable, "driver", driver)
action, err := db.CheckpointDatabase(ctx, dbConn)
if err != nil {
c.Logger.Warn("failed to run database checkpoint after daily aggregation", "driver", driver, "action", action, "error", err)
} else {
c.Logger.Debug("Checkpointed sqlite after daily aggregation", "table", summaryTable, "duration", time.Since(checkpointStart))
c.Logger.Debug("Completed database checkpoint after daily aggregation", "table", summaryTable, "driver", driver, "action", action, "duration", time.Since(checkpointStart))
}
c.Logger.Debug("Finished daily inventory aggregation", "summary_table", summaryTable)
@@ -520,11 +522,13 @@ LIMIT 1
}
c.Logger.Debug("Generated daily report", "table", summaryTable, "duration", time.Since(reportStart))
checkpointStart := time.Now()
c.Logger.Debug("Checkpointing sqlite after daily aggregation", "table", summaryTable)
if err := db.CheckpointSQLite(ctx, dbConn); err != nil {
c.Logger.Warn("failed to checkpoint sqlite after daily aggregation (Go path)", "error", err)
driver := strings.ToLower(dbConn.DriverName())
c.Logger.Debug("Running database checkpoint after daily aggregation", "table", summaryTable, "driver", driver)
action, err := db.CheckpointDatabase(ctx, dbConn)
if err != nil {
c.Logger.Warn("failed to run database checkpoint after daily aggregation (Go path)", "driver", driver, "action", action, "error", err)
} else {
c.Logger.Debug("Checkpointed sqlite after daily aggregation", "table", summaryTable, "duration", time.Since(checkpointStart))
c.Logger.Debug("Completed database checkpoint after daily aggregation", "table", summaryTable, "driver", driver, "action", action, "duration", time.Since(checkpointStart))
}
c.Logger.Debug("Finished daily inventory aggregation (Go path)",