feat(worker): add priority-based consolidation bank scheduling#1813
Merged
Conversation
Add HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY env var to control which banks' consolidation tasks are claimed first when a slot opens. This prevents large banks from being starved by many small banks cycling through limited global consolidation slots. Format: comma-separated bank-pattern:priority pairs (higher = claimed first). Patterns support * wildcards; bare * is the catch-all default. Example: "shadow-*:10,staging-*:5,*:1" Implementation uses tiered claiming — each priority level is a separate index-friendly query, no JOINs or computed ORDER BY. Bank serialization (max 1 concurrent consolidation per bank) is preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1715
HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITYenv var to control which banks' consolidation tasks are claimed first when a slot opensshadow-meetings) from being starved by many small banks cycling through limited global consolidation slotsshadow-*:10,staging-*:5,*:1), usingLIKE ANY/NOT LIKE ALLin PostgreSQL, expanded toOR/ANDclauses for OracleORDER BY created_atDesign decision: priority queues vs per-bank slot reservation
The original issue proposed per-bank slot allocation (
SLOTS_PER_BANK). We chose priority-based scheduling instead because:Test plan
TestParseBankPriority)TestConsolidationBankPriority):created_atshadow-*matchesshadow-meetings,shadow-people)