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

Make synchronous SQLite setting configurable #12082

Open
masih opened this issue Jun 12, 2024 · 5 comments
Open

Make synchronous SQLite setting configurable #12082

masih opened this issue Jun 12, 2024 · 5 comments

Comments

@masih
Copy link
Member

masih commented Jun 12, 2024

The current SQLite configuration in Lotus explicitly sets the synchronous setting to NORMAL.

"PRAGMA synchronous = normal",

"PRAGMA synchronous = normal",

"PRAGMA synchronous = normal",

While this setting provides a balanced trade-off between data safety and performance, it does not cater to all use cases. Specifically, high-traffic APIs, e.g. ethhashlookup, might require the ability to adjust this setting to optimise performance under heavy load conditions.

Make synchronous setting configurable through the application settings, allowing it to be easily adjusted based on specific requirements. The default setting should remain NORMAL to ensure data integrity for the majority of lightweight use cases.

In a case where high throughput is required (i.e. synchronous is set to off) WAL checkpointing can be used to mitigate the risk of potential data loss at the face of ungraceful shutdown (along with some strategic flushing which would need some code changes).

For now:

  • this setting should be user's choice with a sensible default.
  • this is a small change with large quality of life improvement for Lotus users.
@BigLep
Copy link
Member

BigLep commented Jun 18, 2024

2024-06-18 triage note: @rvagg is this getting handled as part of #12098 ?

@rvagg
Copy link
Member

rvagg commented Jun 19, 2024

no, tbh I'm not strongly convinced that this is all that useful

https://sqlite.org/pragma.html#pragma_synchronous

we're using WAL for all 3 databases, and in normal operation, we bypass sync operations on the main database, only synchronizing the WAL

behaviour of "off" with WAL isn't clearly defined by the docs but may mean that WAL checkpoints become unsafe, which just may not be worth it for relatively compact WAL files

@masih
Copy link
Member Author

masih commented Jun 19, 2024

no, tbh I'm not strongly convinced that this is all that useful

https://sqlite.org/pragma.html#pragma_synchronous

we're using WAL for all 3 databases, and in normal operation, we bypass sync operations on the main database, only synchronizing the WAL

behaviour of "off" with WAL isn't clearly defined by the docs but may mean that WAL checkpoints become unsafe, which just may not be worth it for relatively compact WAL files

That makes sense for default behaviour. Does make sense for every client out there?

My sense would be to parameterise it.

@rvagg
Copy link
Member

rvagg commented Jun 19, 2024

Maybe, it could become caveat emptor in the soup of config variables that need documenting and explaining. But my point is that I don't see this as a big enough value-add to bump up as a priority task, maybe a P3 until someone comes asking it—or better yet, comes and contributes this..

@masih
Copy link
Member Author

masih commented Jun 19, 2024

Considering the small size of this task my recommendation would be to run a quick benchmark of eth API throughput with sync off, then prioritise.

Maybe something @snissn can measure?

@rjan90 rjan90 added this to the DX-Streamline milestone Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🐱 Todo
Development

No branches or pull requests

4 participants