master: add --backup to initialize in BACKINGUP
This applies only to an empty cluster and makes the cluster transition from the initial state RECOVERING to BACKINGUP without passing through state RUNNING: (empty) -> RECOVERING -> VERIFYING -> STARTING_BACKUP -> BACKINGUP This is the only way to reach BACKINGUP without having to pass through RUNNING first and manually transitioning to STARTING_BACKUP. It is the only way to reach state BACKINGUP fully automatically. See merge request !25
Showing
... | ... | @@ -92,6 +92,10 @@ class Application(BaseApplication): |
help='the name of cluster to backup') | ||
_('M', 'upstream-masters', parse=util.parseMasterList, | ||
help='list of master nodes in the cluster to backup') | ||
_.bool('B', 'backup', | ||
help="transition automatically toward BACKINGUP instead of RUNNING" | ||
" - without passing through RUNNING - if the cluster is empty" | ||
" (this requires --upstream-cluster and --upstream-master)") | ||
_.int('i', 'nid', | ||
help="specify an NID to use for this process (testing purpose)") | ||
... | ... | @@ -144,6 +148,7 @@ class Application(BaseApplication): |
" different from cluster name") | ||
self.backup_app = BackupApplication(self, upstream_cluster, | ||
config['upstream_masters']) | ||
self.backup_initially = config['backup'] | ||
|
||
self.administration_handler = administration.AdministrationHandler( | ||
self) | ||
... | ... | @@ -308,7 +313,11 @@ class Application(BaseApplication): |
self.runManager(RecoveryManager) | ||
try: | ||
self.runManager(VerificationManager) | ||
if not self.backup_tid: | ||
if (self.backup_initially and | ||
self.getLastTransaction() == ZERO_TID): | ||
self.pt.setBackupTidDict({}) # {} <=> all ZERO_TID | ||
self.backup_tid = ZERO_TID | ||
elif not self.backup_tid: | ||
self.provideService() | ||
# self.provideService only returns without raising | ||
# when switching to backup mode. | ||
... | ... |