Database close fails without error with pending transaction on Windows
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 9.2k
- Forks
- 1.2k
- Avg merge
- 19m
- Merged PRs (30d)
- 4
Description
Hi, thank you very much for making this package available to the community.
I have discovered what seems to be a bug that occurs when closing a database with a pending transaction. I have observed this on Windows, but it seems like it might be a problem on other platforms as well. The bug can be reproduced with the following test:
func TestPendingTransactionFail(t *testing.T) {
db, err := sql.Open("sqlite3", "test.db")
if err != nil {
t.Error(err)
}
_, err = db.Begin()
if err != nil {
t.Error(err)
}
err = db.Close()
if err != nil {
t.Error(err)
}
err = os.Remove("test.db")
if err != nil {
t.Error(err)
}
}
The call to os.Remove fails with the error: remove test.db: The process cannot access the file because it is being used by another process. The "other process" in this case is just this process with an open file handle to the database.
It seems that Close() should return an error if it fails to close the database. It currently returns nil even though the underlying fd isn't closed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the inline TestPendingTransactionFail reproducer and inspect the database/sql Close and Begin entry points in the go-sqlite3 driver. Done means closing a database with a pending transaction no longer leaves test.db locked, and Close reports an error if the underlying handle cannot be closed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100