queue-chaos 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- queue_chaos-1.1.0/LICENSE-APACHE +190 -0
- queue_chaos-1.1.0/LICENSE-MIT +21 -0
- queue_chaos-1.1.0/PKG-INFO +251 -0
- queue_chaos-1.1.0/README.md +240 -0
- queue_chaos-1.1.0/chaos.py +772 -0
- queue_chaos-1.1.0/pyproject.toml +22 -0
- queue_chaos-1.1.0/qadvice.py +54 -0
- queue_chaos-1.1.0/qcheck.py +249 -0
- queue_chaos-1.1.0/queue_chaos.egg-info/PKG-INFO +251 -0
- queue_chaos-1.1.0/queue_chaos.egg-info/SOURCES.txt +21 -0
- queue_chaos-1.1.0/queue_chaos.egg-info/dependency_links.txt +1 -0
- queue_chaos-1.1.0/queue_chaos.egg-info/entry_points.txt +2 -0
- queue_chaos-1.1.0/queue_chaos.egg-info/top_level.txt +4 -0
- queue_chaos-1.1.0/queue_chaos_presets/__init__.py +0 -0
- queue_chaos-1.1.0/queue_chaos_presets/_common.py +33 -0
- queue_chaos-1.1.0/queue_chaos_presets/celery/adapter +7 -0
- queue_chaos-1.1.0/queue_chaos_presets/celery/adapter.py +64 -0
- queue_chaos-1.1.0/queue_chaos_presets/rq/adapter +5 -0
- queue_chaos-1.1.0/queue_chaos_presets/rq/adapter.py +75 -0
- queue_chaos-1.1.0/queue_chaos_presets/rq/chaosjob.py +18 -0
- queue_chaos-1.1.0/setup.cfg +4 -0
- queue_chaos-1.1.0/tests/test_check.py +153 -0
- queue_chaos-1.1.0/tests/test_report.py +44 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Biplab Das
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Biplab Das
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: queue-chaos
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Fault-injection checker for background job queues (lost, duplicate and concurrent job execution)
|
|
5
|
+
License: MIT OR Apache-2.0
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE-APACHE
|
|
9
|
+
License-File: LICENSE-MIT
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# queue-chaos
|
|
13
|
+
|
|
14
|
+
[](https://github.com/biplabku/queue-chaos/actions/workflows/selftest.yml)
|
|
15
|
+
[](https://pypi.org/project/queue-chaos/)
|
|
16
|
+

|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
Fault-injection checker for background job queues. It runs your queue's real workers against a real broker in
|
|
22
|
+
Docker, breaks things on purpose (kills workers, restarts Redis/Postgres, cuts the network, fills the disk, skews
|
|
23
|
+
the clock...) and then checks every single job: did it run? did it run twice? did two workers run it at the same time?
|
|
24
|
+
|
|
25
|
+
**Test your own Celery or RQ app in one command** (no glue code; it keeps your settings and swaps in a throwaway broker):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install queue-chaos
|
|
29
|
+
queue-chaos check celery --app proj.celery:app --quick
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
In CI it's one step ([action](action.yml), [presets](docs/PRESETS.md)):
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
- uses: biplabku/queue-chaos@v1.1.0
|
|
38
|
+
with: { preset: celery, app: proj.celery:app, quick: "true" }
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For any other queue, write a small adapter (below); 19 are included to copy from.
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
$ queue-chaos --adapter adapters/sidekiq/adapter --backend redis --fault kill \
|
|
45
|
+
--rate 20 --faults 3 --fault-window 30 --drain 150 --stuck-ms 10000 --seed 3
|
|
46
|
+
redis-kill-seed3-1795924693: jobs=600 faults=3 completed_once=589 lost=11 dup_complete=0 dup_unexplained=0 concurrent=0 lease_overlap=0 redelivered=0 worker_exits=0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
That one says Sidekiq (OSS, BasicFetch) lost 11 of 600 jobs when 3 workers were SIGKILLed, which is
|
|
50
|
+
[documented](https://github.com/sidekiq/sidekiq/wiki/Reliability) behaviour. Other runs found real bugs; see
|
|
51
|
+
[upstream](#bugs-found-so-far).
|
|
52
|
+
|
|
53
|
+
## How it works
|
|
54
|
+
|
|
55
|
+
```mermaid
|
|
56
|
+
flowchart LR
|
|
57
|
+
O["queue-chaos<br/>(orchestrator)"] -- "enqueue 1 600 300" --> A1["adapter<br/>enqueue"]
|
|
58
|
+
O -- "spawn N x work" --> W["adapter workers<br/>(your queue's real worker code)"]
|
|
59
|
+
A1 --> B[("broker in Docker<br/>Redis / Postgres / Mongo / Faktory")]
|
|
60
|
+
W <--> B
|
|
61
|
+
F{{"fault injector<br/>kill · pause · term · restart<br/>partition · disk full · clock · cmdhold"}} -. breaks .-> W
|
|
62
|
+
F -. breaks .-> B
|
|
63
|
+
W -- "START / END lines" --> L["event log<br/>.events.tsv"]
|
|
64
|
+
L --> C["checker"] --> V["verdict<br/>.json + exit code"]
|
|
65
|
+
style O fill:#4f46e5,color:#fff
|
|
66
|
+
style F fill:#dc2626,color:#fff
|
|
67
|
+
style C fill:#059669,color:#fff
|
|
68
|
+
style V fill:#059669,color:#fff
|
|
69
|
+
style B fill:#f59e0b,color:#000
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
An adapter is a small program (any language) that speaks a line protocol: `enqueue` some jobs, or `work` forever
|
|
73
|
+
and print `START`/`END` for each job. queue-chaos never talks to your queue directly, so anything with a
|
|
74
|
+
worker process can be tested.
|
|
75
|
+
|
|
76
|
+
## Quick start
|
|
77
|
+
|
|
78
|
+
Needs Docker and Python 3.8+.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install queue-chaos # gives the queue-chaos command
|
|
82
|
+
git clone https://github.com/biplabku/queue-chaos && cd queue-chaos
|
|
83
|
+
|
|
84
|
+
# set up one adapter (RQ here), then run a baseline and a fault
|
|
85
|
+
python3 -m venv adapters/rq/.venv && adapters/rq/.venv/bin/pip install rq redis
|
|
86
|
+
queue-chaos --adapter adapters/rq/adapter --backend redis --fault none
|
|
87
|
+
queue-chaos --adapter adapters/rq/adapter --backend redis --fault kill --seed 1
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Exit code is `1` if any job was lost or ran concurrently, so it drops into CI as is.
|
|
91
|
+
More recipes: **[docs/EXAMPLES.md](docs/EXAMPLES.md)**. Writing an adapter for your own queue:
|
|
92
|
+
**[docs/QUICKSTART.md](docs/QUICKSTART.md)**.
|
|
93
|
+
|
|
94
|
+
## Test your own app (presets)
|
|
95
|
+
|
|
96
|
+
For Celery and rq you do not have to write an adapter. Point `check` at your app; it runs a no-fault baseline and
|
|
97
|
+
each fault with a few seeds against a throwaway broker container and prints a verdict per fault (about 5 minutes).
|
|
98
|
+
Install queue-chaos in the same environment as your app (Celery or rq and their broker client must be importable).
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
queue-chaos check celery --app myproj.celery:app --quick # 1 seed per fault
|
|
102
|
+
queue-chaos check celery --app myproj.celery:app --broker rabbitmq --faults kill,term,broker-restart --seeds 3
|
|
103
|
+
queue-chaos check celery --app myproj.celery:app --env DJANGO_SETTINGS_MODULE=myproj.settings --pre-import django
|
|
104
|
+
queue-chaos check rq --app jobs:queue --retry 3 --job-timeout 60 --json out.json --junit out.xml
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Your own settings (acks_late, prefetch, visibility_timeout, ...) are kept; only the broker URL is replaced.
|
|
108
|
+
Exit code `1` means a lost, unexplained-duplicate or concurrent job; plain duplicates are reported, not failed.
|
|
109
|
+
Try it on [`examples/celery-app`](examples/celery-app) and [`examples/rq-app`](examples/rq-app).
|
|
110
|
+
Flags and details: **[docs/PRESETS.md](docs/PRESETS.md)**.
|
|
111
|
+
|
|
112
|
+
## Faults
|
|
113
|
+
|
|
114
|
+
| `--fault` | What happens | Useful flags |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `none` | baseline, must report zero problems | |
|
|
117
|
+
| `kill` | SIGKILL a random worker, then restart it | `--fault-every`, `--faults` |
|
|
118
|
+
| `term` | SIGTERM (graceful shutdown) with a deadline | `--grace-s`, `--term-scope group\|main` (whole process group, like systemd; or main process only, like `docker stop`) |
|
|
119
|
+
| `pause` | SIGSTOP a worker longer than its lease, then SIGCONT | `--pause-s`, `--stuck-ms` |
|
|
120
|
+
| `broker-restart` | `docker restart` the broker container | |
|
|
121
|
+
| `partition` | cut workers off from the broker for a while | `--partition-s` |
|
|
122
|
+
| `diskfull` | fill the Postgres data dir (tmpfs) | `--disk-mb`, `--diskfull-s` |
|
|
123
|
+
| `clockskew` / `clockjump` | shift the broker's clock (libfaketime) | `--skew --skew-s` |
|
|
124
|
+
| `cmdhold` | delay chosen Redis commands through a RESP proxy | `--hold 'BRPOP:3000'`, `--discover` |
|
|
125
|
+
| `mix` | random mix of the above, seeded | `--mix kill,pause,broker-restart` |
|
|
126
|
+
|
|
127
|
+
Add `--phase start` or `--phase end` to `kill`, `term` or `pause` to fire each fault on the worker that just printed
|
|
128
|
+
the next `START` (mid-job) or `END` (handler done, ack not written yet) instead of a random worker. That's where
|
|
129
|
+
lost acks and unfinished shutdown writes hide.
|
|
130
|
+
|
|
131
|
+
Poison jobs (a job that crashes its worker every time) are switched on in the adapter with
|
|
132
|
+
`CHAOS_POISON_EVERY=50 CHAOS_POISON=crash`.
|
|
133
|
+
|
|
134
|
+
## What is checked
|
|
135
|
+
|
|
136
|
+
| Result | Meaning | Fails the run? |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `lost` | job never completed | ❌ yes |
|
|
139
|
+
| `concurrent` | two executions overlapped while both workers were alive | ❌ yes |
|
|
140
|
+
| `dup_unexplained` | completed twice and nothing happened to the first worker | ⚠️ investigate (fails the Action) |
|
|
141
|
+
| `dup_complete` | completed more than once | ℹ️ allowed under at-least-once |
|
|
142
|
+
| `lease_overlap` | overlap because a paused worker outlived its lease | ℹ️ inherent to leases |
|
|
143
|
+
| `redelivered` | re-run after its worker was killed | ✅ expected |
|
|
144
|
+
| `lost_by_contract` | with `--contract at-most-once`: started on a worker that was then killed or exited, never completed (the loss the queue documents) | ℹ️ allowed by the contract |
|
|
145
|
+
|
|
146
|
+
Tell the checker your queue's documented guarantee with `--contract at-most-once` (default `at-least-once`).
|
|
147
|
+
Only jobs that **started** on a worker that then died move to `lost_by_contract`; jobs that never started stay `lost`.
|
|
148
|
+
The guarantees used in the study, with the doc quotes, are in [docs/contracts.json](docs/contracts.json).
|
|
149
|
+
|
|
150
|
+
### How duplicates are classified
|
|
151
|
+
|
|
152
|
+
Every completed run of a job is one `START` ... `END` pair in the event log. A job with two or more `END`s is a
|
|
153
|
+
`dup_complete`. Under at-least-once delivery that's allowed, so on its own it never fails a run.
|
|
154
|
+
|
|
155
|
+
A duplicate is **explained** (stays only in `dup_complete`) when, for each pair of consecutive completed runs, at least
|
|
156
|
+
one of these happened between the first run's `START` and the second run's `START`:
|
|
157
|
+
|
|
158
|
+
- the first run's worker was killed, exited or paused (its ack may never have reached the broker);
|
|
159
|
+
- a broker-side event: restart, partition start/end, disk full/free, clock skew/jump;
|
|
160
|
+
- the second run's worker was paused in that window or within one lease (`--stuck-ms`) before it (it ran a stale claim);
|
|
161
|
+
- either run's worker came out of a pause longer than the lease just before that run started.
|
|
162
|
+
|
|
163
|
+
Jobs whose enqueue was retried by the harness (`ENQ_RETRY`) are excluded, since a second copy really exists.
|
|
164
|
+
If none of these applies, the job is also a **`dup_unexplained`**: something ran it twice and the harness can't point
|
|
165
|
+
at a fault. Treat it as a lead and read the timeline (`awk -F'\t' '$2 == <id> || $2 == -1' <tag>.events.tsv`).
|
|
166
|
+
|
|
167
|
+
Known limits: broker events count only at the moment they happen. A job whose two runs both fall inside one
|
|
168
|
+
disk-full window shows as unexplained even though the failed completion write explains it. Overlap uses the same
|
|
169
|
+
rule: a run without `END` or `CANCEL` counts as running until its worker's `KILL`/`EXIT` is logged.
|
|
170
|
+
|
|
171
|
+
`concurrent` vs `lease_overlap`: two runs of a job overlap in time (a run lasts from `START` to `END`, or to its
|
|
172
|
+
worker's kill/exit, or to the end of the run). If one of the workers was paused or partitioned for longer than the
|
|
173
|
+
lease, the overlap is `lease_overlap` (expected for lease-based queues). Otherwise it is `concurrent`, which fails the run.
|
|
174
|
+
|
|
175
|
+
Also reported: `recov_p50_ms` / `recov_max_ms` (time from a worker's death to the next start of its unfinished job),
|
|
176
|
+
`late_starts` (jobs whose first start came more than 30 s after the last fault, i.e. stranded and picked up late),
|
|
177
|
+
and when jobs are lost, the non-empty broker keys where they may be stranded.
|
|
178
|
+
|
|
179
|
+
Each run writes `<out>/<tag>.events.tsv` (raw timeline) and `<out>/<tag>.json` (config + verdict).
|
|
180
|
+
|
|
181
|
+
## Supported queues
|
|
182
|
+
|
|
183
|
+
| Queue | Language | Broker | Adapter |
|
|
184
|
+
|---|---|---|---|
|
|
185
|
+
| Celery 5.4 | Python | Redis | [`adapters/celery`](adapters/celery) |
|
|
186
|
+
| RQ | Python | Redis | [`adapters/rq`](adapters/rq) |
|
|
187
|
+
| Dramatiq | Python | Redis | [`adapters/dramatiq`](adapters/dramatiq) |
|
|
188
|
+
| Huey | Python | Redis | [`adapters/huey`](adapters/huey) |
|
|
189
|
+
| arq | Python | Redis | [`adapters/arq`](adapters/arq) |
|
|
190
|
+
| Sidekiq | Ruby | Redis | [`adapters/sidekiq`](adapters/sidekiq) |
|
|
191
|
+
| Resque | Ruby | Redis | [`adapters/resque`](adapters/resque) |
|
|
192
|
+
| GoodJob | Ruby | Postgres | [`adapters/good_job`](adapters/good_job) |
|
|
193
|
+
| Solid Queue | Ruby | Postgres | [`adapters/solid_queue`](adapters/solid_queue) |
|
|
194
|
+
| BullMQ | Node | Redis | [`adapters/bullmq`](adapters/bullmq) |
|
|
195
|
+
| pg-boss | Node | Postgres | [`adapters/pg-boss`](adapters/pg-boss) |
|
|
196
|
+
| Graphile Worker | Node | Postgres | [`adapters/graphile-worker`](adapters/graphile-worker) |
|
|
197
|
+
| Agenda | Node | MongoDB | [`adapters/agenda`](adapters/agenda) |
|
|
198
|
+
| Asynq | Go | Redis | [`adapters/hibiken-asynq`](adapters/hibiken-asynq) |
|
|
199
|
+
| River | Go | Postgres | [`adapters/river`](adapters/river) |
|
|
200
|
+
| Faktory | Go client | Faktory | [`adapters/faktory`](adapters/faktory) |
|
|
201
|
+
| Oban | Elixir | Postgres | [`adapters/oban`](adapters/oban) |
|
|
202
|
+
| apalis | Rust | Redis, Postgres | [`adapters/apalis`](adapters/apalis) |
|
|
203
|
+
| asyncq | Rust | Redis, Postgres | [`adapters/asyncq`](adapters/asyncq) |
|
|
204
|
+
|
|
205
|
+
Setup per language is in [docs/EXAMPLES.md](docs/EXAMPLES.md#setting-up-the-bundled-adapters).
|
|
206
|
+
What each of these does under each fault: **[docs/GUARANTEES.md](docs/GUARANTEES.md)**.
|
|
207
|
+
|
|
208
|
+
## Use it in CI
|
|
209
|
+
|
|
210
|
+
```yaml
|
|
211
|
+
- uses: biplabku/queue-chaos@v1.0.0
|
|
212
|
+
with:
|
|
213
|
+
adapter: ./chaos/adapter
|
|
214
|
+
broker: redis
|
|
215
|
+
fault: kill
|
|
216
|
+
seeds: 3
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Full workflow: [examples/workflow.yml](examples/workflow.yml). A matrix over several faults:
|
|
220
|
+
[examples/workflow-matrix.yml](examples/workflow-matrix.yml).
|
|
221
|
+
|
|
222
|
+
## Bugs found so far
|
|
223
|
+
|
|
224
|
+
| Project | Issue | What | Status |
|
|
225
|
+
|---|---|---|---|
|
|
226
|
+
| Sidekiq | [#7129](https://github.com/sidekiq/sidekiq/issues/7129) | job lost on shutdown with `-t` under ~3 s | fixed in [#7130](https://github.com/sidekiq/sidekiq/pull/7130) |
|
|
227
|
+
| kombu (Celery) | [#2831](https://github.com/celery/kombu/pull/2831) | message lost on Redis partition (A/B data for the fix) | merged |
|
|
228
|
+
| Graphile Worker | [#662](https://github.com/graphile/worker/issues/662) | worker exits after a Postgres restart | open |
|
|
229
|
+
| Graphile Worker | [#663](https://github.com/graphile/worker/issues/663) | jobs aborted by graceful shutdown stay locked 4 h | open |
|
|
230
|
+
| Dramatiq | [#925](https://github.com/Bogdanp/dramatiq/issues/925) | messages stranded in a live worker's ack set after a Redis restart | open |
|
|
231
|
+
| Solid Queue | [#842](https://github.com/rails/solid_queue/issues/842) | running jobs released and re-run after a finalize failure (async mode) | open |
|
|
232
|
+
| Agenda | [#1824](https://github.com/agenda/agenda/issues/1824) | job runs twice with default `lockLimit`, no faults needed | open |
|
|
233
|
+
| apalis-redis | [#127](https://github.com/apalis-dev/apalis-redis/issues/127) | worker exits on a short Redis restart | maintainer asked for a reconnect example + guide ([#128](https://github.com/apalis-dev/apalis-redis/pull/128), [website#30](https://github.com/apalis-dev/website/pull/30)), in review |
|
|
234
|
+
| apalis-postgres | [#141](https://github.com/apalis-dev/apalis-postgres/issues/141) (moved from apalis#832) | long task re-run by a second worker while its own worker is still running it (Postgres, defaults) | open |
|
|
235
|
+
|
|
236
|
+
Every claim has the data behind it in [FINDINGS.md](FINDINGS.md) (dated, retracted results kept visible) and a
|
|
237
|
+
repro under [`repros/`](repros). Found a bug with queue-chaos? Open an issue here with the upstream link and I'll add it.
|
|
238
|
+
|
|
239
|
+
## Full study
|
|
240
|
+
|
|
241
|
+
`./run_matrix.sh 10 results` runs every queue with the same settings, then `python3 report.py` prints a
|
|
242
|
+
per-queue table with 95% confidence intervals. Results are stamped with a checker version and never pooled across versions.
|
|
243
|
+
|
|
244
|
+
## How to cite
|
|
245
|
+
|
|
246
|
+
If queue-chaos helped you find a bug or you use it in a paper, please cite it (GitHub's "Cite this repository"
|
|
247
|
+
button, or [`CITATION.cff`](CITATION.cff)).
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
MIT or Apache-2.0, at your option.
|