Skip to content

output/flush: Correct EVE flushing logic#15107

Closed
jlucovsky wants to merge 4 commits into
OISF:main-8.0.xfrom
jlucovsky:8400/1
Closed

output/flush: Correct EVE flushing logic#15107
jlucovsky wants to merge 4 commits into
OISF:main-8.0.xfrom
jlucovsky:8400/1

Conversation

@jlucovsky
Copy link
Copy Markdown
Contributor

Backport of changes made for issue 8286 for main-8.0.x backport.

Link to ticket: https://redmine.openinfosecfoundation.org/issues/8400

Describe changes:

Provide values to any of the below to override the defaults.

  • To use a Suricata-Verify or Suricata-Update pull request,
    link to the pull request in the respective _BRANCH variable.
  • Leave unused overrides blank or remove.

SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=

Add flushing logic driven off of the file contexts. This is a simpler
solution that removes the need for logger registration changes.

Overview:
Use the heartbeat-driven thread to periodically flush all registered EVE
contexts via a global flush list.

The global flush list is a mutex-protected TAILQ of LogFileFlushEntry
nodes; each node points to a LogFileCtx. Mutex = log_file_flush_mutex

Periodic flushing performed by a thread according to the
heartbeat.output-flush-interval [1,60]. LogFileFlushAll() is invoked to
initiate flushing of registered LogFileCtx structs; each struct's
fp_mutex is obtained while the flush occurs to synchronize with
LogFileWrite activity.

Interacts with file-rotation via the fp_mutex.

Deadlock prevention: the log_file_flush_mutex must be obtained before
the fp_mutex.

Issue: 8286
(cherry picked from commit a78911f)
Remove packet-based flush logic in favor of simpler solution

Issue: 8286
(cherry picked from commit d0ba1c4)
Remove log flush functions and update registration logic as
context-based flushing doesn't require it.

Issue: 8286
(cherry picked from commit 1923ca1)
Update output flushing description to reflect EVE based approach in
documentation and config template.

Issue: 8286
(cherry picked from commit e7dc0d8)
@jlucovsky jlucovsky requested review from a team, jufajardini and victorjulien as code owners March 26, 2026 11:39
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 22.72727% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.60%. Comparing base (a4aa865) to head (40e4dec).
⚠️ Report is 10 commits behind head on main-8.0.x.

Additional details and impacted files
@@             Coverage Diff             @@
##           main-8.0.x   #15107   +/-   ##
===========================================
  Coverage       83.59%   83.60%           
===========================================
  Files            1011     1011           
  Lines          266822   266748   -74     
===========================================
- Hits           223048   223011   -37     
+ Misses          43774    43737   -37     
Flag Coverage Δ
fuzzcorpus 64.01% <13.63%> (+0.02%) ⬆️
livemode 18.74% <22.72%> (-0.08%) ⬇️
pcap 44.56% <22.72%> (-0.03%) ⬇️
suricata-verify 64.85% <22.72%> (+<0.01%) ⬆️
unittests 58.85% <13.63%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@suricata-qa
Copy link
Copy Markdown

Information: QA ran without warnings.

Pipeline = 30557

@catenacyber
Copy link
Copy Markdown
Contributor

Should there be an upgrade note ? Seems a big functional change to backport...

@victorjulien
Copy link
Copy Markdown
Member

Should there be an upgrade note ? Seems a big functional change to backport...

Agree. Also going to give this a bit of time in main before merging this backport.

@jlucovsky
Copy link
Copy Markdown
Contributor Author

Should there be an upgrade note ? Seems a big functional change to backport...

Agree. Also going to give this a bit of time in main before merging this backport.

Note that there are no behavioral differences with this implementation so I'm not sure what the upgrade notes would contain.

Comment thread src/output.h
ThreadDeinitFunc ThreadDeinit;

PacketLogger PacketLogFunc;
PacketLogger PacketFlushFunc;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a behavioral difference : any plugins that define their own modules will need to be updated.

What do you think @jasonish ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're OK? As long as users use the registration functions, they are not concerned with changes to the size of this structure. Do you see another concern?

Copy link
Copy Markdown
Contributor

@catenacyber catenacyber Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pinged you because you knew better :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Any data structure change in a backport should get careful review.

@jasonish
Copy link
Copy Markdown
Member

jasonish commented Apr 6, 2026

@jlucovsky Can you take a look at examples/plugins/c-custom-loggers and see if the example should be updated to handle flush events?

@jlucovsky
Copy link
Copy Markdown
Contributor Author

Continued in #15241

@jlucovsky jlucovsky closed this Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants