# Buggy code
async def _run_backfill(self) -> None:
    await self._begin_backfill.wait()
    if self._next_trie_root_hash is None:
        raise RuntimeError(
            "Cannot start backfill when a recent trie root hash is unknown"
        )

    loop = asyncio.get_event_loop()
    while self.manager.is_running:
        # Collect node hashes that might be missing; enough for a single request.
        # Collect batch before asking for peer, because we don't want to hold the
        #   peer idle, for a long time.
        required_data = await loop.run_in_executor(None, self._batch_of_missing_hashes)

        if len(required_data) == 0:
            # Nothing available to request, for one of two reasons:
            if self._check_complete():
                self.logger.info("Downloaded all accounts, storage and bytecode state")
                return
            else:
                # There are active requests to peers, and we don't have enough information to
                #   ask for any more trie nodes (for example, near the beginning, when the top
                #   of the trie isn't available).
                self.logger.debug("Backfill is waiting for more hashes to arrive")
                await asyncio.sleep(PAUSE_SECONDS_IF_STATE_BACKFILL_STARVED)
                continue

        await asyncio.wait(
            (
                self._external_peasant_usage.until_silence(),
                self.manager.wait_finished(),
            ),
            return_when=asyncio.FIRST_COMPLETED,
        )
        if not self.manager.is_running:
            break

        peer = await self._queening_queue.pop_fastest_peasant()

        self.manager.run_task(self._make_request, peer, required_data)


# Traceback (p2p.exceptions.ConnectionBusy)
f2b7-40b4-a77a-6ba6d13da819>: Timed out waiting for NodeDataV65 request lock or connection: Connection-<Session <Node(0xd4062d@91.13.194.238)> 1c231c61-f2b7-40b4-a77a-6ba6d13da819>�[0m
DEBUG  2020-09-02 12:59:58,686        BeamDownloader  Problem downloading nodes from peer, dropping...
Traceback (most recent call last):
File "/usr/src/app/trinity/p2p/exchange/candidate_stream.py", line 81, in payload_candidates
timeout=total_timeout * NUM_QUEUED_REQUESTS,
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 449, in wait_for
raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/app/trinity/trinity/sync/beam/state.py", line 681, in _request_nodes
node_hashes, timeout=self._reply_timeout)
File "/usr/src/app/trinity/trinity/protocol/eth/exchanges.py", line 110, in __call__
timeout,
File "/usr/src/app/trinity/p2p/exchange/exchange.py", line 73, in get_result
timeout,
File "/usr/src/app/trinity/p2p/exchange/manager.py", line 59, in get_result
async for payload in stream.payload_candidates(request, tracker, timeout=timeout):
File "/usr/src/app/trinity/p2p/exchange/candidate_stream.py", line 85, in payload_candidates
f"Timed out waiting for {self.response_cmd_name} request lock "
p2p.exceptions.ConnectionBusy: Timed out waiting for NodeDataV65 request lock or connection: Connection-<Session <Node(0xd4062d@91.13.194.238)> 1c231c61-f2b7-40b4-a77a-6ba6d13da819>

# Fixed code
async def _run_backfill(self) -> None:
    await self._begin_backfill.wait()
    if self._next_trie_root_hash is None:
        raise RuntimeError(
            "Cannot start backfill when a recent trie root hash is unknown"
        )

    loop = asyncio.get_event_loop()
    while self.manager.is_running:
        # Collect node hashes that might be missing; enough for a single request.
        # Collect batch before asking for peer, because we don't want to hold the
        #   peer idle, for a long time.
        required_data = await loop.run_in_executor(None, self._batch_of_missing_hashes)

        if len(required_data) == 0:
            # Nothing available to request, for one of two reasons:
            if self._check_complete():
                self.logger.info("Downloaded all accounts, storage and bytecode state")
                return
            else:
                # There are active requests to peers, and we don't have enough information to
                #   ask for any more trie nodes (for example, near the beginning, when the top
                #   of the trie isn't available).
                self.logger.debug("Backfill is waiting for more hashes to arrive")
                await asyncio.sleep(PAUSE_SECONDS_IF_STATE_BACKFILL_STARVED)
                continue

        await asyncio.wait(
            (
                self._external_peasant_usage.until_silence(),
                self.manager.wait_finished(),
            ),
            return_when=asyncio.FIRST_COMPLETED,
        )
        if not self.manager.is_running:
            break

        peer = await self._queening_queue.pop_fastest_peasant()

        # skip over peer if it has an active data request
        while peer.eth_api.get_node_data.is_requesting:
            self.logger.debug(
                "Want backfill nodes from %s, but it has an active request, skipping...",
                peer,
            )
            # Put this peer back
            self._queening_queue.insert_peer(peer, NON_IDEAL_RESPONSE_PENALTY)
            # Ask for the next peer
            peer = await self._queening_queue.pop_fastest_peasant()

        self.manager.run_task(self._make_request, peer, required_data)