Commit 8173441b authored by Julien Muchembled's avatar Julien Muchembled

client: do not loop forever on unreadable cells when not connected to the master

When the connection to the primary master node is lost, the node manager
does not have anymore a reliable list of running nodes, so iterateForObject()
must not retry any cell.
parent 9c0a0c9e
......@@ -130,7 +130,7 @@ class ConnectionPool(object):
# state can have changed during connection attempt.
elif node.isRunning():
new_cell_list.append(cell)
if not new_cell_list:
if not new_cell_list or self.app.master_conn is None:
break
cell_list = new_cell_list
# wait a bit to avoid a busy loop
......
......@@ -31,6 +31,7 @@ from neo.lib.protocol import CellStates, ClusterStates, NodeStates, Packets, \
from .. import expectedFailure, _UnexpectedSuccess
from . import ClientApplication, NEOCluster, NEOThreadedTest, Patch
from neo.lib.util import add64, makeChecksum
from neo.client.exception import NEOStorageError
from neo.client.pool import CELL_CONNECTED, CELL_GOOD
class PCounter(Persistent):
......@@ -708,6 +709,10 @@ class Test(NEOThreadedTest):
cluster.stop()
def testClientReconnection(self):
conn = [None]
def getConnForNode(orig, node):
self.assertTrue(node.isRunning())
return conn.pop()
cluster = NEOCluster()
try:
cluster.start()
......@@ -739,6 +744,14 @@ class Test(NEOThreadedTest):
client.setPoll(0)
cluster.client.setPoll(1)
# Check reconnection to storage.
p = Patch(cluster.client.cp, getConnForNode=getConnForNode)
self.assertFalse(cluster.client.history(x1._p_oid))
del p
self.assertFalse(conn)
self.assertTrue(cluster.client.history(x1._p_oid))
# Check successful reconnection to master.
t1.begin()
self.assertEqual(x1._p_changed ,None)
self.assertEqual(x1.value, 1)
......
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