Timer timing issue
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
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- ruby
- Lĩnh vực
- backend, distributed-systems
Hướng nghiên cứu
Bắt đầu với state_manager.rb và vòng lặp xử lý sự kiện history_window được mô tả trong issue. Tái hiện kịch bản workflow trong đó việc hoàn tất sleep và việc kích hoạt timer đến trong cùng một lô lịch sử, sau đó so sánh hành vi hiện tại với hành vi được trích dẫn của các SDK Java và Rust. Issue vẫn chưa có triển khai được thống nhất hoặc định nghĩa hoàn thành.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
temporal-ruby Timer timing issue
Scenario:
- Timer started (30 minutes)
- Sleep started by workflow code (15 minute)
- Worker goes down
- Sleep ends
- Timer fires.
- Worker comes back up
- Worker receives a history containing the sleep finishing followed by timer firing.
The workflow thus receives two TIMER_FIRED events in its history at once. Now what should happen?
What’s happening in temporal-ruby today
It processes the timers in order. Sleep first, then the other timer. The workflow completes first, and it’s not allowed to do anything after the workflow has completed. Thus, if the timer issues a command, the task will fail with Temporal::WorkflowAlreadyCompletingError.
Attempted solution
My first attempt was to early-out in state_manager.rb
history_window.events.each do |event|
apply_event(event)
break if if workflow_finished?
end
This fixed my problem and is logical; the workflow will execute the same as it would have if the worker had never gone down. But, it will silently drop events.
I asked Maxim what other SDKs do…
Other SDKs’ behaviors
According to Maxim:
Temporal processes new events in batches. One batch per workflow task. It applies all the events before running workflow code. So in case of Java or Go, for example the Futures that correspond to timer will be set to ready before running any workflow threads. This way workflow can check if any of these Futures are ready to decide what to do next.
Signals have similar properties, but they use callbacks in Java and some other SDKs. Temporal SDK schedules callback threads before running workflow threads. This way workflow cannot complete before the callback threads were called.
Then in case of Java SDK it is going to make the main workflow thread eligible to run. But it still will run only after all other threads executed and all other Futures resolved.
Without this functionality you guaranteed to lose signals if they are delivered as callbacks.
Rust core does the same
Java implementation - we can a see that callbacks (timer in this case) have a higher priority than the main thread (which is awoken by the sleep in this case).
What now?
Changing temporal-ruby's behavior is obviously somewhat tricky and would cause version changes if not done in a version-safe way. We might take this fix on but want to work with the community.
- Should we fix this?
- Implementation suggestions for the fix itself?
- Version safety. I'm guessing we should add a configuration that changes this behavior that folks can opt into.
- Ngôn ngữ chính
- Ruby
- Star
- 288
- Fork
- 113
- Merge trung bình
- 10 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 2
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 coinbase/temporal-ruby
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
coinbase/temporal-ruby#361 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
coinbase/temporal-ruby#341 ·
-
Emitting Metrics for Prometheus Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
coinbase/temporal-ruby#328 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
coinbase/temporal-ruby#326 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
coinbase/temporal-ruby#324 · 3 bình luận · 2 reaction ·
Tất cả issue của coinbase/temporal-ruby
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Please Drop ruby 3.2 support Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
googleapis/google-api-ruby-client#28001 · 5 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100