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

Introduce option to checkpoint database on Flush() #1104

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

dawidk-msft
Copy link
Contributor

@dawidk-msft dawidk-msft commented Feb 27, 2023

The way SQLite is initialized (synchronous=NORMAL config) introduces potential issues with durability of changes/updates in some corner cases (power loss, ungraceful process termination/exit, etc).

iOS Outlook logs telemetry in scenarios where if some critical validation/check failed and cannot be handled process will self-terminate. In between logging the event and terminating we call Flush() to avoid lost events. If we checkpoint the DB before returning from the Flush() call app can safely assume no events will be lost. This change introduces an option that enables such behavior.

Alternative solution would be to use the default configuration (with synchronous=FULL) which doesn't have that problem but has overhead of filesystem syncing for each transaction which makes it a bad idea from the perf point of view.

The way SQLite is initialized (synchronous=NORMAL config) introduces potential issues with durability of changes/updates in some corner cases.

iOS Outlook logs telemetry in scenarios where some critical validation/check failed and cannot be handled and process self-terminates. In between logging the event and terminating we call Flush() to avoid lost events. If we checkpoint the DB before returning from the Flush() call app can safely assume no events will be lost. This change introduces an option that enables such behavior.

Alternative solution would be to use the default configuration (with synchronous=FULL) which doesn't have that problem but has overhead of filesystem syncing for each transaction which makes it a bad idea from the perf point of view.
@lalitb
Copy link
Contributor

lalitb commented Feb 28, 2023

While the changes are behind config flag, so should be good in general. Just wanted to check, if you have seen the DB corruption / data loss issue in power failure scenario. The synchronous=NORMAL mode should be in general resilient, with very small window of WAL logs not getting synced to physical disk since last checkpoint. Haven't seen this window getting hit, so just curious.

Copy link
Contributor

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM. The PR was discussed in today's community meeting, and above query was clarified.

@dawidk-msft dawidk-msft merged commit ea0eb89 into main Mar 1, 2023
@dawidk-msft dawidk-msft deleted the dawidk/db-checkpoint-on-flush branch March 1, 2023 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants