소스 검색

mysql pipe handler - log only once

Olivier Massot 5 년 전
부모
커밋
ec37c90c0c
1개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. 10 6
      clonedb.py

+ 10 - 6
clonedb.py

@@ -102,6 +102,7 @@ class MysqlHandler(MysqldumpHandler):
     _rx_prog = re.compile(r'^((?:CREATE TABLE )|(?:INSERT INTO ))`(\w+)`')
     _log_all = LOG_PIPES_OUTPUT
     _action_name = "restoring"
+    _last_logged = ""
 
     def process(self, line):
         """ Process the last line that was read
@@ -110,10 +111,13 @@ class MysqlHandler(MysqldumpHandler):
         if SHOW_PROGRESSION:
             match = self._rx_prog.search(line)
             if match:
-                logger.debug('... %s %s %s', self._action_name,
-                             'structure of' if 'CREATE' in match.group(1) else 'data of',
-                             match.group(2))
-                print('.', end="", flush=True)
+                tname = match.group(2)
+                if tname != self._last_logged:
+                    logger.debug('... %s %s %s', self._action_name,
+                                 'structure of' if 'CREATE' in match.group(1) else 'data of',
+                                 tname)
+                    print('.', end="", flush=True)
+                    self._last_logged = tname
         if self._log_all:
             logger.debug(line)
 
@@ -154,7 +158,7 @@ class MySqlServer:
                                    user=self.username,
                                    password=self.password,
                                    autocommit=autocommit,
-                                   max_allowed_packet=MAX_ALLOWED_PACKET,
+                                   max_allowed_packet="32M",
                                    )
 
         if not self.cnn.open:
@@ -299,7 +303,7 @@ class CloningOperation:
         ready-to-consume list for Popen
         @see https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_quick
         """
-        init_command = "set global max_allowed_packet=1073741824;" \
+        init_command = f"set global max_allowed_packet={MAX_ALLOWED_PACKET};" \
                        "set global wait_timeout=28800;" \
                        "set global interactive_timeout=28800;"