Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add full_drain_mode option to ensure complete data flush over network before shutdown #1395

Merged
merged 5 commits into from
Mar 22, 2024

Conversation

henryzhx8
Copy link
Collaborator

@henryzhx8 henryzhx8 commented Mar 12, 2024

Introducing the full_drain_mode configuration, which when enabled, triggers a comprehensive data flush across the network during the shutdown sequence. This mode is particularly beneficial for environments with sidecar and fat containers where data persistence is not guaranteed post-application exit. By ensuring all data is transmitted prior to shutdown, we prevent potential data loss that could occur with local dumps, making this feature a critical addition for systems that require high data integrity and resilience.

core/common/LogtailCommonFlags.cpp Outdated Show resolved Hide resolved
@@ -2073,7 +2073,7 @@ SendResult Sender::SendToNetSync(sdk::Client* sendClient,
void Sender::SendToNetAsync(LoggroupTimeValue* dataPtr) {
auto& exactlyOnceCpt = dataPtr->mLogGroupContext.mExactlyOnceCheckpoint;

if (IsFlush()) // write local file avoid binary update fail
if (!BOOL_FLAG(sidecar_mode) && Application::GetInstance()->IsExiting()) // write local file avoid binary update fail
Copy link
Collaborator

Choose a reason for hiding this comment

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

如果网络不稳定,发送极慢,会有什么影响?影响最终退出时间?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

常规模式下,一旦开始退出流程,所有缓存队列的数据全部写到本地磁盘,不再通过网络发送,所以网络对退出时间无影响;
新模式下,是强制发完所有数据后退出,如果网络问题导致发不出去,就会一直等着,直到K8s强制kill。这个是迅飞提的要求,发不出去就死等,而不是超时自动退出。

core/common/LogtailCommonFlags.cpp Outdated Show resolved Hide resolved
core/event_handler/EventHandler.cpp Show resolved Hide resolved
if (BOOL_FLAG(sidecar_mode) && Application::GetInstance()->IsExiting()
&& EventDispatcher::GetInstance()->IsAllFileRead()) {
break;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

非sidecar_mode在mInteruptFlag+Application::GetInstance()->IsExiting()的时候也可以break出来?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

之前的设计里是input的循环是不会主动退出的,只会暂停

core/sender/Sender.cpp Outdated Show resolved Hide resolved
@yyuuttaaoo yyuuttaaoo changed the title support flushing out data rather than stopping immediately on app exit feat: add full_drain_mode option to ensure complete data flush over network before shutdown Mar 19, 2024
@yyuuttaaoo yyuuttaaoo added the enhancement Feature enhancement label Mar 19, 2024
@yyuuttaaoo yyuuttaaoo added this to the v2.1 milestone Mar 19, 2024
@yyuuttaaoo yyuuttaaoo merged commit f2c3ade into main Mar 22, 2024
17 of 18 checks passed
@henryzhx8 henryzhx8 deleted the feat/flush branch April 2, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants