enable SqlOrchestrationService.PurgeInstanceStateAsync to delete more than 1000 instances#308
Conversation
… than 1000 instances
cgillum
left a comment
There was a problem hiding this comment.
Thank you for this PR! One concern I have is that the list of instances to be purged could grow extremely large, in which case this transaction may never be able to succeed due to memory constraints on the database. Should we consider a design where we keep the original implementation (which includes the 1000 PageSize limit) but run it in a loop so that we purge in batches of 1000, thus capping the maximum size of the database transaction?
…ing to keep smaller SQL transactions when purging instances by filter
|
Sounds good. I was initially apprehensive about iterative approach, but in the case of extremely large pool of instances to be purged I'd agree that it'll perform better. |
|
I just now triggered the CI to validate the changes. |
Supposed to fix #297.
Summary of changes
PurgeInstanceStateByFilterstored procedure (logic.sql): Accepts@CreatedTimeFrom,@CreatedTimeTo, and@RuntimeStatusFilterparameters, selects all matching instance IDs server-side, and delegates deletion to the existingPurgeInstanceStateByIDsproc. This follows the same pattern as the existingPurgeInstanceStateByTimeprocedure.PurgeInstanceStateAsync(PurgeInstanceFilter)(SqlOrchestrationService.cs): Replaced the two-step query-then-delete approach (limited to 1000) with a single call to the new stored procedure, removing the artificial limit entirely.DataRetentionTests.cs): AddedPurgesMoreThanOneThousandInstancestest that creates 1100 completed orchestrations and verifies all are purged in a singlePurgeInstanceStateAsynccall.