Skip to content

Race condition in P2P listen_to_p2p_network() #2834

Description

@abitmore

Bug Description
During testing there is a race condition in listen() in node_impl::listen_to_p2p_network() that appears quite frequently (see Github Actions logs e.g. https://github.com/bitshares/bitshares-core/actions/runs/34021597393/job/101455080081?pr=2833). The "bind - close (via object destruction) - rebind" approach is not ideal. A better approach is to not close the server socket if the first bind is successful, but keep and use it directly.

Ideally we also need a unit test case to cover the fix:

  • if bind succeeds
  • if bind fails
    • if "p2p-endpoint" option is not set, retry port 0 one time
    • if "p2p-endpoint" option is set, wait for a few seconds and then retry, repeat

Commit 8db58de in #1764 is related.

Impacts
Describe which portion(s) of BitShares Core may be impacted by this bug. Please tick at least one box.

  • API (the application programming interface)
  • Build (the build process or something prior to compiled code)
  • CLI (the command line wallet)
  • Deployment (the deployment process after building such as Docker, Travis, etc.)
  • DEX (the Decentralized EXchange, market engine, etc.)
  • P2P (the peer-to-peer network for transaction/block propagation)
  • Performance (system or user efficiency, etc.)
  • Protocol (the blockchain logic, consensus, validation, etc.)
  • Security (the security of system or user data, etc.)
  • UX (the User Experience)
  • Other (please add below)

Steps To Reproduce
Github Actions

Expected Behavior

Screenshots (optional)

Host Environment

  • Host OS: Ubuntu 24.04 LTS
  • Host Physical RAM
  • BitShares Version: 7.0.2
  • OpenSSL Version: 3.0
  • Boost Version: 1.83

Additional Context (optional)

CORE TEAM TASK LIST

  • Evaluate / Prioritize Bug Report
  • Refine User Stories / Requirements
  • Define Test Cases
  • Design / Develop Solution
  • Perform QA/Testing
  • Update Documentation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions