-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
fix: release concurrency system only consumes tokens when releasings are executed successfully #1883
Conversation
…are executed successfully
|
WalkthroughThis pull request updates the debugging configuration and modifies the concurrency handling in the RunEngine. The changes include updating the test command in the VSCode launch configuration, altering asynchronous functions to return explicit boolean results, and adjusting the executor behavior for the token bucket queue. Additionally, new tests have been added to verify that tokens are correctly managed when the executor returns false. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant RunEngine
participant ReleaseConcurrencySystem
participant TokenBucketQueue
Caller->>RunEngine: Initiate concurrency release
RunEngine->>ReleaseConcurrencySystem: executeReleaseConcurrencyForSnapshot(snapshotId)
ReleaseConcurrencySystem->>TokenBucketQueue: Invoke executor function
TokenBucketQueue-->>ReleaseConcurrencySystem: Return Boolean result
ReleaseConcurrencySystem-->>RunEngine: Pass result (true/false)
RunEngine-->>Caller: Deliver execution outcome
Suggested reviewers
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
internal-packages/run-engine/src/engine/releaseConcurrencyTokenBucketQueue.ts (3)
127-127
: Logging at info level may be verbose.
Switching from debug to info could cause log noise if concurrency is high. Evaluate whether debug would be more appropriate for frequent events.- this.logger.info("Consumed token in attemptToRelease", { + this.logger.debug("Consumed token in attemptToRelease", {
291-291
: Elevating log level to info.
Logging executor calls at info may be desired for auditing, but be mindful of excessive log volume.- this.logger.info("Calling executor for release", { releaseQueueDescriptor, releaserId }); + this.logger.debug("Calling executor for release", { releaseQueueDescriptor, releaserId });
434-563
: NewgetQueueMetrics
method implementation.
This scanning approach is functional and provides thorough metrics collection. However, scanning large sets of queues may impact performance.Consider implementing batching or caching strategies if a significant number of queues exist, or if performance overhead becomes noticeable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.vscode/launch.json
(1 hunks)internal-packages/redis/src/index.ts
(1 hunks)internal-packages/run-engine/src/engine/releaseConcurrencyTokenBucketQueue.ts
(10 hunks)internal-packages/run-engine/src/engine/tests/releaseConcurrencyTokenBucketQueue.test.ts
(6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .vscode/launch.json
🧰 Additional context used
🧬 Code Definitions (2)
internal-packages/run-engine/src/engine/tests/releaseConcurrencyTokenBucketQueue.test.ts (2)
internal-packages/run-engine/src/engine/releaseConcurrencyTokenBucketQueue.ts (5)
ReleaseConcurrencyTokenBucketQueue
(45-787)releaseQueue
(372-374)releaseQueue
(376-378)releaseQueue
(380-382)_
(402-424)internal-packages/run-engine/src/engine/index.ts (1)
runId
(1173-1327)
internal-packages/run-engine/src/engine/releaseConcurrencyTokenBucketQueue.ts (2)
internal-packages/run-engine/src/run-queue/index.ts (1)
T
(756-785)internal-packages/run-engine/src/run-queue/keyProducer.ts (1)
queueKey
(51-77)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: typecheck / typecheck
- GitHub Check: units / 🧪 Unit Tests
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (17)
internal-packages/redis/src/index.ts (1)
11-11
: Increase in test environment retries looks good.
RaisingmaxRetriesPerRequest
to 5 for the Vitest environment helps mitigate transient errors during tests. This should improve reliability without notably impacting overall performance.internal-packages/run-engine/src/engine/tests/releaseConcurrencyTokenBucketQueue.test.ts (6)
23-23
: Executor return alignment is correct.
Returningtrue
here aligns with the new executor contract that expects a boolean.
225-225
: Consistent boolean return on successful execution.
Returningtrue
when the executor finally succeeds is now consistent with the modified interface.
304-304
: Accurate success signal.
Includingreturn true;
ensures the concurrency engine interprets this as a successful run, matching the updated behavior.
425-425
: Proper token handling acknowledgment.
Returningtrue
notifies the system that the run has succeeded and frees the token.
523-577
: Well-structured test for handling 'false' executor return.
This new test comprehensively verifies that afalse
return leads to the token being returned without requeuing. It nicely covers the scenario of immediately making the token available for the next run.
683-715
: Thorough metrics retrieval test.
These lines effectively test the newly introducedgetQueueMetrics
feature by verifying queue lengths and token counts. Coverage appears robust for multiple queues and states.internal-packages/run-engine/src/engine/releaseConcurrencyTokenBucketQueue.ts (10)
2-2
: Tracing import.
ImportingstartSpan
andTracer
allows for improved observability. No concerns here.
5-5
: UsingsetInterval
fromnode:timers/promises
.
This is a modern, clean approach for running tasks on a schedule.
6-6
: Flattening attributes.
Pulling inflattenAttributes
is straightforward; no obvious downsides.
19-22
: Executor now returns a boolean.
Documenting the new return expectations is good practice, clarifying the meaning offalse
vs.true
.
85-85
: Initiating metrics producer by default.
Starting the metrics producer when consumers are enabled is a sensible default.
278-278
: Switching toPromise.allSettled
.
UsingPromise.allSettled
ensures all processing completes even if one operation fails. This is safer for batch operations.
293-297
: Handling successful executor runs explicitly.
The distinction between success (released
) and failure fosters clarity.
298-302
: Properly logging non-releasing outcomes.
Provides transparent feedback when the executor signals it should not consume concurrency.
303-312
: Immediate token return onfalse
.
This logic correctly returns the token without retry, aligning with the new executor contract.
402-424
: Metrics producer routine.
The new routine to periodically log queue metrics is well-structured. Consider potential performance overhead if the queue grows large.
Summary by CodeRabbit
Refactor
Tests