Commit 1d8a0dbe authored by Julien Muchembled's avatar Julien Muchembled

storage: fix save or reset of 'backup_tid' config value

Because masters don't have persistent storage, the task to remember whether
the cluster is in backup mode or not is delegated to storages, via the presence
of a 'backup_tid' config value.

This fixes a bug that set 'backup_tid' after a simple replication.
If the cluster was restarted, it would have tried to switch to BACKINGUP state.
parent 4319b532
...@@ -18,7 +18,8 @@ import sys ...@@ -18,7 +18,8 @@ import sys
from collections import deque from collections import deque
from neo.lib import logging from neo.lib import logging
from neo.lib.protocol import uuid_str, CellStates, NodeTypes, Packets from neo.lib.protocol import uuid_str, \
CellStates, ClusterStates, NodeTypes, Packets
from neo.lib.node import NodeManager from neo.lib.node import NodeManager
from neo.lib.event import EventManager from neo.lib.event import EventManager
from neo.lib.connection import ListeningConnection from neo.lib.connection import ListeningConnection
...@@ -312,6 +313,10 @@ class Application(object): ...@@ -312,6 +313,10 @@ class Application(object):
for node in self.nm.getStorageList(only_identified=True): for node in self.nm.getStorageList(only_identified=True):
node.getConnection().close() node.getConnection().close()
def changeClusterState(self, state):
if state == ClusterStates.STOPPING_BACKUP:
self.dm.setBackupTID(None)
def wait(self): def wait(self):
# change handler # change handler
logging.info("waiting in hidden state") logging.info("waiting in hidden state")
......
...@@ -33,8 +33,7 @@ class BaseMasterHandler(EventHandler): ...@@ -33,8 +33,7 @@ class BaseMasterHandler(EventHandler):
raise PrimaryFailure('re-election occurs') raise PrimaryFailure('re-election occurs')
def notifyClusterInformation(self, conn, state): def notifyClusterInformation(self, conn, state):
logging.warning('ignoring notify cluster information in %s', self.app.changeClusterState(state)
self.__class__.__name__)
def notifyLastOID(self, conn, oid): def notifyLastOID(self, conn, oid):
self.app.dm.setLastOID(oid) self.app.dm.setLastOID(oid)
......
...@@ -113,8 +113,9 @@ class Replicator(object): ...@@ -113,8 +113,9 @@ class Replicator(object):
for offset, p in self.partition_dict.iteritems(): for offset, p in self.partition_dict.iteritems():
if offset not in outdated_set: if offset not in outdated_set:
tid = min(tid, p.next_trans, p.next_obj) tid = min(tid, p.next_trans, p.next_obj)
if tid not in (ZERO_TID, INVALID_TID): if ZERO_TID != tid != INVALID_TID:
return add64(tid, -1) return add64(tid, -1)
return ZERO_TID
def populate(self): def populate(self):
app = self.app app = self.app
...@@ -292,7 +293,9 @@ class Replicator(object): ...@@ -292,7 +293,9 @@ class Replicator(object):
del self.current_partition, self.replicate_tid, self.next_backup_tid del self.current_partition, self.replicate_tid, self.next_backup_tid
p = self.partition_dict[offset] p = self.partition_dict[offset]
p.next_obj = add64(tid, 1) p.next_obj = add64(tid, 1)
self.app.dm.setBackupTID(self.getBackupTID()) dm = self.app.dm
if dm.getBackupTID() is not None:
dm.setBackupTID(self.getBackupTID())
if not p.max_ttid: if not p.max_ttid:
p = Packets.NotifyReplicationDone(offset, tid) p = Packets.NotifyReplicationDone(offset, tid)
self.app.master_conn.notify(p) self.app.master_conn.notify(p)
......
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