Skip to content

Commit f287374

Browse files
committed
Add instrumentation to debug I/O error in CI that I don't get locally
try to debug 'sqlite3.OperationalError: disk I/O error' failures: https://github.com/roundup-tracker/roundup/actions/runs/2995869962 https://app.travis-ci.com/github/roundup-tracker/roundup/jobs/581894108 during commit(). Get info on mode, uid, gid etc. for db directory and files in it. I can provoke the failure by stopping before a self.conn.commit(), chmod 555 the directory holding the db then continue. But even running a full test suite I never see this error. It only occurs for some tests and not others and doesn't seem to be consistent. One other possible workaround is setting it to WAL mode rather than journal mode when opening it.
1 parent e00d0dd commit f287374

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

roundup/backends/back_sqlite.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,39 @@ def sql_commit(self):
418418
419419
Ignore errors if there's nothing to commit.
420420
"""
421+
def list_dir(dir):
422+
import os
423+
files = os.listdir(self.dir)
424+
# ['db-journal', 'files', 'db']
425+
for entry in [''] + files:
426+
path = self.dir + '/' + entry
427+
stat = os.stat(path)
428+
print("file: %s, uid: %s, gid: %s, mode: %o"%(path,
429+
stat.st_uid, stat.st_gid, stat.st_mode))
430+
431+
# Getting sqlite3.OperationalError: disk I/O error
432+
# in CI. It happens intermittently. Try to get more
433+
# info about what is happening and retry the commit.
434+
# Some possibilities:
435+
# -journal file not writable
436+
# file has disappeared
437+
#
438+
# Note after exception self.conn.in_transaction is False
439+
# but was True before failed commit(). Retry succeeds,
440+
# but I am not sure it actually does anything.
441+
# for retry in range(2):
421442
try:
422443
self.conn.commit()
444+
except sqlite.OperationalError as error:
445+
if str(error) != 'disk I/O error':
446+
raise
447+
list_dir(self.dir)
448+
raise
423449
except sqlite.DatabaseError as error:
424450
if str(error) != 'cannot commit - no transaction is active':
425451
raise
452+
# else:
453+
# break # out of loop if no exception
426454
# open a new cursor for subsequent work
427455
self.cursor = self.conn.cursor()
428456

0 commit comments

Comments
 (0)