andpor / react-native-sqlite-storage

Full featured SQLite3 Native Plugin for React Native (Android and iOS)
MIT License
2.75k stars 521 forks source link

iOS "unable to open database file","code":0 #511

Open Crhaj opened 2 years ago

Crhaj commented 2 years ago

Hello,

In our app, we have been randomly experiencing issues with the database failing to process queries with the error "unable to open database file" and code 0. Unfortunately, the error is rather generic and we didn't recognize any patterns. My original thought was it might be because of storage space but some of our clients experienced this issue even when having plenty of free storage space. Our application that experiences these issues only targets iOS so I can't confirm if it is an issue on both Android and iOS. Any help would be appreciated (even just with understanding what the message and code combination mean).

We initialize the database when we start our application like this and then during the lifetime of our application call methods sqlBatch() and executeSql() to perform queries. Let me know if we are using the plugin wrongly and we should for example close the database after each query. I can confirm that the initialization code SQLite.openDatabase() is not an issue because there is no instance in our logs where the opening would fail.

Screenshot 2022-03-21 at 11 44 16

Expected Behavior

We expect the database to run our queries without issues.

Current Behavior

Randomly, the queries we run report that the database file could not be opened.

Possible Solution

???

Steps to Reproduce (for bugs)

Unfortunately, we were not able to replicate this behavior consistently and it only happened to our production clients.

Context

We are just using the database as always (and it always worked) but sometimes, randomly, queries fail with the mentioned error.

Your Environment

Debug logs

Unfortunately, it only happens randomly on production and the error is returned directly from the react-native-sqlite-storage plugin.