Skip to content

Commit f8e1525

Browse files
committed
fix
1 parent a040d5f commit f8e1525

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dbos/system_database.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,10 @@ func (s *sysDB) garbageCollectWorkflows(ctx context.Context, input garbageCollec
823823
if err != nil && err != pgx.ErrNoRows {
824824
return fmt.Errorf("failed to query cutoff timestamp by rows threshold: %w", err)
825825
}
826-
// If we found a valid cutoffTimestamp from rows, use it
827-
if err != pgx.ErrNoRows && cutoffTimestamp == nil || rowsBasedCutoff > *cutoffTimestamp {
826+
// If we don't have a provided cutoffTimestamp and found one in the database
827+
// Or if the found cutoffTimestamp is more restrictive (higher timestamp = more recent = less deletion)
828+
// Use the cutoff timestamp found in the database
829+
if rowsBasedCutoff > 0 && cutoffTimestamp == nil || (cutoffTimestamp != nil && rowsBasedCutoff > *cutoffTimestamp) {
828830
cutoffTimestamp = &rowsBasedCutoff
829831
}
830832
}

0 commit comments

Comments
 (0)