Page 1 of 1

Error writing csdb datafile

Posted: August 25th, 2025, 7:18 am
by Mariovaisman
Hello,
I have an app that works in windows devices, the database is located in a shared folder in a server, and up to three user are doing the data entry. When only one devices works, all is working properly, however when all are working, some time gives the message "THERE WAS AN ERROR SAVING THE CASE", or in automatic savepartials "THERE WAS AN ERROR WRITING TO THE DATA SOURCE: DATABASE IS LOCKED".
I do not know why the csdb is locked, or why the app maintain it locked to the rest of the users.
Is it a problem in the rights of the database in the server?,
I will apreciate your comments.
Thanks

Re: Error writing csdb datafile

Posted: August 25th, 2025, 8:49 am
by savy
CSDB file are SQLite files. SQLIte locks the files when writing to the database. This is the reason you are seeing this error message. Please see the helps for Networked Data Entry https://www.csprousers.org/help/CSPro/ ... entry.html
Your workarounds are
1. Have enumerators retry saving when this error appears. This usually works since the locks are brief.
2. Disable Auto Save Partial and programmatically do savepartial at specific points to reduce the incidence of these locking events.
3. Follow the sync approach described in our Networked Data Entry documentation.

The next version of CSPro will allow directly writing to the CSWeb MySQL database repository which will avoid these issues.

Re: Error writing csdb datafile

Posted: August 26th, 2025, 8:41 am
by Mariovaisman
Thank you Savy,
I see that I can check the savepartial() function return code and then f the error occur, I can wait 1 or 2 seconds and retry, however how I can manage the situation hen the case is completed?.
Thanks
Mario

BTW, I posted 2 times because the first time disappeared from the list, now both are in the list. Thanks

Re: Error writing csdb datafile

Posted: August 26th, 2025, 9:12 am
by savy
Removing autosave will reduce the occurrence of these concurency issues. An option is to have a control field at the end of the questionnaire where you first do savePartial and retry it until succeeding before the postproc of the level is processed.