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

オープン
#12,680 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c
領域
backend, testing

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C
スター
8.2k
フォーク
2k
平均マージ
3日 20時間
マージ済み PR(30日)
99

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fluent/fluent-bit のほかの issue

fluent/fluent-bit の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。