Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Merge requests
  • !2363

perf(clean): use ZRANGEBYSCORE to improve performance

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/wanderlog/harry-stop into develop May 27, 2022
  • Overview 13
  • Commits 1
  • Pipelines 0
  • Changes 2

Created by: hsource

Motivation

When running clean on large queues, it can take a long time when tons of entries are within the grace period. The cleanJobsInSet Lua script never reaches the limit and endlessly iterates through items. Since redis scripts are atomic, this can lock up the rest of the server.

Fix

For sorted sets, the timestamp is just the score. As such, if there's a limit, we can just immediately get all the relevant ones using ZRANGEBYSCORE in one iteration that also filters out the timestamps within the grace period.

Testing

Added automated tests

NODE_ENV=test yarn mocha -- 'test/test_queue*' -g "clean completed"
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/wanderlog/harry-stop