Problems with busy_timeout with SQL lite, xorm seems to be ignoring it #1979
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#1979
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi Lunny.
I have a program that uses SQL lite and I have a background process that is writing to SQL lite.
Then I have a CLI process that reads and writes to there. Sometimes they try to get a lock at the same time and in that case the busy timeout should make them wait for each other.
The SQLlite parameters are being passed through and I can see the driver is picking up the busy_timeout that I am passing through.
The problem is after I start a transaction and do an update on a model in the database then it fails immediately with Database locked instead of waiting for the busy wait time.
When I do this with mattn/go-sqlite3 directly and skip xorm this works perfectly, but I want to use xorm as it is very convenient to use.
This is how I construct the engine:
This is basically what I am doing and the .Update() is failing immediately with database locked and not waiting on the _busy_wait that SQL lite should be waiting, assuming the SQL lite driver should be blocking.
Any input would be greatly appreciated as I realise it can be a user/my error but I do not know the internals of xorm inside out.
Thanks for you reporting. I never used the parameter
busy_timeout
or_busy_timeout
?I will test it and investigate what's wrong.
It is _busy_timeout, that is picked up by mattn/go-sqlite3.
1157a4212d/sqlite3.go (L1137)
Default busy timeout is 5 seconds see
1157a4212d/sqlite3.go (L1030)
.However when doing the session.Update() it is not waiting 5 seconds, but rather just failing straight away with database locked. I cannot understand how this can happen as when I use the mattn/go-sqlite3 driver directly it waits the timeout, xorm calls into the driver, I cannot understand how it can bypass it.
when I wrap core.DB around database/sql *DB it works fine also but when using the xorm Session it starts to not work.
Did you get a chance to look at this @lunny ? :).
Is it related with a transaction? Have you tried transaction with core.DB / sql.DB ?
I cannot reproduce this. Below is my test code on macOS: