Skip to content
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

A concurrency problem in SQLiteWallet because of across execution #3534

Open
nan01ab opened this issue Oct 13, 2024 · 0 comments
Open

A concurrency problem in SQLiteWallet because of across execution #3534

nan01ab opened this issue Oct 13, 2024 · 0 comments
Labels
discussion Initial issue state - proposed but not yet accepted enhancement Type - Changes that may affect performance, usability or add new features to existing modules.

Comments

@nan01ab
Copy link
Contributor

nan01ab commented Oct 13, 2024

Describe the bug
In SQLiteWallet, it uses two lock to avoid concurrency problems:

  • lock (accounts) to protect the accounts structure;
  • lock (db_lock) to protect the WalletDataContext;

Because there are two locks, and there not locked at the same time.
This method may lead to some problems in some cases, for example:

  1. Cross-execution of the CreateAccount and the DeleteAccount:
    These two methods use same lock step:
lock (accounts) { 
  // step 1;
}

lock (db_lock) {
 // step 2;
}

It may lead to unconsistency state if a thread executed AddAccount step 1 and switched out, then another thread executed DeleteAccount step 1 and step 2, then thread-1 executes AddAccount step 2.

  1. Cross-execution of diffirent CreateAccounts: Similar execution process.
@Jim8y Jim8y added enhancement Type - Changes that may affect performance, usability or add new features to existing modules. discussion Initial issue state - proposed but not yet accepted labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Initial issue state - proposed but not yet accepted enhancement Type - Changes that may affect performance, usability or add new features to existing modules.
Projects
None yet
Development

No branches or pull requests

2 participants