Skip to content

Commit eeb37b6

Browse files
fix: recoverdata and log print (#3545)
* fix: ops log print * fix log and try recover all table
1 parent 4f49313 commit eeb37b6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tools/openmldb_ops.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import logging
15-
15+
# for Python 2, don't use f-string
1616
log = logging.getLogger(__name__)
1717
import os
1818
import sys
@@ -118,8 +118,8 @@ def RecoverPartition(executor, db, partitions, endpoint_status):
118118
db=db, table_name=table_name, pid=pid, leader_endpoint=leader_endpoint))
119119
status = executor.LoadTable(leader_endpoint, table_name, tid, pid)
120120
if not status.OK():
121-
log.error("load table failed. db {db} name {table_name} tid {tid} pid {pid} endpoint {leader_endpoint} msg {status.GetMsg()}".format(
122-
db=db, table_name=table_name, tid=tid, pid=pid, leader_endpoint=leader_endpoint, status=status))
121+
log.error("load table failed. db {db} name {table_name} tid {tid} pid {pid} endpoint {leader_endpoint} msg {status}".format(
122+
db=db, table_name=table_name, tid=tid, pid=pid, leader_endpoint=leader_endpoint, status=status.GetMsg()))
123123
return Status(-1, "recover partition failed")
124124
if not partitions[leader_pos].IsAlive():
125125
status = executor.UpdateTableAlive(db, table_name, pid, leader_endpoint, "yes")
@@ -204,8 +204,9 @@ def RecoverData(executor):
204204
log.error("get all table failed")
205205
return
206206
for name in tables:
207+
# if recover failed, continue to recover next table
207208
if not RecoverTable(executor, db, name).OK():
208-
return
209+
log.error("recover table failed. db {db} name {name}, check log for detail".format(db=db, name=name))
209210

210211
def ChangeLeader(db, partition, src_endpoint, desc_endpoint, one_replica, restore = True):
211212
log.info(

tools/tool.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import subprocess
1717
import sys
1818
import time
19+
# for Python 2, don't use f-string
1920
log = logging.getLogger(__name__)
2021
logging.basicConfig(level=logging.INFO, format = '%(levelname)s: %(message)s')
2122

@@ -276,6 +277,7 @@ def LoadTable(self, endpoint, name, tid, pid, sync = True):
276277
cmd = list(self.tablet_base_cmd)
277278
cmd.append("--endpoint=" + self.endpoint_map[endpoint])
278279
cmd.append("--cmd=loadtable {} {} {} 0 8".format(name, tid, pid))
280+
log.info("run {cmd}".format(cmd = cmd))
279281
status, output = self.RunWithRetuncode(cmd)
280282
time.sleep(1)
281283
if status.OK() and output.find("LoadTable ok") != -1:
@@ -289,12 +291,12 @@ def LoadTable(self, endpoint, name, tid, pid, sync = True):
289291
if table_stat == "kTableNormal":
290292
return Status()
291293
elif table_stat == "kTableLoading" or table_stat == "kTableUndefined":
292-
log.info("table is loading... tid {tid} pid {pid}".format(tid, pid))
294+
log.info("table is loading... tid {tid} pid {pid}".format(tid = tid, pid = pid))
293295
else:
294-
return Status(-1, "table stat is {table_stat}".format(table_stat))
296+
return Status(-1, "table stat is {table_stat}".format(table_stat = table_stat))
295297
time.sleep(2)
296298

297-
return Status(-1, "execute load table failed")
299+
return Status(-1, "execute load table failed, status {msg}, output {output}".format(msg = status.GetMsg(), output = output))
298300

299301
def GetLeaderFollowerOffset(self, endpoint, tid, pid):
300302
cmd = list(self.tablet_base_cmd)

0 commit comments

Comments
 (0)