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

Improve locks acquiring #7947

Merged
merged 3 commits into from
Jul 19, 2023
Merged

Improve locks acquiring #7947

merged 3 commits into from
Jul 19, 2023

Conversation

Qwerty5Uiop
Copy link
Contributor

@Qwerty5Uiop Qwerty5Uiop commented Jul 17, 2023

Resolves #6755
Resolves #6734

Motivation

Currently we are using FOR UPDATE locks in every lock queries, but there is no need to use this lock type for queries that are not going to delete or modify primary key. In these cases it's better to use FOR NO KEY UPDATE to avoid unnecessary locks.

Also, there are several locks that hold data not meant to be updated.

Changelog

  • Change lock type from FOR UPDATE to FOR NO KEY UPDATE for queries that are not going to delete data or modify PK
  • Move tokens lock acquiring from Blocks and CurrentTokenBalances runners to update token holders function since this lock is only needed for insert ordering
  • Upgrade lock acquiring in EmptyBlockSanitizer so it doesn't conflict with general block fetchers

@Qwerty5Uiop Qwerty5Uiop changed the title Decrease locks level Improve locks acquiring Jul 19, 2023
@vbaranov vbaranov merged commit ccab6d6 into master Jul 19, 2023
@vbaranov vbaranov deleted the soften-locks branch July 19, 2023 14:29
rkachowski added a commit to celo-org/blockscout that referenced this pull request Aug 28, 2023
rkachowski added a commit to celo-org/blockscout that referenced this pull request Sep 5, 2023
rkachowski added a commit to celo-org/blockscout that referenced this pull request Sep 6, 2023
rkachowski added a commit to celo-org/blockscout that referenced this pull request Sep 6, 2023
* cherry-pick -m 1 41f562b

* Remove withdrawals tabel from migration (we dont' have it)

* Apply changes from blockscout#7947 to reduce lock strength

* Fix empty block sanitiser parsing.

* Sort coin_balance fetcher address imports by hash.

* Skipping flaky test.

* Explicitly set lock_timeout for address import / insertion.

* Revert "Explicitly set lock_timeout for address import / insertion."

This reverts commit 7df9785.

* Remove schema migration files from PR.

---------

Co-authored-by: Victor Baranov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Research soften "FOR UPDATE" to "FOR NO KEY UPDATE" block_catchup deadlock detected ?
3 participants