Debug application performing transaction
0
votes
1
answer
275
views
I have an application to debug which performs a few dozen operations against a MySQL database. These operations are performed in a single transaction. I need to know the state of the database while debugging at a specific breakpoint.
I can log into the MySQL service using the common
mysql
CLI tool. I see that a transaction in progress:
mysql> SELECT * FROM information_schema.innodb_trx\G
*************************** 1. row ***************************
trx_id: 325090
trx_state: RUNNING
trx_started: 2022-09-14 12:10:32
trx_requested_lock_id: NULL
trx_wait_started: NULL
trx_weight: 30
trx_mysql_thread_id: 26
trx_query: NULL
trx_operation_state: NULL
trx_tables_in_use: 0
trx_tables_locked: 10
trx_lock_structs: 26
trx_lock_memory_bytes: 1128
trx_rows_locked: 43
trx_rows_modified: 4
trx_concurrency_tickets: 0
trx_isolation_level: REPEATABLE READ
trx_unique_checks: 1
trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
trx_adaptive_hash_latched: 0
trx_adaptive_hash_timeout: 0
trx_is_read_only: 0
trx_autocommit_non_locking: 0
trx_schedule_weight: NULL
1 row in set (0.01 sec)
## Now, how can I join that transaction to query the state of the database during the transaction?
As a workaround, I could add a query to the application code. However that requires me to know which query I want to run before running the application, and then to recompile the app for each query I want to run. Having an open CLI to debug would be very helpful.
The database is MySQL 8.0 running on Debian.
Asked by dotancohen
(1106 rep)
Sep 14, 2022, 12:26 PM
Last activity: Sep 16, 2022, 10:02 PM
Last activity: Sep 16, 2022, 10:02 PM