Skip to content

Commit d894e31

Browse files
committed
Pauses ingestion during retention cleanup
Ensures data ingestion is paused during retention cleanup to prevent conflicts and data corruption. Sets a flag to prevent more data ingestion while partitions are being dropped to avoid race conditions.
1 parent 4f62e3e commit d894e31

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ServiceControl.Audit.Persistence.Sql.Core/Infrastructure/RetentionCleaner.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public abstract class RetentionCleaner(
1515
AuditSqlPersisterSettings settings,
1616
IBodyStoragePersistence bodyPersistence,
1717
IPartitionManager partitionManager,
18-
RetentionMetrics metrics) : BackgroundService
18+
RetentionMetrics metrics,
19+
MinimumRequiredStorageState storageState) : BackgroundService
1920
{
2021
const int HoursAhead = 6;
2122

@@ -82,6 +83,8 @@ async Task Clean(CancellationToken stoppingToken)
8283

8384
foreach (var hour in expiredPartitions)
8485
{
86+
storageState.CanIngestMore = false;
87+
8588
// Delete body storage for this hour first
8689
await bodyPersistence.DeleteBodiesForHour(hour, stoppingToken);
8790

@@ -101,6 +104,7 @@ async Task Clean(CancellationToken stoppingToken)
101104
finally
102105
{
103106
await ReleaseLock(lockConnection, stoppingToken);
107+
storageState.CanIngestMore = true;
104108
}
105109
}
106110

0 commit comments

Comments
 (0)