Repository navigation
Fix broken 3.8 SQLite test pipeline - #266
Merged
Merged
Conversation
Closed
saaj
approved these changes
Dec 21, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The test
tests/taxii2/test_taxii2_sqldb.py::test_delete_object[wrong collection]returnssqlite3.OperationalError: disk I/O errorwith the envpy38-sqlalchemy14-werkzeuglt21-sqlite.How to reproduce
Run all the tests with
tox -e py38-sqlalchemy14-werkzeuglt21-sqliteon a fresh python environment. Delete the old environment if existing before.Other failed attempts to reproduce it, eg it passed:
tox -e py38-sqlalchemy14-werkzeuglt21-sqlite -- tests/test_* <failed-test>andtox -e py38-sqlalchemy14-werkzeuglt21-sqlite -- tests/taxii2/test_taxii2_sqldb.py. Both succeeded.tox -e py38-sqlalchemy14-werkzeuglt21-sqlite -- --no-covAnother surprising fact is that using the
pip freezeoutput from last successful run job link also failed locally for me.Hypothesis
A timing issue with sqlite accessing the DB file from a still alive connection while this one is deleted by the fixture
app(truncate_app>clean_db).I am in favor for this hypothesis because, by replacing
os.remove(filename)withopen(filename, 'w').close()to just prune the file content. The error is thenOperationalError: database is locked.According to this SO thread, this is mostly related to leftover connection. It should be added that this error happened more than for just the problematic test so it is not an exact correlation.
Normally SQLite can provide more logs, but the
sqlite3is not able to leverage it according to this recent discussion. Also SQLite is providing extended error code but those are only available from Python 3.11 where the test always passed.Solution
Explicitly dispose all DB connections from
sqlalchemy.It is not clear if the closed connection is the fix or just because it delays the code a bit.
Other
Full test report