Commit 9a132d42 authored by Monty's avatar Monty

MDEV-33620 Improve times and states in show processlist for replication

This will makes it easier to find out what replication workers are
doing and what they are waiting for.

Things changed in processlist:
- Slave_SQL time was not consistent. Now time for state "Slave has
  read all relay log; waiting for more updates" shows how long it has
  waited for getting the next event.
- Slave_worker threads did often show "Closing tables" for a long
  time.  Now the state is reverted to the previous state after
  "Closing tables" is done.
- Commit and Rollback states where not shown for replication (and some
  other threads). Now Commit and Rollback states are always shown and
  the state is reverted to previous state when the Commit/Rollback
  have finished.

Code changes:
- Added thd->set_time_for_next_stage() for parallel replication when
  when starting to wait for prior transactions to commit, group commit,
  and FTWRL and for free space in thread pool.
  Before we reset the time only after the above events.
- Moved THD_STAGE_INFO(stage_rollback) and THD_STAGE_INFO(stage_commit)
  from sql_parse.cc to transaction.cc to ensure this is done for
  all commits and not only 'normal connection queries'.

Test case changes:
- close_thread_tables() reverting stage to previous stage caused the
  counter in performance_schema to be increased. In many case it is
  the 'sql/starting' stage that was effected.
- We only change to "Commit" stage if there is a need for a commit.
  This caused some "Commit" stages to disapper from perfschema reports.

TODO in 11.#:
- Slave_IO always showes "Waiting for master to send event" and the time is
  from SLAVE START. We should in 11.# change this to be the time since
  reading the last event.
parent 0df4651c
......@@ -82,11 +82,10 @@ stage/sql/Unlocking tables NULL NULL
stage/sql/Rename result table NULL NULL
stage/sql/End of update loop NULL NULL
stage/sql/Query end NULL NULL
stage/sql/Commit NULL NULL
stage/sql/closing tables NULL NULL
stage/sql/Unlocking tables NULL NULL
stage/sql/closing tables NULL NULL
stage/sql/Commit implicit NULL NULL
stage/sql/Query end NULL NULL
stage/sql/Starting cleanup NULL NULL
stage/sql/Freeing items NULL NULL
stage/sql/Reset for next command NULL NULL
......
......@@ -10,10 +10,10 @@ username event_name nesting_event_type
username event_name nesting_event_type
user1 stage/sql/starting STATEMENT
user1 stage/sql/starting STATEMENT
user1 stage/sql/starting STATEMENT
user1 stage/sql/Query end STATEMENT
user1 stage/sql/Commit STATEMENT
user1 stage/sql/closing tables STATEMENT
user1 stage/sql/Commit implicit STATEMENT
user1 stage/sql/Query end STATEMENT
user1 stage/sql/Starting cleanup STATEMENT
user1 stage/sql/Freeing items STATEMENT
user1 stage/sql/Reset for next command STATEMENT
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment