-
Notifications
You must be signed in to change notification settings - Fork 848
feat: triggers queue mode #7116
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
base: main
Are you sure you want to change the base?
Conversation
Deploying windmill with
|
| Latest commit: |
e74e04b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6884fea8.windmill.pages.dev |
| Branch Preview URL: | https://dieri-triggers-queue-mode.windmill.pages.dev |
|
Claude finished @dieriba's task —— View job Code Review CompleteReviewing PR #7116: "feat: triggers queue mode" Tasks
SummaryThis PR implements a "queue mode" feature for triggers, allowing trigger events to be queued for manual processing rather than executing immediately. The implementation adds an Architecture OverviewCore Mechanism:
Key Components:
Code Quality Assessment✅ Strengths
|
| pub is_flow: bool, | ||
| pub enabled: Option<bool>, | ||
| pub active_mode: Option<bool>, | ||
| pub process_queued_jobs: Option<bool>, |
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.
Unused field: The process_queued_jobs field is defined in BaseTriggerData but appears to be unused throughout the codebase. This could be:
- Dead code that should be removed
- An incomplete feature implementation
- Reserved for future use
Recommendation: Either implement the functionality for this field or remove it to avoid confusion. If it's intended for future use, add a comment explaining its purpose.
| ALTER TABLE email_trigger | ||
| ADD COLUMN active_mode BOOLEAN NOT NULL DEFAULT TRUE; | ||
|
|
||
| CREATE INDEX idx_gcp_trigger_active_mode ON gcp_trigger(workspace_id,path,active_mode); |
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.
Migration Safety - Good Practice: The migration uses NOT NULL DEFAULT TRUE which is excellent for backward compatibility. Existing triggers will automatically be in active mode, preserving current behavior.
Index Design Consideration: The composite indexes include workspace_id, path, active_mode. Consider whether queries will filter by active_mode frequently enough to justify these indexes. If most queries are just by (workspace_id, path), these indexes might be redundant with the existing primary key/unique constraints.
Suggestion: Review query patterns to ensure these indexes provide value. If active_mode filtering is rare, simpler indexes on just (workspace_id, active_mode) might be more appropriate for finding all inactive triggers.
| }; | ||
| use windmill_common::{error, jobs::JobTriggerKind, utils::require_admin}; | ||
|
|
||
| pub async fn resume_suspended_trigger_jobs( |
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.
Security & Authorization - Good: The function correctly requires admin privileges before allowing bulk operations on suspended trigger jobs.
Potential Race Condition: Between checking for suspended jobs and updating them, the job state could change. Consider using a transaction or adding additional safeguards.
Documentation Needed: Add docstring comments explaining:
- What "suspended trigger jobs" means in this context
- The relationship between
active_mode = falseandscheduled_for = 9999-12-31 - When this endpoint should be used vs individual job management
| }); | ||
|
|
||
| let user_db = user_db.unwrap_or_else(|| UserDB::new(db.clone())); | ||
| let scheduled_for = active_mode |
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.
Critical Logic: This is the core implementation of queue mode. When active_mode is false, jobs are scheduled for the far future date (9999-12-31 23:59:59), effectively "suspending" them until manually processed.
Potential Issues:
-
Year 9999 Problem: While unlikely to cause issues in practice, this magic date could cause problems with:
- Time arithmetic/duration calculations
- Reporting and analytics queries
- Database date range constraints
-
Better Alternative: Consider using a dedicated
suspendedboolean field onv2_job_queueinstead of overloadingscheduled_for. This would be more explicit and avoid potential edge cases. -
Missing Null Check: The code uses
active_mode.filter(|active_mode| !*active_mode)which only setsscheduled_forwhenactive_modeisSome(false). Ensure this aligns with the expected behavior whenactive_modeisNone.
| .map_err(|e| e.into_response())?; | ||
|
|
||
| let trigger_info = TriggerMetadata::new(Some(trigger.path.clone()), JobTriggerKind::Http); | ||
| if !trigger.active_mode { |
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.
Logic Inversion: This condition appears inverted. The comment says "If set to false, each incoming event will be suspend job until ran manually", but the code checks if !trigger.active_mode, which means it triggers when active_mode is FALSE.
Clarification Needed:
- Is this intentional double-negative logic?
- Should the variable be named differently to avoid confusion (e.g.,
queue_modeinstead of!active_mode)? - The OpenAPI description at line ~240 of openapi.yaml says "If set to false, each incomming event will be suspend job" which aligns with this logic, but it's confusing.
Recommendation: Consider renaming to make the intent clearer, or add a comment explaining why we check for !active_mode.
backend/windmill-api/openapi.yaml
Outdated
| active_mode: | ||
| type: boolean | ||
| default: true | ||
| description: If set to false, each incomming event will be suspend job until ran manually or set it to true |
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.
Typographical error found: incomming should be incoming. Additionally, consider rephrasing will be suspend job until ran manually or set it to true to improve clarity (e.g., will suspend the job until run manually or reset to true).
| description: If set to false, each incomming event will be suspend job until ran manually or set it to true | |
| description: If set to false, each incoming event will suspend the job until run manually or reset to true |
No description provided.