Skip to content

Sum running and pending task quota in one query - #5703

Open
sethboyles wants to merge 1 commit into
mainfrom
sum-task-quota-in-one-query
Open

sethboyles wants to merge 1 commit into
mainfrom
sum-task-quota-in-one-query

Conversation

@sethboyles

Copy link
Copy Markdown
Member

Org and space memory_used and log_rate_limit_remaining summed RUNNING and PENDING tasks in two separate queries. Under Postgres READ COMMITTED each statement takes a new snapshot, so a task that TaskCreate#submit_task moves from PENDING to RUNNING between the two queries was counted in neither. A concurrent task create could then see less usage than is actually in use and exceed the org or space quota. MySQL REPEATABLE READ keeps one snapshot per transaction and is unaffected.

  • Sum both states in a single query so a task in transition is counted exactly once.
  • Remove the now-unused per-state helpers.

This also caused some flaky tests.

Thanks for contributing to cloud_controller_ng. To speed up the process of reviewing your pull request please provide us with:

  • A short explanation of the proposed change:

  • An explanation of the use cases your change solves

  • Links to any other associated PRs

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

Org and space memory_used and log_rate_limit_remaining summed RUNNING
and PENDING tasks in two separate queries. Under Postgres READ
COMMITTED each statement takes a new snapshot, so a task that
TaskCreate#submit_task moves from PENDING to RUNNING between the two
queries was counted in neither. A concurrent task create could then
see less usage than is actually in use and exceed the org or space
quota. MySQL REPEATABLE READ keeps one snapshot per transaction and is
unaffected.

- Sum both states in a single query so a task in transition is counted
  exactly once.
- Remove the now-unused per-state helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants