-
-
Notifications
You must be signed in to change notification settings - Fork 713
More v1 run engine fixes #1644
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
More v1 run engine fixes #1644
Conversation
…up to 5s to complete
…pikes in queues (like around the hour and half hour marks)
|
WalkthroughThis pull request introduces new configuration options for the MARQS (Message Queue Routing and Queuing System) in the web application. Two new environment variables, Changes
Sequence DiagramsequenceDiagram
participant Env as Environment Config
participant Strategy as FairDequeuingStrategy
participant Queue as Message Queues
Env->>Strategy: Configure reuseSnapshotCount
Env->>Strategy: Configure maximumOrgCount
Strategy->>Queue: Create Initial Queue Snapshot
Strategy->>Strategy: Check Snapshot Reuse Limit
Strategy->>Strategy: Select Top Organizations
Strategy->>Queue: Distribute Queues
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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: 1
🧹 Nitpick comments (3)
apps/webapp/app/v3/marqs/fairDequeuingStrategy.server.ts (2)
47-48
: Consider documenting how these new optional properties are intended to be used.
They look appropriate, but adding clearer doc comments or inline explanations on the usage and defaults (especially formaximumOrgCount
) would help future maintainers.
319-340
: Add or note an expiration mechanism if outdated snapshots pose a risk.
The logic correctly checksreuseCount
againstreuseSnapshotCount
, but stale snapshots could accumulate if the queue changes drastically. As a follow-up, consider time-based validation or periodic clearing to ensure data freshness.apps/webapp/test/fairDequeuingStrategy.test.ts (1)
206-294
: Performance-based test checks risk flakiness on slower machines.
Large multipliers (>10x
speed) can fail intermittently in certain CI environments. Consider adjusting thresholds or using more robust performance testing.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/webapp/app/env.server.ts
(1 hunks)apps/webapp/app/v3/marqs/fairDequeuingStrategy.server.ts
(6 hunks)apps/webapp/app/v3/marqs/index.server.ts
(1 hunks)apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
(0 hunks)apps/webapp/test/fairDequeuingStrategy.test.ts
(2 hunks)
💤 Files with no reviewable changes (1)
- apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: typecheck / typecheck
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: units / 🧪 Unit Tests
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
apps/webapp/app/v3/marqs/fairDequeuingStrategy.server.ts (6)
95-98
: Evaluate potential concurrency risks when using a shared Map in async code.
Although Node.js is single-threaded, high concurrency triggers can cause rapid reads and writes which may lead to race conditions in_reusedSnapshotForConsumer
. Consider adding a lock or verifying that calls will not overlap for the same consumer.
342-342
: No issues to report here.
354-363
: Implementation for maximumOrgCount is clear.
The code flows well. Just ensure that callers handle edge cases whenmaximumOrgCount
is 0 or undefined.
397-401
: Good addition of tracing attributes for org-level concurrency details.
This provides clear observability without cluttering.
434-438
: Parallel environment-level tracing attributes are consistent.
The approach is uniform and helps maintain clarity across both orgs and envs.
451-460
: Snapshot caching logic is consistent with earlier checks.
The same concurrency verification applies here. If usage patterns grow complex, consider adding a short TTL to reduce stale entries.apps/webapp/app/env.server.ts (1)
235-236
: Environment variables look well integrated.
Defining a default of0
forMARQS_REUSE_SNAPSHOT_COUNT
and makingMARQS_MAXIMUM_ORG_COUNT
optional seems consistent with the usage patterns inFairDequeuingStrategyOptions
.apps/webapp/test/fairDequeuingStrategy.test.ts (1)
783-912
: Comprehensive test for maximumOrgCount.
This test thoroughly exercises average-age logic and ensures only top orgs are selected. Logging is handy for debugging.apps/webapp/app/v3/marqs/index.server.ts (1)
1628-1629
: LGTM! Configuration changes enhance queue distribution control.The addition of
reuseSnapshotCount
andmaximumOrgCount
to the shared queue'sFairDequeuingStrategy
configuration provides more granular control over queue distribution and performance optimization.Let's verify the environment variables are properly defined:
✅ Verification successful
✓ Configuration changes are properly implemented
The
reuseSnapshotCount
andmaximumOrgCount
properties are correctly:
- Defined as optional parameters in
FairDequeuingStrategyOptions
- Configured through environment variables with proper type validation
- Used consistently in the MARQS implementation
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify environment variable definitions and their usage. # Test: Search for environment variable definitions echo "Searching for environment variable definitions..." rg -A 2 "MARQS_(REUSE_SNAPSHOT_COUNT|MAXIMUM_ORG_COUNT)" # Test: Search for FairDequeuingStrategy options type definition echo "Searching for FairDequeuingStrategy options type..." ast-grep --pattern 'interface $_ { $$$ reuseSnapshotCount?: $_ maximumOrgCount?: $_ $$$ }'Length of output: 1061
Script:
#!/bin/bash # Search for FairDequeuingStrategy type definition with a more flexible pattern echo "Searching for FairDequeuingStrategy type definition..." ast-grep --pattern 'class FairDequeuingStrategy { $$$ }' # Also search for any type definitions containing these properties echo "Searching for type definitions with these properties..." rg -A 5 "(?:interface|type).*\{[^}]*(?:reuseSnapshotCount|maximumOrgCount)"Length of output: 378
Script:
#!/bin/bash # Broader search for FairDequeuingStrategy echo "Searching for FairDequeuingStrategy mentions..." rg -A 5 "FairDequeuingStrategy" # Search for files containing both properties echo "Searching for files with both properties..." rg -l "reuseSnapshotCount.*maximumOrgCount|maximumOrgCount.*reuseSnapshotCount"Length of output: 12832
@trigger.dev/build
trigger.dev
@trigger.dev/react-hooks
@trigger.dev/rsc
@trigger.dev/core
@trigger.dev/sdk
commit: |
Summary by CodeRabbit
Release Notes
New Features
MARQS_REUSE_SNAPSHOT_COUNT
to control snapshot reuseMARQS_MAXIMUM_ORG_COUNT
to limit organization selection in queue processingImprovements
Testing