Skip to content

get_tablet_consensus_state_change function #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

get_tablet_consensus_state_change function #187

wants to merge 7 commits into from

Conversation

pgyogesh
Copy link
Contributor

profile.functions

  • Enhance: documentation for get_tablet_leader_change_time and get_count_per_minute functions
  • Enhance: get_node_info function documentation for clarity and usability
  • Add: function to parse and display tablet consensus state changes from logs

run_lnav

  • Add: Full command option, K8s Support

@pgyogesh
Copy link
Contributor Author

pgyogesh commented May 17, 2025

get_tablet_consensus_state_change function sample output:

$ get_tablet_consensus_state_change
get_tablet_consensus_state_change:shift:28: shift count must be <= $#
Usage: get_tablet_consensus_state_change <tablet_uuid> <logfile1> [logfile2 ...]
$ get_tablet_consensus_state_change b8b96049110044828c87960be970dab4 yugadata/node-2/logs/master/yb-master.INFO
| Time           |   Term | config_json (first is leader)                                                                                                                                                                             |
|----------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 05-17 21:39:11 |     10 | [{"uuid": "cf5686678ce54b9d9230a880fd578da9", "host": "127.0.0.3"}, {"uuid": "26971932da03492086f39884f03fc312", "host": "127.0.0.4"}, {"uuid": "f3026cd1176e45c38aa57ac6b5de4770", "host": "127.0.0.2"}] |
| 05-17 20:59:19 |      4 | [{"uuid": "f3026cd1176e45c38aa57ac6b5de4770", "host": "127.0.0.2"}, {"uuid": "26971932da03492086f39884f03fc312", "host": "127.0.0.4"}, {"uuid": "cf5686678ce54b9d9230a880fd578da9", "host": "127.0.0.3"}] |
| 05-17 20:27:58 |      3 | [{"uuid": "26971932da03492086f39884f03fc312", "host": "127.0.0.4"}, {"uuid": "f3026cd1176e45c38aa57ac6b5de4770", "host": "127.0.0.2"}, {"uuid": "cf5686678ce54b9d9230a880fd578da9", "host": "127.0.0.3"}] |
| 05-17 20:27:02 |      2 | [{"uuid": "f3026cd1176e45c38aa57ac6b5de4770", "host": "127.0.0.2"}, {"uuid": "26971932da03492086f39884f03fc312", "host": "127.0.0.4"}, {"uuid": "cf5686678ce54b9d9230a880fd578da9", "host": "127.0.0.3"}] |
| 05-17 20:25:11 |      1 | [{"uuid": "cf5686678ce54b9d9230a880fd578da9", "host": "127.0.0.3"}, {"uuid": "26971932da03492086f39884f03fc312", "host": "127.0.0.4"}, {"uuid": "f3026cd1176e45c38aa57ac6b5de4770", "host": "127.0.0.2"}] |

⚠️  Missing term(s): 5, 6, 7, 8, 9

Note: Missing terms could be due to master logs not being available when leader election for these terms happened.
Ensure you are checking the logs of all N masters, where N is the replication factor.

@pgyogesh pgyogesh changed the title Yogesh get_tablet_consensus_state_change function May 17, 2025
@pgyogesh
Copy link
Contributor Author

Sample output after few enhancements

$ get_tablet_consensus_state_change
Usage: get_tablet_consensus_state_change <tablet_uuid>
$ get_tablet_consensus_state_change e4b1f166853f420e9df9b4a96169af2f
| Time           |   Term | config_json (first is leader)                                                                                                                                                                             |
|----------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 05-18 13:25:27 |      6 | [{"uuid": "09f7a8473a014cb6a5233d432620527c", "host": "127.0.0.2"}, {"uuid": "0104c4d1d5354ba2b109faa5fc27a4c2", "host": "127.0.0.4"}, {"uuid": "5cf0c168ea4b4f88a513ee6e2e5f3d15", "host": "127.0.0.3"}] |
| 05-18 13:25:25 |      5 | [{"uuid": "0104c4d1d5354ba2b109faa5fc27a4c2", "host": "127.0.0.4"}, {"uuid": "09f7a8473a014cb6a5233d432620527c", "host": "127.0.0.2"}, {"uuid": "5cf0c168ea4b4f88a513ee6e2e5f3d15", "host": "127.0.0.3"}] |
| 05-18 13:25:24 |      4 | [{"uuid": "09f7a8473a014cb6a5233d432620527c", "host": "127.0.0.2"}, {"uuid": "0104c4d1d5354ba2b109faa5fc27a4c2", "host": "127.0.0.4"}, {"uuid": "5cf0c168ea4b4f88a513ee6e2e5f3d15", "host": "127.0.0.3"}] |
| 05-18 13:25:02 |      3 | [{"uuid": "5cf0c168ea4b4f88a513ee6e2e5f3d15", "host": "127.0.0.3"}, {"uuid": "0104c4d1d5354ba2b109faa5fc27a4c2", "host": "127.0.0.4"}, {"uuid": "09f7a8473a014cb6a5233d432620527c", "host": "127.0.0.2"}] |
| 05-18 12:58:04 |      2 | [{"uuid": "09f7a8473a014cb6a5233d432620527c", "host": "127.0.0.2"}, {"uuid": "0104c4d1d5354ba2b109faa5fc27a4c2", "host": "127.0.0.4"}, {"uuid": "5cf0c168ea4b4f88a513ee6e2e5f3d15", "host": "127.0.0.3"}] |
| 05-18 12:56:56 |      1 | [{"uuid": "5cf0c168ea4b4f88a513ee6e2e5f3d15", "host": "127.0.0.3"}, {"uuid": "0104c4d1d5354ba2b109faa5fc27a4c2", "host": "127.0.0.4"}, {"uuid": "09f7a8473a014cb6a5233d432620527c", "host": "127.0.0.2"}] |
Result saved to tablet_consensus_state_change_e4b1f166853f420e9df9b4a96169af2f_2025-05-18_133044.log

@pgyogesh
Copy link
Contributor Author

@eugeneckim / @ionthegeek Can you review and approve this change?

The function get_tablet_consensus_state_change will not just list the consensus changes but it can also help in selecting logs. For example, Let's we have an issue with specific tablet. We can run this function and get the list of its peers and check the logs only from these peers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants