mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? <!-- Describe what has changed in this PR --> - This PR aims to enable the metric `approximateBacklogCounter` which shall serve to be an approximation of the number of tasks in the task queue backlog. **Note** - The following commit will not be merged to main: https://github.com/temporalio/temporal/pull/5915 - The main purpose of this commit was to provide an exact count for SQL databases since they don't persist the value of the backlog counter during creation of tasks. Thus, if a TQ were to shut down ungracefully, the backlog counter value read from persistence on restart would not be accurate. This commit added support for running a `Count(*)` query for those scenarios. - However, it was found out that it was not altogether exact. `task_gc` only goes on and deletes tasks from the db if there has been a second's difference between the previous batch's delete. In the case where there hasn't, as was found in some of my test cases, the task_gc will not run. Thus, the `Count(*)` query would return an over-estimate and it would be better to use the in-memory counter in this case. - There are *no* consequences of not including this PR for this project. The counter is meant to be an estimate of the number of tasks in the backlog and will continue to do so. The only difference would be that it would be less accurate for SQL databases than others in certain occasions. ## Why? <!-- Tell your future self why have you made these changes --> So that new and helpful metrics can be used by customers: 1. `ApproximateBacklogCount` ## How did you test it? - Suite of tests brought in by each individual PR - CI tests ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> Documentation has been added in appropriate places. ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) --> No --------- Co-authored-by: ShahabT <[email protected]>