Commit e09e8edc authored by Levin Zimmermann's avatar Levin Zimmermann

identification: Set possible answers to same msgid

This patchs origin is !20.
With recent changes on kirr/neo!2
and levin.zimmermann/wendelin.core@f546d836
we can already use WCFS with multiple master nodes in combination with this
patch. Until we proceed in !20
we can already use a NEO/py with this patch in order to test WCFS on our
wind clone.

---

Original patch content:

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
parent c94f2ed5
......@@ -30,15 +30,15 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
def answerLastTransaction(*args):
pass
class PrimaryNotificationsHandler(MTEventHandler):
""" Handler that process the notifications from the primary master """
def notPrimaryMaster(self, *args):
try:
super(PrimaryNotificationsHandler, self).notPrimaryMaster(*args)
super(PrimaryBootstrapHandler, self).notPrimaryMaster(*args)
except PrimaryElected, e:
self.app.primary_master_node, = e.args
class PrimaryNotificationsHandler(MTEventHandler):
""" Handler that process the notifications from the primary master """
def answerLastTransaction(self, conn, ltid):
app = self.app
app_last_tid = app.__dict__.get('last_tid', '')
......
......@@ -156,5 +156,5 @@ class SecondaryIdentificationHandler(EventHandler):
for node in app.nm.getMasterList()]
conn.send(Packets.NotPrimaryMaster(
primary and known_master_list.index(primary),
known_master_list))
known_master_list), msg_id=conn.peer_id)
conn.abort()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment