Como na extract_resources fazemos uma única conexão com o banco de dados para extração de todos os recursos no full-extract, está sendo comum o erro de perda de conexão.
Como isso está acontecendo recorrentemente, mesmo depois de alterações nas configurações do banco de dados pelo NUCC/CGE, precisamos tornar nosso script mais confiável inserindo uma lógica de retry para conexões perdidas.
Para referência, segue o log completo do erro de 02/02 do arquivo age/logs/full_extract.txt
Traceback (most recent call last):
File "C:\Users\m752587\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\m752587\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\m752587\projects\age7\venv\Scripts\dtamg-py.exe\__main__.py", line 7, in <module>
File "c:\users\m752587\projects\age7\venv\lib\site-packages\click\core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\click\core.py", line 1053, in main
rv = self.invoke(ctx)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\m752587\projects\age7\venv\lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\m752587\projects\age7\venv\lib\site-packages\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\dtamg_py\full_extract.py", line 10, in full_extract_cli
full_extract()
File "c:\users\m752587\projects\age7\venv\lib\site-packages\dtamg_py\utils.py", line 45, in full_extract
extract_resources(dp.resources)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\dtamg_py\utils.py", line 33, in extract_resources
cursor.execute(sql_query)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\cursors.py", line 148, in execute
result = self._query(query)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\cursors.py", line 310, in _query
conn.query(q)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\connections.py", line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\connections.py", line 775, in _read_query_result
result.read()
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\connections.py", line 1163, in read
self._read_result_packet(first_packet)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\connections.py", line 1236, in _read_result_packet
self._read_rowdata_packet()
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\connections.py", line 1270, in _read_rowdata_packet
packet = self.connection._read_packet()
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\connections.py", line 711, in _read_packet
recv_data = self._read_bytes(bytes_to_read)
File "c:\users\m752587\projects\age7\venv\lib\site-packages\pymysql\connections.py", line 748, in _read_bytes
raise err.OperationalError(
pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')
Como na
extract_resources
fazemos uma única conexão com o banco de dados para extração de todos os recursos nofull-extract
, está sendo comum o erro de perda de conexão.Como isso está acontecendo recorrentemente, mesmo depois de alterações nas configurações do banco de dados pelo NUCC/CGE, precisamos tornar nosso script mais confiável inserindo uma lógica de retry para conexões perdidas.
Para referência, segue o log completo do erro de 02/02 do arquivo
age/logs/full_extract.txt