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]>
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
// The MIT License
|
|
//
|
|
// Copyright (c) 2024 Temporal Technologies Inc. All rights reserved.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
// THE SOFTWARE.
|
|
|
|
package tests
|
|
|
|
import (
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
func TestDescribeTaskQueueSuite(t *testing.T) {
|
|
flag.Parse()
|
|
suite.Run(t, new(DescribeTaskQueueSuite))
|
|
}
|