Skip to content

Commit b0bd646

Browse files
PettitWesleysingholt
authored andcommitted
engine: force flush on shutdown to create tasks for pending chunks
Signed-off-by: Wesley Pettit <[email protected]>
1 parent f2f11c6 commit b0bd646

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/flb_engine.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ int flb_engine_start(struct flb_config *config)
698698
struct flb_sched *sched;
699699
struct flb_net_dns dns_ctx;
700700
struct flb_notification *notification;
701+
int exiting = FLB_FALSE;
701702

702703
/* Initialize the networking layer */
703704
flb_net_lib_init();
@@ -1050,22 +1051,30 @@ int flb_engine_start(struct flb_config *config)
10501051
flb_task_running_print(config);
10511052
}
10521053
if ((mem_chunks + fs_chunks) > 0) {
1053-
flb_info("[engine] Pending chunk count: memory=%d, filesystem=%d",
1054-
mem_chunks, fs_chunks);
1054+
flb_info("[engine] pending chunk count: memory=%d, filesystem=%d; grace_timer=%d",
1055+
mem_chunks, fs_chunks, config->grace_count);
10551056
}
1057+
1058+
/* Create new tasks for pending chunks */
1059+
flb_engine_flush(config, NULL);
10561060
if (config->grace_count < config->grace_input) {
1057-
flb_engine_exit(config);
1061+
if (exiting == FLB_FALSE) {
1062+
flb_engine_exit(config);
1063+
exiting = FLB_TRUE;
1064+
}
10581065
} else {
1059-
flb_engine_stop_ingestion(config);
1066+
if (config->is_ingestion_active == FLB_TRUE) {
1067+
flb_engine_stop_ingestion(config);
1068+
}
10601069
}
10611070
}
10621071
else {
10631072
if (tasks > 0) {
10641073
flb_task_running_print(config);
10651074
}
10661075
if ((mem_chunks + fs_chunks) > 0) {
1067-
flb_info("[engine] Pending chunk count: memory=%d, filesystem=%d",
1068-
mem_chunks, fs_chunks);
1076+
flb_info("[engine] pending chunk count: memory=%d, filesystem=%d; grace_timer=%d",
1077+
mem_chunks, fs_chunks, config->grace_count);
10691078
}
10701079
flb_info("[engine] service has stopped (%i pending tasks)",
10711080
tasks);

0 commit comments

Comments
 (0)