• Levin Zimmermann's avatar
    identification: Set possible answers to same msgid · b9f38390
    Levin Zimmermann authored
    When a node tries to connect to another node it initially sends a
    'RequestIdentification' packet. The other node can either reply with
    'AcceptIdentification' or in case of a secondary master with
    'NotPrimaryMaster'.
    
    In the second case the message id differs from the initial requests
    message id. This makes it difficult in a multi-threaded implementation
    to proceed this answer: due to the different msg/connection - id the
    multi-threaded implementation tries to proceed this incoming message in
    a different thread, while the requesting thread waits forever for its
    peers reply.
    
    The most straightforward solution is to use the same connection - id for
    both possible answers to the 'RequestIdentification' packet. This
    doesn't break given NEO/py implementation and is only a small patch.
    A workaround in a multi-threaded implementation on the other hand
    seems to be much more complicated and time-consuming. Finally it also makes
    sense semantically, because "Message IDs are used to identify response
    packets" and in the given context the 'NotPrimaryMaster' *is* the de facto
    response of a 'RequestIdentification'.
    
    Because the msgid is the same now, '_ask' uses the
    'PrimaryBootstrapHandler' (if it's the same connection) [1], so it may also
    be necessary to move 'notPrimaryMaster' to 'PrimaryBootstrapHandler'.
    
    [1] https://lab.nexedi.com/nexedi/neoppod/blob/ecc9c63c7/neo/lib/threaded_app.py#L142
    b9f38390
identification.py 6.56 KB