-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database is locked
error in some scenarios
#10838
Comments
Changing the flow a little bit results in a different error - In |
@saledjenic Currently if the
On top of fixing the
WDYT of adding another task to keep track of it once we plan to release for keycard support? |
There's a circular foreign key definition between |
Now about this part
Not sure that I understand this, but keycard support will be released with mvp. |
How do you see it "circular"?
Based on described relations I don't see any circular dependency? |
You are right, thanks! Got lost in keycards and keypairs. Back to square one to fully understand this behaviour.
What I meant is that currently when there is an error in profile migration the account becomes unusable. It is partially migrated to keycard, but the keycard login won't work. The question is if it's feasible (also if it's something we want) to fix this so that the user can still use the same account in case of migration error? |
Yes, that's true, if something goes wrong there is no a recovering process which will revert applied changes and keep the profile valid. Otherwise if an error occurs even if user is able to login, that account is corrupted, cause a migration was partially done and the data in the db are inconsistent. That's something we can think of and possibly improve, but I guess that will require wider changes cause I used the existing
for any of those we actually cannot do anything to recover from that state:
All in all (at least for now) that's very sensitive action (which may take very long, depends on the db size), which should go smooth, but if something goes wrong, the only what user can do is to remove local Status folder and recover his account. |
I'm facing the same issue when I was trying to change a display name in the latest master branch, here is the log:
@alexjba @osmaczko could we revert that commit where db improvements are added and merge it once we solve this issue? |
Hmmm... I cannot reproduce on latest master (under Linux). But... we have the very same issue open already: #10827 |
- reverts db pool until `database is locked` error is resolved related to: status-im/status-desktop#10838
- reverts db pool until `database is locked` error is resolved related to: status-im/status-desktop#10838
Apparently there can be read transactions and write transactions (based on the first statement used in the transaction). In our case the the db lock was happening when the first transaction statement is The fix in our case seems to be to set |
The default transaction lock is `deferred`. This means that the transaction will automatically become read or write transaction based on the first DB operation. In case the first operation is `SELECT` the transaction becomes read transaction, otherwise write transaction. When a read transaction tries to write the DB sqlite will promote the transaction to a write transaction if there is no other transaction that holds a lock. When the promotion fails `database is locked` error is returned. The error is returned immediately and does not use the busy handler. In our case almost all read transaction would fail with `database is locked` error. This fix is changing the default transaction lock to `IMMEDIATE`. It translates to `BEGIN IMMEDIATE` instead of `BEGIN`. In this mode, the transaction will be created as a write transaction no matter what DB operation will run as part of the transaction. The write transaction will try to obtain the DB lock immediately when `BEGIN IMMEDIATE` is called and the busy handler is used when the DB is locked by other transaction. Fixing: status-im/status-desktop#10838
Scenario |
- reverts db pool until `database is locked` error is resolved related to: status-im/status-desktop#10838
- reverts db pool until `database is locked` error is resolved related to: status-im/status-desktop#10838
The default transaction lock is `deferred`. This means that the transaction will automatically become read or write transaction based on the first DB operation. In case the first operation is `SELECT` the transaction becomes read transaction, otherwise write transaction. When a read transaction tries to write the DB sqlite will promote the transaction to a write transaction if there is no other transaction that holds a lock. When the promotion fails `database is locked` error is returned. The error is returned immediately and does not use the busy handler. In our case almost all read transaction would fail with `database is locked` error. This fix is changing the default transaction lock to `IMMEDIATE`. It translates to `BEGIN IMMEDIATE` instead of `BEGIN`. In this mode, the transaction will be created as a write transaction no matter what DB operation will run as part of the transaction. The write transaction will try to obtain the DB lock immediately when `BEGIN IMMEDIATE` is called and the busy handler is used when the DB is locked by other transaction. Fixing: status-im/status-desktop#10838
database is locked
error started to appear after db improvements were applied. Not sure when, under which circumstances that's happening, but folks from mobile team faced this issue as well. One flow where it is reproducible in 100% cases is when user is migrating his profile keypair to a keycard. That flow ends with an error due todatabase is locked
error which is happening when status-goConvertToKeycardAccount
function is called in this lineaddedKc, _, err := accountDB.AddKeycardOrAddAccountsIfKeycardIsAdded(kc)
.The text was updated successfully, but these errors were encountered: