@@ -489,28 +489,27 @@ _local_root_write_probe_127() {
489489 # one of the 5 valid values (1044/1290/1142/0/other) — fail-closed
490490 # `probe_result_malformed` / `probe_result_malformed_errno` otherwise
491491 # (Jack 05:24 instrumentation 1).
492+ #
493+ # alpha.127+ fix: replaced mutating INSERT/DELETE probe with read-only
494+ # SHOW GRANTS check to eliminate orphan GTID writes on the demoted primary.
495+ # Mirrors the pattern used by verify_post_dcs_local_root_write_fenced().
492496 __PROBE_OUT=$( " ${MARIADB_CLIENT_BIN} " " -u${MARIADB_ROOT_USER} " " -p${MARIADB_ROOT_PASSWORD} " \
493497 --connect-timeout=" ${MARIADB_CONNECT_TIMEOUT_SECONDS} " \
494- -P3306 -h127.0.0.1 -N -s -e "
495- CREATE DATABASE IF NOT EXISTS kubeblocks;
496- CREATE TABLE IF NOT EXISTS ${SWITCHOVER_REMOTE_ROOT_PROBE_TABLE} (probe_id VARCHAR(128) PRIMARY KEY, check_ts BIGINT);
497- INSERT INTO ${SWITCHOVER_REMOTE_ROOT_PROBE_TABLE} (probe_id, check_ts)
498- VALUES ('switchover_local_root_probe', UNIX_TIMESTAMP());
499- DELETE FROM ${SWITCHOVER_REMOTE_ROOT_PROBE_TABLE} WHERE probe_id='switchover_local_root_probe';
500- " 2>&1 )
498+ -P3306 -h127.0.0.1 -N -s -e " SHOW GRANTS FOR '${MARIADB_ROOT_USER} '@'127.0.0.1';" 2>&1 )
501499 __PROBE_RC=$?
502- case " ${__PROBE_OUT} " in
503- * 1044* ) __PROBE_ERRNO=1044 ;;
504- * 1290* ) __PROBE_ERRNO=1290 ;;
505- * 1142* ) __PROBE_ERRNO=1142 ;; # Permission for table itself; accepted as fenced
506- * )
507- if [ " ${__PROBE_RC} " -eq 0 ]; then
508- __PROBE_ERRNO=0
509- else
510- __PROBE_ERRNO=other
511- fi
512- ;;
513- esac
500+ if [ " ${__PROBE_RC} " -ne 0 ]; then
501+ case " ${__PROBE_OUT} " in
502+ * 1044* ) __PROBE_ERRNO=1044 ;;
503+ * 1141* ) __PROBE_ERRNO=1044 ;;
504+ * ) __PROBE_ERRNO=other ;;
505+ esac
506+ return
507+ fi
508+ if echo " ${__PROBE_OUT} " | grep -qiE ' ALL PRIVILEGES|INSERT|UPDATE|DELETE|CREATE' ; then
509+ __PROBE_ERRNO=0
510+ else
511+ __PROBE_ERRNO=1290
512+ fi
514513}
515514
516515_filter_grants_keep_unmatched () {
@@ -686,7 +685,12 @@ _verify_host_is_fenced() {
686685 esac
687686 write_rc=" ${__PROBE_RC} "
688687 write_errno=" ${__PROBE_ERRNO} "
689- case " ${write_rc} " in
688+ case " ${write_errno} " in
689+ 1044|1290|1142)
690+ reason=" ok_by_local_probe:${write_errno} "
691+ log_switchover_info " remote_root_fence_verify host=${host} verified_host=${host} probe_host=${probe_host} grants_query_rc=0 ${grants_sha_field} grants_bypass=none grants_ignored_count=${__GRANTS_IGNORED_COUNT} write_probe_attempted=true write_probe_rc=${write_rc} write_probe_errno=${write_errno} reason=${reason} "
692+ return 0
693+ ;;
690694 0)
691695 reason=" writable_unexpected"
692696 log_switchover_error " remote_root_fence_verify host=${host} verified_host=${host} probe_host=${probe_host} grants_query_rc=0 ${grants_sha_field} grants_bypass=none grants_ignored_count=${__GRANTS_IGNORED_COUNT} write_probe_attempted=true write_probe_rc=${write_rc} write_probe_errno=${write_errno} reason=${reason} "
@@ -696,21 +700,12 @@ _verify_host_is_fenced() {
696700 return 1
697701 ;;
698702 * )
699- case " ${write_errno} " in
700- 1044|1290|1142)
701- reason=" ok_by_local_probe:${write_errno} "
702- log_switchover_info " remote_root_fence_verify host=${host} verified_host=${host} probe_host=${probe_host} grants_query_rc=0 ${grants_sha_field} grants_bypass=none grants_ignored_count=${__GRANTS_IGNORED_COUNT} write_probe_attempted=true write_probe_rc=${write_rc} write_probe_errno=${write_errno} reason=${reason} "
703- return 0
704- ;;
705- * )
706- reason=" probe_account_mismatch"
707- log_switchover_error " remote_root_fence_verify host=${host} verified_host=${host} probe_host=${probe_host} grants_query_rc=0 ${grants_sha_field} grants_bypass=none grants_ignored_count=${__GRANTS_IGNORED_COUNT} write_probe_attempted=true write_probe_rc=${write_rc} write_probe_errno=${write_errno} reason=${reason} "
708- log_switchover_error " remote_root_fence_verify host=${host} probe_dump_begin"
709- log_switchover_error " ${__PROBE_OUT} "
710- log_switchover_error " remote_root_fence_verify host=${host} probe_dump_end"
711- return 1
712- ;;
713- esac
703+ reason=" probe_account_mismatch"
704+ log_switchover_error " remote_root_fence_verify host=${host} verified_host=${host} probe_host=${probe_host} grants_query_rc=0 ${grants_sha_field} grants_bypass=none grants_ignored_count=${__GRANTS_IGNORED_COUNT} write_probe_attempted=true write_probe_rc=${write_rc} write_probe_errno=${write_errno} reason=${reason} "
705+ log_switchover_error " remote_root_fence_verify host=${host} probe_dump_begin"
706+ log_switchover_error " ${__PROBE_OUT} "
707+ log_switchover_error " remote_root_fence_verify host=${host} probe_dump_end"
708+ return 1
714709 ;;
715710 esac
716711 ;;
0 commit comments