Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,28 @@ Describe "cmpd-replication.yaml semisync startup recovery"
primary_reconcile_fast_path_requires_real_wildcard_listener() {
awk '
index($0, "reconcile_sql_listener_for_syncer_primary_once() {") { fn = 1 }
fn && index($0, ".primary-read-write-ready") && index($0, "mariadbd_listen_on_all_interfaces") { found = 1 }
fn && index($0, "runtime-primary-listener-reconcile-repair-begin") { exit(found ? 0 : 1) }
END { exit(found ? 0 : 1) }
fn && index($0, ".primary-read-write-ready") { primary_ready = 1 }
fn && index($0, "mariadbd_listen_on_all_interfaces") { listener = 1 }
fn && index($0, "runtime-primary-listener-reconcile-repair-begin") { exit(primary_ready && listener ? 0 : 1) }
END { exit(primary_ready && listener ? 0 : 1) }
' "$(template_file)"
}

primary_reconcile_logs_each_drift_predicate_before_repair() {
awk '
index($0, "reconcile_sql_listener_for_syncer_primary_once() {") { fn = 1 }
fn && index($0, "runtime-primary-listener-reconcile-repair-begin") {
log_line = NR
primary_ready = index($0, "primary_ready=")
remote_fence = index($0, "remote_root_fence=")
master_info = index($0, "master_info=")
listener = index($0, "listener_wildcard=")
}
fn && index($0, "expose_sql_listener_for_primary_role \"syncer-promoted-primary-existing-listener-no-writecheck\"") {
repair = NR
exit(log_line && primary_ready && remote_fence && master_info && listener && log_line < repair ? 0 : 1)
}
END { exit(log_line && primary_ready && remote_fence && master_info && listener && repair && log_line < repair ? 0 : 1) }
' "$(template_file)"
}

Expand Down Expand Up @@ -214,6 +233,11 @@ Describe "cmpd-replication.yaml semisync startup recovery"
The status should be success
End

It "records every primary publish predicate before a drift repair mutates markers"
When call primary_reconcile_logs_each_drift_predicate_before_repair
The status should be success
End

It "does not trust .sql-listener-ready without a real wildcard listener in syncer-secondary expose path"
When call secondary_expose_fast_path_requires_real_wildcard_listener
The status should be success
Expand Down
23 changes: 20 additions & 3 deletions addons/mariadb/scripts/replication-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@ local_has_user_tables() {
[ "${table_count}" -gt 0 ]
}
reconcile_sql_listener_for_syncer_primary_once() {
local now primary_sid role
local now primary_sid role primary_ready remote_root_fence master_info listener_wildcard
[ ! -f "${DATA_DIR}/.prestop-fence-started" ] || return 0
# alpha.80 v1 (Helen): the alpha.76 `switchover_fence_active_is_fresh`
# early-skip has been removed. alpha.79 v1 minimalist deleted the
Expand All @@ -2115,10 +2115,27 @@ reconcile_sql_listener_for_syncer_primary_once() {
if [ -f "${DATA_DIR}/.sql-listener-ready" ]; then
role="$(query_local_syncer_role || true)"
[ "${role}" = "primary" ] || return 0
if [ -f "${DATA_DIR}/.primary-read-write-ready" ] && [ ! -f "${DATA_DIR}/.remote-root-fence-role" ] && [ ! -f "${DATA_DIR}/master.info" ] && mariadbd_listen_on_all_interfaces; then
primary_ready=absent
remote_root_fence=absent
master_info=absent
listener_wildcard=absent
[ -f "${DATA_DIR}/.primary-read-write-ready" ] && primary_ready=present
[ -f "${DATA_DIR}/.remote-root-fence-role" ] && remote_root_fence=present
[ -f "${DATA_DIR}/master.info" ] && master_info=present
if mariadbd_listen_on_all_interfaces; then
listener_wildcard=present
fi
if [ "${primary_ready}" = "present" ] && \
[ "${remote_root_fence}" = "absent" ] && \
[ "${master_info}" = "absent" ] && \
[ "${listener_wildcard}" = "present" ]; then
return 0
fi
prestop_watchdog_log "runtime-primary-listener-reconcile-repair-begin reason=primary-role-state-drift role=${role}"
# Record the last pre-mutation snapshot. expose_sql_listener_for_primary_role
# starts by STOP/RESET and set_primary_read_write starts by retracting both
# ready markers, so a post-repair snapshot cannot identify the first broken
# predicate that caused the repair.
prestop_watchdog_log "runtime-primary-listener-reconcile-repair-begin reason=primary-role-state-drift role=${role} primary_ready=${primary_ready} remote_root_fence=${remote_root_fence} master_info=${master_info} listener_wildcard=${listener_wildcard}"
# Keep the historical suffix for log continuity. The r9 acceptance
# contract now uses the internal-admin, sql_log_bin=0 pre-open gate on all
# paths, so neither this repair loop nor a normal promotion emits the old
Expand Down
Loading