diff --git a/confluent_server/bin/confluentdbutil b/confluent_server/bin/confluentdbutil index be35e5aa..0f3148e7 100755 --- a/confluent_server/bin/confluentdbutil +++ b/confluent_server/bin/confluentdbutil @@ -69,7 +69,10 @@ if args[0] == 'restore': if options.interactivepassword: password = getpass.getpass('Enter password to restore backup: ') try: + cfm.statelessmode = True cfm.restore_db_from_directory(dumpdir, password) + cfm.statelessmode = False + cfm.ConfigManager.wait_for_sync(True) if owner != 0: for targdir in os.walk('/etc/confluent'): os.chown(targdir[0], owner, group) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 58f4bc59..f1a4192e 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -2604,7 +2604,13 @@ class ConfigManager(object): with _dirtylock: dirtyglobals = copy.deepcopy(_cfgstore['dirtyglobals']) del _cfgstore['dirtyglobals'] - globalf = dbm.open(os.path.join(cls._cfgdir, "globals"), 'c', 384) # 0600 + try: + globalf = dbm.open(os.path.join(cls._cfgdir, "globals"), 'c', 384) # 0600 + except dbm.error: + if not fullsync: + raise + os.remove(os.path.join(cls._cfgdir, "globals")) + globalf = dbm.open(os.path.join(cls._cfgdir, "globals"), 'c', 384) # 0600 try: for globalkey in dirtyglobals: if globalkey in _cfgstore['globals']: @@ -2617,8 +2623,15 @@ class ConfigManager(object): globalf.close() if fullsync or 'collectivedirty' in _cfgstore: if len(_cfgstore.get('collective', ())) > 1: - collectivef = dbm.open(os.path.join(cls._cfgdir, "collective"), - 'c', 384) + try: + collectivef = dbm.open(os.path.join(cls._cfgdir, 'collective'), + 'c', 384) + except dbm.error: + if not fullsync: + raise + os.remove(os.path.join(cls._cfgdir, 'collective')) + collectivef = dbm.open(os.path.join(cls._cfgdir, 'collective'), + 'c', 384) try: if fullsync: colls = _cfgstore['collective'] @@ -2645,7 +2658,13 @@ class ConfigManager(object): currdict = _cfgstore['main'] for category in currdict: _mkpath(pathname) - dbf = dbm.open(os.path.join(pathname, category), 'c', 384) # 0600 + try: + dbf = dbm.open(os.path.join(pathname, category), 'c', 384) # 0600 + except dbm.error: + if not fullsync: + raise + os.remove(os.path.join(pathname, category)) + dbf = dbm.open(os.path.join(pathname, category), 'c', 384) # 0600 try: for ck in currdict[category]: dbf[ck] = cPickle.dumps(currdict[category][ck], protocol=cPickle.HIGHEST_PROTOCOL) @@ -2665,7 +2684,13 @@ class ConfigManager(object): currdict = _cfgstore['tenant'][tenant] for category in dkdict: _mkpath(pathname) - dbf = dbm.open(os.path.join(pathname, category), 'c', 384) # 0600 + try: + dbf = dbm.open(os.path.join(pathname, category), 'c', 384) # 0600 + except dbm.error: + if not fullsync: + raise + os.remove(os.path.join(pathname, category)) + dbf = dbm.open(os.path.join(pathname, category), 'c', 384) # 0600 try: for ck in dkdict[category]: if ck not in currdict[category]: