Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#18124] YSQL: make backends catalog version check upgrade-aware
Summary: Commit a1729c3 titled [#7376] ysql: fix state waits for online CREATE INDEX fixes CREATE INDEX state waits by adding WaitForBackendsCatalogVersion RPCs that fan out to tservers. It was not made rolling upgrade safe because DDLs are normally not supported during rolling upgrade. However, it is nice to still make a best effort to support the case, so handle it by ignoring the version check when the following two cases happen: - tservers are on old version: then they don't recognize the RPC. - YSQL upgrade did not run: if the src->dst src version is too old, it may not have the column "catalog_version" in pg_stat_activity. One minor difference is that, previously, it had a hard-coded 1s sleep. With the ignore logic, it may delay for less than that, but this likely won't be the case in a real-world setting where RPC latencies are decently high. Also add a missing space in an existing log message. Jira: DB-7155 Test Plan: 1. Do release build: ./yb_build.sh release. 1. Get an old release: curl "https://downloads.yugabyte.com/releases/2.16.4.0/yugabyte-2.16.4.0-b32-linux-x86_64.tar.gz" \ | tar xzv -C /tmp 1. Run the following script passing in that dir: ./script.sh /tmp/yugabyte-2.16.4.0 where #!/usr/bin/env bash # script.sh set -euxo pipefail if [ $# -ne 1 ]; then echo "Missing argument path to old release" >&2 exit 1 fi OLD_RELEASE_PATH=$1 "$OLD_RELEASE_PATH"/bin/yb-ctl destroy "$OLD_RELEASE_PATH"/bin/yb-ctl create --rf 3 "$OLD_RELEASE_PATH"/bin/ysqlsh -c 'CREATE TABLE t (i int)' YB_ADMIN_CMD_PREFIX=( build/latest/bin/yb-admin "--master_addresses=127.0.0.1,127.0.0.2,127.0.0.3" ) function test_case() { master_idx=$1 num_tservers_not_migrated=$2 num_tservers_old_version=$3 # Use fresh master for each test case in order to get a fresh set of logs. master_uuid=$("${YB_ADMIN_CMD_PREFIX[@]}" list_all_masters \ | sed "$((master_idx + 1))q;d" \ | awk '{print$1}') "${YB_ADMIN_CMD_PREFIX[@]}" master_leader_stepdown "$master_uuid" "${YB_ADMIN_CMD_PREFIX[@]}" list_all_masters \ | sed "$((master_idx + 1))q;d" \ | grep -q LEADER sleep 5 bin/ysqlsh -c 'CREATE INDEX ON t (i)' # 2 backends catalog version requests per CREATE INDEX, hence x2. log_file=~/yugabyte-data/node-"$master_idx"/disk-1/yb-data/master/logs/yb-master.INFO test "$(grep -c "but ignoring for backwards compatibility" "$log_file")" \ -eq $((num_tservers_not_migrated * 2)) test "$(grep -c "is on an older version" "$log_file")" \ -eq $((num_tservers_old_version * 2)) } bin/yb-ctl restart_node 1 --master bin/yb-ctl restart_node 2 --master bin/yb-ctl restart_node 3 --master # Test case: not all tservers upgraded. # - 1 tserver: up-to-date version, but YSQL upgrade did not happen. # - 2 tservers: old version. bin/yb-ctl restart_node 1 test_case 1 1 2 # Test case: all tservers upgraded, but ysql upgrade not run. bin/yb-ctl restart_node 2 bin/yb-ctl restart_node 3 test_case 2 3 0 # Test case: everything upgraded. "${YB_ADMIN_CMD_PREFIX[@]}" upgrade_ysql test_case 3 0 0 Close: #18124 Reviewers: skedia Reviewed By: skedia Subscribers: ybase, bogdan Differential Revision: https://phorge.dev.yugabyte.com/D26727
- Loading branch information