Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't try to send self address when connecting as read-only #126

Merged
merged 2 commits into from
Oct 21, 2020

Conversation

CyberDem0n
Copy link
Contributor

When connecting as readonly node to the cluster with encryption enabled the _onOutgoingMessageReceived() method tried to unconditionally send _selfNode.address after an exchange of random keys.
Since the _selfNode.address is None, the following exception was raised:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/syncobj.py", line 505, in _autoTickThread
    self._onTick(self.__conf.autoTickPeriod)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/syncobj.py", line 617, in _onTick
    self._poller.poll(timeToWait)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/poller.py", line 97, in poll
    self.__descrToCallbacks[descr](descr, eventMask)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/tcp_connection.py", line 174, in __processConnection
    self.__onMessageReceived(message)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/transport.py", line 455, in _onOutgoingMessageReceived
    conn.send(self._selfNode.address)
AttributeError: 'NoneType' object has no attribute 'address'

When connecting as readonly node to the cluster with encryption enabled
the _onOutgoingMessageReceived() method tried to unconditionally send
_selfNode.address after an exchange of random keys. Since the
_selfNode.address is None following exception was raised:
```python
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/syncobj.py", line 505, in _autoTickThread
    self._onTick(self.__conf.autoTickPeriod)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/syncobj.py", line 617, in _onTick
    self._poller.poll(timeToWait)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/poller.py", line 97, in poll
    self.__descrToCallbacks[descr](descr, eventMask)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/tcp_connection.py", line 174, in __processConnection
    self.__onMessageReceived(message)
  File "/usr/local/lib/python2.7/dist-packages/pysyncobj/transport.py", line 455, in _onOutgoingMessageReceived
    conn.send(self._selfNode.address)
AttributeError: 'NoneType' object has no attribute 'address'
```
@coveralls
Copy link

coveralls commented Oct 21, 2020

Coverage Status

Coverage increased (+0.01%) to 86.268% when pulling 9d20d86 on CyberDem0n:bugfix/encrypted-readonly into 999e694 on bakwc:master.

@bakwc
Copy link
Owner

bakwc commented Oct 21, 2020

Could you write a unit test on this case (in test_syncobj.py)?

@CyberDem0n
Copy link
Contributor Author

Also I've got another question about encryption. Why the TcpConnection.encryptor is reset on disconnect? It makes it impossible for nodes to reconnect if one of the partners was disconnected/restarted/not accessible, because next time it will try to connect without encryption and remote side will drop such connections.

@bakwc
Copy link
Owner

bakwc commented Oct 21, 2020

Disconnect works as a destructor (for cases when garbage collector is disabled and only reference counting works). May be there is a bug, there are only few tests for encryption (was not a priority use case). You can write a test and fix it in separate PR.

@bakwc bakwc merged commit 08ac10a into bakwc:master Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants