-
-
Notifications
You must be signed in to change notification settings - Fork 525
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
'Attempt to write a readonly database' error after a hot restart #325
Comments
The issue is about hot restart and deleting the database here. The current workaround is to open the database and close it before deleting it. Maybe deleteDatabase (instead of calling File().delete) should do the proper cleanup but it is not the case neither. Since many are running into this, I guess I should fix deleteDatabase behavior (well that is not really a fix, it is a hotload issue where the db is not closed on hotrestart). I will work on it. |
As of sqflite 1.1.8, the behavior of deleteDatabase has slightly change, for the better hopefully as I don't consider this a breaking change. It now supports Android restart and hot restart in general. If the database was opened previously as a single instance, the database is closed first, then deleted. This means that the trick of opening the database before deletion is no longer needed. |
The bug is still present. I couldn't find where the deleteDatabase() method is |
I face this issue recently, and I don't have delete db functionality. I just cache network responses. and delete the responses weekly. (not the whole db)
|
There is indeed a complex mechanism to handle hot-restart (as the db is not closed on the native side). I'm puzzled by the 'dbmoved' response. @haashem on which platform are you experiencing the issue ? Also can you confirm (and it seems so) that you are never closing the db? Also can you print the content of |
Thanks for quick reply, Yes, I confirm that I don't close the db. I create two database when app launches, each db is used for specific reason. one Is located in cache directory (so OS can delete it anytime) and one is created in documents directory (user contents). I don't close the databases at all and changing path is not possible because the app is in production. It only happened on Android devices. I have opened a new related issue: |
Description
Failed to update sqlite database. Error message says
But database object configuration is not (
SqfliteDatabaseBase.isOpen = true
,SqfliteDatabaseBase.isClosed = false
andSqfliteDatabaseBase.readonly = false
)Steps to reproduce
Note: This bug will occur after executing a hot restart, but doing a hot reload or restart completely (Stop and run again) seems to work
Error log
Information
The text was updated successfully, but these errors were encountered: