siara-cc/esp32_arduino_sqlite3_lib

multiple DELETE in transaction occasionally cause disk I/O error

albertlt opened this issue · 0 comments

Hi. I am running sqlite on esp32 sd card. I have to truncate multiple tables and insert new data once in a while. So what I did was I begin a transaction, issue DELETE on three tables, INSERT new data on all tables and COMMIT or ROLLBACK if there is error. If I do it once in a while, no problems. However if I immediately repeat the whole process again, the DELETE on second table always produce disk I/O error.

I tried to INSERT 5000 records in a single transaction and it also produce an error at the end when trying to COMMIT. Is there an issue with transaction?

ERROR:

BEGIN TRANSACTION
DELETE FROM TABLE A -- OK
DELETE FROM TABLE B -- OK
DELETE FROM TABLE C -- OK
INSERT NEW DATA TO TABLE A ( 3 rows ) -- OK
INSERT NEW DATA TO TABLE B (3 rows ) -- OK
INSERT NEW DATA TO TABLE C (3 rows ) -- OK
COMMIT -- OK

BEGIN TRANSACTION -- OK
DELETE FROM TABLE A -- OK
DELETE FROM TABLE B -- Failed: Disk I/O Error

ALSO ERROR:

BEGIN TRANSACTION -- OK
DELETE FROM TABLE A -- OK
DELETE FROM TABLE B -- OK
DELETE FROM TABLE C -- OK
INSERT NEW DATA TO TABLE A ( 1000 rows ) -- OK
INSERT NEW DATA TO TABLE B (2000 rows ) -- OK
INSERT NEW DATA TO TABLE C (2000 rows ) -- OK
COMMIT -- Failed: Disk I/O Error