Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix ancient blocks queue deadlock #8751

Merged
merged 8 commits into from Jun 5, 2018
Merged

Fix ancient blocks queue deadlock #8751

merged 8 commits into from Jun 5, 2018

Conversation

tomusdrw
Copy link
Collaborator

A more generic solution proposed by @ngotchac is replaced with a solution that handles only ancient blocks.

The problem with previous solution was that queue.lock().pop_front() was actually holding the lock for longer then needed and if fun was trying to use the queue recursively it would deadlock (since parking_lot mutexes are not re-entrant).

Avoiding holding the lock would cause race issues and we need to be super sure that old blocks are imported in order by the same thread.

Hence I reverted to the old IoChannelQueue implementation and introduced a separate import_lock for ancient blocks. We don't lock on the queue to prevent blocking the event loop when adding new items.

@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels May 31, 2018
@5chdn 5chdn added this to the 1.12 milestone May 31, 2018
&*client.chain.read()
).map(|_| ()).unwrap_or_else(|e| {
error!(target: "client", "Error importing ancient block: {}", e);
});
Copy link
Collaborator

@niklasad1 niklasad1 Jun 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider to use .ok().map_or_else here instead of map().unwrap_or_else

@5chdn 5chdn added B0-patchthis P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible. B9-blocker 🚧 This pull request blocks the next release from happening. Use only in extreme cases. labels Jun 5, 2018
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Although I don't totally understand what was causing the deadlock (why would fun be recursing?).

@5chdn 5chdn merged commit 6771539 into master Jun 5, 2018
@5chdn 5chdn deleted the td-fix-block-queue branch June 5, 2018 17:49
sorpaas pushed a commit that referenced this pull request Jun 5, 2018
* Revert "Fix not downloading old blocks (#8642)"

This reverts commit d193436.

* Make sure only one thread actually imports old blocks.

* Add some trace timers.

* Bring back pending hashes set.

* Separate locks so that queue can happen while we are importing.

* Address grumbles.
5chdn added a commit that referenced this pull request Jun 5, 2018
* parity-version: bump beta to 1.11.3

* Disallow unsigned transactions in case EIP-86 is disabled (#8802)

* Disallow unsigned transactions in case EIP-86 is disabled

* Add tests for verification

* Add disallow unsigned transactions test in machine

* Fix ancient blocks queue deadlock (#8751)

* Revert "Fix not downloading old blocks (#8642)"

This reverts commit d193436.

* Make sure only one thread actually imports old blocks.

* Add some trace timers.

* Bring back pending hashes set.

* Separate locks so that queue can happen while we are importing.

* Address grumbles.
ordian added a commit to ordian/parity that referenced this pull request Jun 6, 2018
…rp_sync_on_light_client

* 'master' of https://github.com/paritytech/parity:
  Remove UI related settings from CLI (openethereum#8783)
  Remove windows tray and installer (openethereum#8778)
  docs: add changelogs for 1.10.6 and 1.11.3 (openethereum#8810)
  Fix ancient blocks queue deadlock (openethereum#8751)
  Disallow unsigned transactions in case EIP-86 is disabled (openethereum#8802)
  Fix evmbin compilation (openethereum#8795)
  Have space between feature cfg flag (openethereum#8791)
  rpc: fix address formatting in TransactionRequest Display (openethereum#8786)
dvdplm added a commit that referenced this pull request Jun 7, 2018
…eric

* origin/master:
  ethcore: fix ancient block error msg handling (#8832)
  CI: Fix docker tags (#8822)
  parity: fix indentation in sync logging (#8794)
  Removed obsolete IpcMode enum (#8819)
  Remove UI related settings from CLI (#8783)
  Remove windows tray and installer (#8778)
  docs: add changelogs for 1.10.6 and 1.11.3 (#8810)
  Fix ancient blocks queue deadlock (#8751)
  Disallow unsigned transactions in case EIP-86 is disabled (#8802)
  Fix evmbin compilation (#8795)
  Have space between feature cfg flag (#8791)
  rpc: fix address formatting in TransactionRequest Display (#8786)
  Conditionally compile ethcore public test helpers (#8743)
  Remove Result wrapper from AccountProvider in RPC impls (#8763)
  Update `license header` and `scripts` (#8666)
@5chdn 5chdn added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. B9-blocker 🚧 This pull request blocks the next release from happening. Use only in extreme cases. M4-core ⛓ Core client code / Rust. P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants