Add a way to run callbacks after a transaction commits
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 38/100
Hướng nghiên cứu
Start with opsqueue/src/db/mod.rs, where Connection::transaction() is defined, and read the linked discussion in issues #182 and #193 for context. The issue proposes storing callbacks on transactions, running them after a successful outermost commit, and propagating them from nested transactions. Done means callbacks run only after commit and nested transactions pass them upward; the issue leaves key design details open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Related: https://github.com/channable/opsqueue/issues/182#issuecomment-5698854050, https://github.com/channable/opsqueue/issues/193
We currently have three things that need to happen after a transaction commits:
- Prometheus metrics accounting.
- Notifying via
notify_on_insert. - Notifying via
submission_status_changed(when https://github.com/channable/opsqueue/pull/187 lands).
Ideally we would like to define these actions close to where they most sense on a semantic level (e.g. within insert_submission). However, once transactions come into play this becomes problematic, because these side-effects should only be executed if and when the transaction commits. Since the callee doesn't control, nor has insight in, if and when that commit would happen we have no choice but to defer that execution to the caller. We currently either ignore the problem (for Prometheus metrics), or handle the defer manually (e.g. by returning a bool, and making the caller check that after commit). Both are not ideal.
To remedy this I propose we offer users of opsqueue::db::Connection::transaction() something like the following API:
conn.transaction(move |mut tx| { async move {
...
// Register a callback to run on commit.
tx.on_commit(|| notify_on_insert.notify());
...
} .boxed()}).await?;
To implement that we would have to:
- Store a list of
on_commitcallbacks somewhere on the transaction (TBD where exactly). - Within
opsqueue::db::Connection::transaction()we check if the transaction committed. If so, and we are not in a nested transaction we execute all the callbacks. If we are in a nested transaction we propagate the callbacks upwards.
- Ngôn ngữ chính
- Rust
- Star
- 97
- Fork
- 2
- Merge trung bình
- 1 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của channable/opsqueue
-
Reserver does not need to be genericCó thể đã có người làm @jerbaroo đã nhận 13 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
channable/opsqueue#195 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Make `submissions_canceled` and `add_chunks_done_to_submissions_failed` migrations bidirectionalĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
channable/opsqueue#193 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của channable/opsqueue
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
priority middle
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
KATO-Hiro/AtCoderClans#12940 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
o8 next debug build aborts on Glass to Dark appearance switch (nil identifier messaged before check)Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
hurttlocker/o8#5112 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 1 ngày