filter_multiline: synchronize buffered output-processor appends with the flush timer

Đang mở
#12,680 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
backend, testing

Hướng nghiên cứu

Start with plugins/filter_multiline/ml.c and trace cb_ml_filter(), get_or_create_stream(), flush_callback(), and shutdown alongside the multiline core append and auto-flush paths. Then inspect output worker dispatch in flb_output.c and flb_output.h, and the runtime tests named in the issue. Done means real multi-worker dispatch and timer flushes are covered, records flush correctly, shutdown is safe, classic-filter and input-processor tests pass, and ThreadSanitizer reports no races.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

Track the pre-existing synchronization problem when buffered multiline parser mode runs as an output processor.

As identified in the discussion on PR #12678, output processors execute from output flush helpers on worker threads, while cb_ml_init() initializes the multiline auto-flush timer on the main scheduler. The worker path and timer can therefore access the same multiline state concurrently.

get_or_create_stream() mutates ctx->ml_streams, and flb_ml_append_event() mutates parser group buffers. The timer flush path reads or modifies that state and invokes flush_callback(), which looks up stream metadata through get_by_id().

This can cause data races and inconsistent stream or parser state. This issue tracks the synchronization concern; no runtime crash reproduction is claimed here.

Scope and required changes

  • Establish safe ownership or synchronization for buffered multiline parser state when used as an output processor.
  • Serialize stream creation, lookup, list mutation, and parser appends with timer-driven flushes. Account for concurrent output workers sharing the processor context.
  • Review flush callbacks, emitter interactions, and shutdown/destruction under the same ownership model. Avoid deadlocks or callback re-entry problems.
  • Document the threading contract and preserve existing classic-filter and input-processor behavior.
  • Add regression coverage that exercises real output worker dispatch concurrently with timer flushes.

Possible approaches include a shared synchronization mechanism or confining parser operations and timer flushes to one owner thread. The implementation should select and document the appropriate approach.

Affected areas

  • plugins/filter_multiline/ml.c: cb_ml_init(), cb_ml_filter(), get_or_create_stream(), get_by_id(), flush_callback(), and shutdown/destruction.
  • Multiline core auto-flush and append paths.
  • Output processor initialization and output flush helpers (flb_output.c and flb_output.h).
  • tests/runtime/filter_multiline.c and appropriate output-processor runtime coverage.

Acceptance criteria

  • Output-worker appends and timer flushes cannot access shared stream lists or parser buffers without synchronization or single-thread ownership.
  • Tests exercise actual output worker dispatch, including multiple workers, while timer flushes occur. Do not use a formatter test hook that bypasses worker dispatch.
  • Tests verify correct multiline concatenation and pending-content flushing without missing or duplicate records.
  • A ThreadSanitizer run of the concurrency regression reports no races in the affected multiline state.
  • Shutdown completes without deadlocks or invalid memory access.
  • Classic-filter and input-processor multiline tests continue to pass.

Relationship to PR #12678

This is separate from idle-stream eviction. PR #12678 disables idle eviction for output processors to avoid adding stream frees to the existing race. Disabling eviction does not serialize existing appends and timer flushes. Keep that safeguard until output-processor stream lifecycle safety is established; enabling eviction is not required by this issue.

Requested by @baizhenyu.

Ngôn ngữ chính
C
Star
8.2k
Fork
2k
Merge trung bình
3 ngày 20 giờ
Pull request đã merge (30 ngày)
99

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fluent/fluent-bit

Tất cả issue của fluent/fluent-bit

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.