aiomysql icon indicating copy to clipboard operation
aiomysql copied to clipboard

Log when echo=true BEGIN/COMMIT/ROLLBACK functions

Open rspadim opened this issue 5 years ago • 3 comments

when using echo=true, we should log begin/commit/rollback as they are important commands to debug transactions

rspadim avatar Jun 10 '20 17:06 rspadim

example of debug output with formatter = readable_log_formatter.ReadableFormatter:

   DEBUG aiomysql in _execute_command (line:661)
         ECHO: b'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ'
         command: 3
   DEBUG aiomysql in _execute_command (line:661)
         ECHO: b'COMMIT'
         command: 3
   DEBUG aiomysql in _execute_command (line:661)
         ECHO: b'SET AUTOCOMMIT = 0'
         command: 3
   DEBUG aiomysql in _execute_command (line:661)
         ECHO: b'SET AUTOCOMMIT = 1'
         command: 3
   DEBUG aiomysql in _execute_command (line:661)
         ECHO: b"SELECT server_id,account_id,api_key FROM sync_instances WHERE session_id='842d9230-acea-414f-8066-2cfcc392c203;1;15173280'"
         command: 3
   DEBUG aiocache.base in set (line:268)
         SET sync_instances842d9230-acea-414f-8066-2cfcc392c203;1;15173280 1 (0.0001)s
   DEBUG aiomysql in _execute_command (line:661)
         ECHO: b'COMMIT'
         command: 3

rspadim avatar Jun 13 '20 15:06 rspadim

example of debug output without formatter and format = format=%(asctime)s - %(name)s - %(levelname)s - %(message)s :

2020-06-13 12:44:53,893 - aiomysql - DEBUG - ECHO: b'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ'
2020-06-13 12:44:53,893 - aiomysql - DEBUG - ECHO: b'COMMIT'
2020-06-13 12:44:53,894 - aiomysql - DEBUG - ECHO: b'SET AUTOCOMMIT = 0'
2020-06-13 12:44:53,895 - aiomysql - DEBUG - ECHO: b'SET AUTOCOMMIT = 1'
2020-06-13 12:44:53,895 - aiomysql - DEBUG - ECHO: b"SELECT server_id,account_id,api_key FROM sync_instances WHERE session_id='842d9230-acea-414f-8066-2cfcc392c203;1;15173280'"

rspadim avatar Jun 13 '20 15:06 rspadim

Hi @webknjaz, I'm new here and don't know if you can help here, but you have some commits =)

Please, when possible check if this PR is usefull

I couldn't debug deadlock without the commit / autocommit / transation isolations / being / rollback messages at connection level, the cursor level is "ok" but not as usefull as this one

rspadim avatar Jun 13 '20 15:06 rspadim