Skip to content

Working with simultaneous actions #68

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

Open
Zhu-jiatong opened this issue Mar 13, 2023 · 2 comments
Open

Working with simultaneous actions #68

Zhu-jiatong opened this issue Mar 13, 2023 · 2 comments

Comments

@Zhu-jiatong
Copy link

I am using this library with a webserver for storing and accessing user data.
In most cases, there will be no issues.

However, when there is a write operation to the database while a read is being performed on it, what will happen?
What about 2 writes at the same time?

I saw that on the sqlite documentation, different threadsafe options are offered both during compile time and runtime.
So, according to this document, I may use Multi-thread mode to allow a database to be used simultaneously by multiple connections.
Alternatively, I may also use Serialized mode to force all operations into sequential order.

I would like to know if the above informatin is valid, and that whether I can use the library safely in such cases. Thank you.

*If any further clarifications are required, please let me know.

@siara-cc
Copy link
Owner

I have not really tried to use the lib concurrently.

As I understand it, esp32 has 2 cores and 1 is dedicated for WiFi communication and only 1 core is available for developer use? Running single thread itself is an overload on ESP32 owing to limited memory and heavy SQLite library. So this lib was not intended for multiple threads. I think using multiple threads on the 1 core with limited amount of memory and heavy SQLite code is going to be an overload unless the threads are doing different things.

@Zhu-jiatong
Copy link
Author

Zhu-jiatong commented May 8, 2023

The scenario I had in mind is when the SQLite database is used for session management:

  • Using a ESP32 as a web server and ESPAsyncWebServer as the library for the server.
  • With each request for a resource on the server, the database has to be read.
  • With each new login, a new session has to be created in the database (write).

In this case, when requests and logins are very frequent, I suspect that there might be near-simultaneous read and write action to the database, which would perhaps corrupt it or fail to complete the actions.

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

No branches or pull requests

2 participants