-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#23070] YSQL, ASH: Replace ysql_session_id with pid
Summary: yb_active_session_history had a field for the pg client session id, but it's not very useful, because it's an internal counter and the mapping between session id and pid is only present in the log files. This makes it hard for the user to correlate session id with an actual process. This diff replaces the session id with pid which is more readily available. The pid is of the process which is executing the query. For YSQL, it will be pid of the backend which is executing the query, for YCQL and background activities like flushes and compactions, it will be pid of the TServer. This diff also does some refactoring - Rename YbSetAshClientAddrAndPort to YbAshSetOneTimeMetadata - Move YbAshSetOneTimeMetadata to yb_ash.c Upgrade/Rollback safety: - Old node sends the PB to new node -- Old node sets the session_id, but the new node ignores it -- Old node cannot set the pid, so the new node takes the pid as 0, it's incorrect until the nodes are upgraded, and that's fine - New node sends the PB to old node -- New node sets the pid, the old node is not aware of it and ignores it -- New node doesn't set the session_id, old node takes the session id as 0, it's also incorrect and fine The reason that the incorrect values are fine - - The data in the circular buffer is only supposed to be there for a few hours, so it's fine to have incorrect value of one field during the upgrade 'ysql_yb_enable_ash' Will be made an AutoFlag at GA time Test Plan: ./yb_build.sh --java-test TestYsqlUpgrade ./yb_build.sh --java-test TestYbAsh#testYsqlPids Manually tested that the pids are correct ``` yugabyte=# select wait_event_component, pid, client_node_ip, count(*) from yb_active_session_history group by wait_event_component, pid, client_node_ip order by pid, wait_event_component; wait_event_component | pid | client_node_ip | count ----------------------+-------+-----------------+------- TServer | 78409 | | 872 TServer | 78623 | 127.0.0.1:57719 | 17 YSQL | 78623 | 127.0.0.1:57719 | 15 YSQL | 78667 | 127.0.0.1:57736 | 3 TServer | 78672 | 127.0.0.1:57740 | 57 YSQL | 78672 | 127.0.0.1:57740 | 348 TServer | 78673 | 127.0.0.1:57742 | 57 YSQL | 78673 | 127.0.0.1:57742 | 356 TServer | 78674 | 127.0.0.1:57744 | 59 YSQL | 78674 | 127.0.0.1:57744 | 352 TServer | 78675 | 127.0.0.1:57746 | 60 YSQL | 78675 | 127.0.0.1:57746 | 344 TServer | 78676 | 127.0.0.1:57748 | 52 YSQL | 78676 | 127.0.0.1:57748 | 349 TServer | 78677 | 127.0.0.1:57750 | 59 YSQL | 78677 | 127.0.0.1:57750 | 348 TServer | 78678 | 127.0.0.1:57752 | 50 YSQL | 78678 | 127.0.0.1:57752 | 344 TServer | 78679 | 127.0.0.1:57754 | 44 YSQL | 78679 | 127.0.0.1:57754 | 350 TServer | 78680 | 127.0.0.1:57756 | 54 YSQL | 78680 | 127.0.0.1:57756 | 348 TServer | 78681 | 127.0.0.1:57758 | 46 YSQL | 78681 | 127.0.0.1:57758 | 358 YSQL | 78693 | 127.0.0.1:57761 | 2 ``` Output of `ps -A | grep yugabyte` ``` 78672 ?? 0:06.75 postgres: yugabyte yugabyte 127.0.0.1(57740) idle 78673 ?? 0:06.71 postgres: yugabyte yugabyte 127.0.0.1(57742) INSERT 78674 ?? 0:06.64 postgres: yugabyte yugabyte 127.0.0.1(57744) UPDATE 78675 ?? 0:06.66 postgres: yugabyte yugabyte 127.0.0.1(57746) COMMIT 78676 ?? 0:06.55 postgres: yugabyte yugabyte 127.0.0.1(57748) UPDATE 78677 ?? 0:06.59 postgres: yugabyte yugabyte 127.0.0.1(57750) UPDATE 78678 ?? 0:06.58 postgres: yugabyte yugabyte 127.0.0.1(57752) COMMIT 78679 ?? 0:06.52 postgres: yugabyte yugabyte 127.0.0.1(57754) UPDATE 78680 ?? 0:06.56 postgres: yugabyte yugabyte 127.0.0.1(57756) UPDATE 78681 ?? 0:06.48 postgres: yugabyte yugabyte 127.0.0.1(57758) idle 78693 ?? 0:00.18 postgres: yugabyte yugabyte 127.0.0.1(57761) idle 78409 ttys006 4:08.89 /Users/asaha/code/yugabyte-db/build/latest/bin/yb-tserver ... ``` Reviewers: jason, amitanand Reviewed By: jason Subscribers: hsunder, yql, amitanand, hbhanawat, ybase Differential Revision: https://phorge.dev.yugabyte.com/D37081
- Loading branch information
1 parent
3cb8faf
commit a036313
Showing
23 changed files
with
202 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.