Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update matching to emit metric for tasklist backlog size #5448

Merged
merged 2 commits into from
Nov 24, 2023

Conversation

Shaddoll
Copy link
Member

What changed?
Update matching to emit metric for tasklist backlog size

Why?
To provide visibility of tasklist backlog size

How did you test it?
local test

Potential risks

Release notes

Documentation Changes

@@ -191,7 +191,7 @@ func TestDescribeTaskList(t *testing.T) {
require.NotNil(t, taskListStatus)
require.Zero(t, taskListStatus.GetAckLevel())
require.Equal(t, taskCount, taskListStatus.GetReadLevel())
require.Equal(t, taskCount, taskListStatus.GetBacklogCountHint())
require.Equal(t, int64(0), taskListStatus.GetBacklogCountHint())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand. In the test 3 tasks are pushed to the tasklist. Why a backlog is still 0? Or are they immediately processed?
I suggest adding a test that verifies the backlog count/metric emition with tally.TestScope.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original value is in-memory backlog, and the new value is the in-db backlog. The test generates the backlog by changing the in-memory backlog, so after the change, the value is changed.

service/matching/taskReader.go Show resolved Hide resolved
@@ -459,7 +459,7 @@ func (c *taskListManagerImpl) DescribeTaskList(includeTaskListStatus bool) *type
response.TaskListStatus = &types.TaskListStatus{
ReadLevel: c.taskAckManager.GetReadLevel(),
AckLevel: c.taskAckManager.GetAckLevel(),
BacklogCountHint: c.taskAckManager.GetBacklogCount(),
BacklogCountHint: c.db.BacklogCount(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who is calling DescribeTaskList() and how will this BacklogCountHint be used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's called by cadence-web and cadence-cli. And the value is only used to tell if there is backlog.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on your other comment this value will be potentially 5m old. If that's sufficient for now the change makes sense. otherwise we can maybe keep an accurate in-memory counter as tasks are added/removed from a tasklist in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, after some thought, I decide to not use the cached value. The api is not called frequently, and I don't think it will increase db load a lot.

service/matching/taskReader.go Show resolved Hide resolved
@@ -459,7 +459,7 @@ func (c *taskListManagerImpl) DescribeTaskList(includeTaskListStatus bool) *type
response.TaskListStatus = &types.TaskListStatus{
ReadLevel: c.taskAckManager.GetReadLevel(),
AckLevel: c.taskAckManager.GetAckLevel(),
BacklogCountHint: c.taskAckManager.GetBacklogCount(),
BacklogCountHint: c.db.BacklogCount(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on your other comment this value will be potentially 5m old. If that's sufficient for now the change makes sense. otherwise we can maybe keep an accurate in-memory counter as tasks are added/removed from a tasklist in the future.

@Shaddoll Shaddoll merged commit c48593b into cadence-workflow:master Nov 24, 2023
16 checks passed
@Shaddoll Shaddoll deleted the tasklist-size branch November 24, 2023 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants