Repository navigation
Add state diagram for chunks #194
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: master
Are you sure you want to change the base?
Changes from all commits
a77d7d8
95cdb00
3091d37
c858dbd
2f65027
8f3a59b
b6995eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -341,6 +341,41 @@ Were a consumer to _raise an exception_ or _outright crash_ or _have network pro | |
|
|
||
| In the event of a consumer crash or (ephemeral) network problems, we do not want work to get lost. The opsqueue system takes the 'at least once' approach (rather than the 'at most once' approach). This means that your consumers **must be idempotent**. They have to handle the possibility of (part of a) chunk being re-executed multiple times. | ||
|
|
||
| ## Chunks | ||
|
|
||
| It may be helpful in understanding OpsQueue to see a state machine of a chunk. | ||
| Definitions of each of the states follows below: | ||
|
|
||
| ```mermaid | ||
| stateDiagram | ||
| [*] --> Available: Submission created | ||
| [*] --> Paused: Submission created paused | ||
| Paused --> Available: Submission unpaused | ||
| Available --> Reserved: Consumer reserves chunk | ||
| Reserved --> Completed: Consumer reports success, completion recorded | ||
| Reserved --> Failed: Consumer reports failure, retry limit reached | ||
| Reserved --> Available: Consumer reports failure, retries remain | ||
| Reserved --> Available: Consumer disconnects, reservation released | ||
| Reserved --> Available: Reservation expires | ||
| Reserved --> Available: Completion/failure transaction fails, reservation released | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this the same path as the consumer disconnect path? |
||
| Paused --> Skipped: Submission cancelled | ||
| Available --> Skipped: Submission cancelled or failed | ||
| Reserved --> Skipped: Submission cancelled or failed | ||
|
jerbaroo marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| Note that late (after reservation expired) completion/failure of a chunk is also | ||
| possible, so we would have additional transitions `Available -> Completed` and | ||
| `Available -> Failed`, but kept out of the diagram for simplicity. | ||
|
Comment on lines
+366
to
+368
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could add those paths dotted because those are the edge cases that you need to handle when working on the reserver. |
||
|
|
||
| | State | Pseudo-SQL definition | | ||
| |---------------|---------------------------------------------------------------------------------------| | ||
| | **Paused** | `SELECT * FROM chunks_paused` | | ||
| | **Available** | `SELECT * FROM chunks WHERE opsqueue_is_reserved(submission_id, chunk_index) = FALSE` | | ||
| | **Reserved** | `SELECT * FROM chunks WHERE opsqueue_is_reserved(submission_id, chunk_index) = TRUE` | | ||
| | **Completed** | `SELECT * FROM chunks_completed` | | ||
| | **Failed** | `SELECT * FROM chunks_failed WHERE skipped = FALSE` | | ||
| | **Skipped** | `SELECT * FROM chunks_failed WHERE skipped = TRUE` | | ||
|
|
||
| ## API connections | ||
|
|
||
| Under the hood, the producer and the queue talk with each other using a JSON-REST API over HTTP. Users of opsqueue don't need to think about this, as this is abstracted behind the client library. | ||
|
|
||
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.
In how far are these detected in one path vs being two separate paths?
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.
The consumer disconnect is triggered differently from the reservation expiry, but in both cases reservation removed.
For the consumer disconnect: when
ConsumerConnis dropped then the ownedConsumerState's drop method runs which removes reservations. This was pointed out to me by LLM. Seems like quite hidden/implicit behaviour, not obvious.