Skip to content

Commit 77d61d1

Browse files
engine: send backlog chunks on shutdown
Signed-off-by: Anuj Singh <[email protected]> Co-authored-by: Wesley Pettit <[email protected]>
1 parent c460714 commit 77d61d1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/flb_engine.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,8 @@ int flb_engine_start(struct flb_config *config)
976976

977977
ret = sb_segregate_chunks(config);
978978

979-
if (ret) {
979+
if (ret < 0)
980+
{
980981
flb_error("[engine] could not segregate backlog chunks");
981982
return -2;
982983
}
@@ -1061,6 +1062,18 @@ int flb_engine_start(struct flb_config *config)
10611062
if (ret > 0 && (config->grace_count < config->grace || config->grace == -1)) {
10621063
if (config->grace_count == 1) {
10631064
flb_task_running_print(config);
1065+
/*
1066+
* If storage.backlog.shutdown_flush is enabled, attempt to flush pending
1067+
* filesystem chunks during shutdown. This is particularly useful in scenarios
1068+
* where Fluent Bit cannot restart to ensure buffered data is not lost.
1069+
*/
1070+
if (config->storage_bl_shutdown_flush) {
1071+
ret = sb_segregate_chunks(config);
1072+
if (ret < 0) {
1073+
flb_error("[engine] could not segregate backlog chunks during shutdown");
1074+
return -2;
1075+
}
1076+
}
10641077
}
10651078
if ((mem_chunks + fs_chunks) > 0) {
10661079
flb_info("[engine] pending chunk count: memory=%d, filesystem=%d; grace_timer=%d",

0 commit comments

Comments
 (0)