Repository navigation
fix: cluster node getting stuck and cluster left running in degraded mode - #4447
Conversation
|
Warning Rate limit exceeded@atzoum has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 5 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📥 CommitsReviewing files that changed from the base of the PR and between 91203a1906672e80ba4cc42a41a1449880335d9d and 915d0bb. 📒 Files selected for processing (5)
Summary by CodeRabbit
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe updates refactor cluster management by introducing a Changes
Sequence Diagram(s)sequenceDiagram
participant Main as Main Process
participant ClusterManager
participant Worker
participant MetricsServer
participant RedisClient
Main->>ClusterManager: Initialize with config (worker count, timeouts, etc.)
ClusterManager->>Worker: Fork worker(s)
Worker->>MetricsServer: Start (if Prometheus enabled)
Worker->>AppServer: Start application server
Note over ClusterManager, Worker: ClusterManager monitors workers
alt Graceful Shutdown Triggered
ClusterManager->>Worker: Invoke workerShutdownFn
Worker->>AppServer: Close server
Worker->>MetricsServer: Shutdown metrics client
Worker->>RedisClient: Disconnect (if client exists)
Worker-->>ClusterManager: Signal shutdown complete
end
alt Stuck Worker Detected
ClusterManager->>Worker: Kill and respawn (up to max limit)
end
Suggested reviewers
Suggestions for improvement:
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
Documentation and Community
|
|
Allure Test reports for this run are available at:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4447 +/- ##
===========================================
+ Coverage 91.18% 91.22% +0.03%
===========================================
Files 638 639 +1
Lines 33532 33588 +56
Branches 7919 7931 +12
===========================================
+ Hits 30577 30640 +63
+ Misses 2716 2681 -35
- Partials 239 267 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
0a171e5 to
2c7b914
Compare
|
Allure Test reports for this run are available at:
|
2c7b914 to
c7aa203
Compare
|
Allure Test reports for this run are available at:
|
c7aa203 to
7b01629
Compare
|
Allure Test reports for this run are available at:
|
7b01629 to
1dcf5ab
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between b8aeabb and 1dcf5abad1e20670c904dc694f8550e5b0c22a07.
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackage.jsonis excluded by!**/*.json
📒 Files selected for processing (4)
src/index.ts(2 hunks)src/util/cluster.js(1 hunks)src/util/cluster.test.ts(1 hunks)src/util/redis/redisConnector.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).
**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
src/util/redis/redisConnector.jssrc/util/cluster.js
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
src/util/redis/redisConnector.js (1)
129-134: Good defensive programming practice!The added null check prevents potential runtime errors during shutdown when the Redis client might not be initialized. This is particularly important in the context of the cluster management refactor where worker shutdown can occur at various stages of the application lifecycle.
src/index.ts (1)
69-73: Correct removal of SIGSEGV from graceful shutdown signalsRemoving SIGSEGV from the graceful shutdown signals is the right approach. When a segmentation fault occurs, the process is already in an unreliable state, and attempting graceful shutdown can lead to hangs and stuck workers. It's better to let the process crash immediately and rely on the cluster manager to restart it.
Also applies to: 86-91
src/util/cluster.test.ts (1)
40-45: Well-structured unit test for respawn limit logicThe test effectively verifies that the respawn function correctly enforces the maximum respawn limit by returning true for the first call and false for subsequent calls.
src/util/cluster.js (3)
8-30: Well-structured worker shutdown handlerThe implementation properly sequences the shutdown steps: HTTP server → metrics client → Redis client. The 30-second timeout for graceful HTTP shutdown aligns with the overall cluster shutdown timeout pattern.
32-50: Clean implementation of respawn limit logicExcellent use of closure pattern to maintain respawn counter state. The function generator approach provides a clean API for the ClusterManager while encapsulating the respawn tracking logic.
66-89: Robust configuration with sensible defaultsThe environment variable parsing is well-implemented with appropriate defaults and clear documentation. The configuration parameters comprehensively address the cluster management requirements outlined in the PR objectives.
|
Allure Test reports for this run are available at:
|
9d7c791 to
91203a1
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
.github/scripts/startServer.sh (2)
24-36: Graceful shutdown should wait on the childAfter sending SIGINT you loop until
/healthfails, but neverwaiton the PID. Usewaitto avoid leaving a zombie and to propagate the exit code.-kill -SIGINT $NODE_PID +kill -SIGINT "$NODE_PID" +wait "$NODE_PID" 2>/dev/null || trueOptionally drop the second curl-polling loop and rely solely on
wait.
38-39: Missing trap for early exitsIf the script itself is terminated (e.g., CI timeout) the child keeps running. Add a trap so the child is always cleaned up:
trap 'kill -SIGINT "$NODE_PID" 2>/dev/null || true' EXIT.github/workflows/verify-server-start.yml (2)
29-32: Trailing spaces – YAML lint fails pipelineLines 29, 34 and 39 contain stray spaces flagged by yamllint. Remove them to keep the workflow green.
- - name: Install Dependencies␠ + - name: Install Dependencies ... - run: npm run build␠ + run: npm run build
40-47: Parameter duplication – use a reusable matrixThe two nearly-identical steps differ only in env vars. Consider a job / matrix strategy to avoid duplication and make it easy to add more scenarios.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 9d7c79146499f0d499b2b72c1a88520c03a71a83 and 91203a1906672e80ba4cc42a41a1449880335d9d.
📒 Files selected for processing (3)
.github/scripts/startServer.sh(1 hunks).github/workflows/verify-server-start.yml(1 hunks)src/index.ts(3 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/index.ts
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/verify-server-start.yml
[error] 29-29: trailing spaces
(trailing-spaces)
[error] 34-34: trailing spaces
(trailing-spaces)
[error] 39-39: trailing spaces
(trailing-spaces)
🪛 Shellcheck (0.10.0)
.github/scripts/startServer.sh
[warning] 30-30: i appears unused. Verify use (or export if used externally).
(SC2034)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: Code Coverage
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
.github/scripts/startServer.sh (2)
7-16: Unused loop counter & missing strict mode
iis never referenced – shellcheck rightly warns (SC2034).
Also addset -euo pipefailto abort fast on any error and catch unset vars.+# Exit on error, unset vars, or pipe failure +set -euo pipefail ... -for i in $(seq 1 $timeout); do +for _ in $(seq 1 "$timeout"); do[ suggest_essential_refactor ]
18-22: Race condition & brittlekillIf the node process dies before this point,
kill $NODE_PIDwill exit non-zero and mask the real failure. Add|| true, and usewaitto collect exit status.- kill $NODE_PID + kill "$NODE_PID" 2>/dev/null || true + wait "$NODE_PID" 2>/dev/null || true[ suggest_essential_refactor ]
91203a1 to
2a74cd2
Compare
2a74cd2 to
915d0bb
Compare
|
Allure Test reports for this run are available at:
|
|




Description
Using
ClusterManagerinrudder-transformer:The previous cluster management logic had several flaws that caused multiple issues:
SIGSEGVsignals. However, when a process receivesSIGSEGV, it is already in an unreliable state. This often led to the worker process hanging indefinitely and consuming 100% of the cpu core.process.exit(0), which could leave the process hanging without fully shutting down.resolves PIPE-2194
resolves PIPE-2193