Auto-commit in the processing thread?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 18/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- kafka, python
- Lĩnh vực
- distributed-systems
Hướng nghiên cứu
The commit timer and the Consumer docstring that promises a background commit thread are in faust/transport/consumer.py, around line 34. Reproduce with a stream agent that calls time.sleep(10) per message and check when the commit timer fires relative to the processing loop. Done means commits keep their interval while the handler blocks, and a test covers it. The thread has no maintainer decision or assignee, so confirm the intended design before changing anything.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Checklist
- I have included information about relevant versions
- I have verified that the issue persists when using the
masterbranch of Faust.
Steps to reproduce
I have created a simple function which blocks for 10s for each message. I run this using the vscode debugger.
import faust
import time
app = faust.App("test", broker="localhost:9093")
topic = app.topic("new-topic", value_type=str)
@app.agent(topic)
async def processor(stream):
async for message in stream:
time.sleep(10)
if __name__ == "__main__":
app.main()
Expected behavior
Commits to occur in the background thread, not the processing thread.
Documentation states auto-commit commits should occur in a background thread:
https://faust-streaming.github.io/faust/userguide/streams.html#message-life-cycle
Also seen in faust/transport/consumer.py:34:
+ The Consumer has a background thread that periodically commits the
offset.
Actual behavior
I am seeing commits occur in the main processing thread.
Blocking processor calls cause the auto-commit timer to lose its place leading to infrequent commits. In this example, a commit only occurs after 3 messages have been processed. One way to work around this issue is by wrapping the blocking function in a thread executor:
@app.agent(topic)
async def processor(stream):
async for message in stream:
loop = asyncio.get_event_loop()
print("going to sleep")
await loop.run_in_executor(None, time.sleep, 10)
If the commit happened in a different thread, like the consumer heartbeat does, this would not be an issue.
Full traceback
[2023-03-23 12:44:39,232] [65292] [INFO] Timer Monitor.sampler woke up too late, with a drift of +19.581969500000014 runtime=0.00015591600003972417 sleeptime=20.581969500000014
[2023-03-23 12:44:39,239] [65292] [INFO] Timer Recovery.stats woke up too late, with a drift of +16.54871479099984 runtime=4.708400047093164e-05 sleeptime=21.54871479099984
[2023-03-23 12:44:49,253] [65292] [INFO] Timer commit woke up too late, with a drift of +18.804260166999665 runtime=10.017661875000158 sleeptime=21.604260166999666
[2023-03-23 12:44:49,255] [65292] [WARNING] Timer commit is overlapping (interval=2.8 runtime=10.017661875000158)
Versions
- Python version: 3.10
- Faust version: 0.9.5
- Operating system: macOS 13.1 (22C65)
- Kafka version: 2.8.1
- RocksDB version (if applicable)
- Ngôn ngữ chính
- Python
- Star
- 1.9k
- Fork
- 205
- Merge trung bình
- 2 giờ 2 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọ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 faust-streaming/faust
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
faust-streaming/faust#804 ·
-
scripts/install script forces use of ./venv virtualenv, impossible to use with virtualenvwrapperĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
faust-streaming/faust#28 · 1 bình luận ·
-
[BUG] SASL PLAINTEXT producer initialization fails : missing sasl_plain_username/passwordCó thể đã có người làm @wbarnha đã nhận 56 ngày trước. Đang mở
faust-streaming/faust#794 · 2 bình luận · 1 reaction · 2 người được giao ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
faust-streaming/faust#670 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
faust-streaming/faust#666 ·
Tất cả issue của faust-streaming/faust
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Maintainer] task area:visualizer
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
RailtownAI/railtracks#1824 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
apache/datafusion#27688 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
mloda-ai/mloda-registry#1664 ·
Maintainer thường phản hồi trong vòng 1 ngày