Description:
## Problem
Replica applier threads (SQL_thread and MTS workers) override the session lock_wait_timeout to `LONG_TIMEOUT`(= 31536000 seconds = 1 year).
When the applier hits an MDL conflict on the replica (for example, a long analytic SELECT), three problems arise.
1. STOP REPLICA and SHUTDOWN cannot proceed because of waiting applier thread.
2. SHOW REPLICA STATUS misreports state. Replica_SQL_Running stays "Yes", but applier thread processes nothing, and Seconds_Behind_Source grows without bound.
3. `replica_transaction_retries` is effectively ineffective, because LONG_TIMEOUT is hardcoded to one year.
## Proposal
Add a new GLOBAL system variable `replica_lock_wait_timeout`, and replace the hardcoded assignment in init_replica_thread() with this variable.
Setting defaults to `LONG_TIMEOUT` preserve existing behavior exactly. Operators who want bounded applier waits by `SET GLOBAL replica_lock_wait_timeout=60` (for
example) and STOP REPLICA SQL_THREAD; START REPLICA SQL_THREAD;
to pick up the change.
## Related bug report
[Bug #103708](https://bugs.mysql.com/bug.php?id=103708) (Verified, open): shutdown of replica takes too long if MTS worker waits for MDL lock. Same root cause; this FR enables the workaround at runtime, not only at shutdown.
How to repeat:
## Preparation
-- source node --
CREATE DATABASE IF NOT EXISTS test;
USE test;
CREATE TABLE t1 (id INT PRIMARY KEY, c1 INT);
INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
-- replica node --
USE test;
BEGIN;
SELECT * FROM t1 ...; -- analytical query, holds MDL_SHARED_READ on t1
-- (Do not COMMIT or ROLLBACK)
-- source node --
ALTER TABLE t1 ADD COLUMN c2 INT;
-- (Source side completes (no conflict on source))
-- replica node --
(observe that the applier is blocked and wait until analytical query which conflicts DDL ends)
Suggested fix:
Add a new GLOBAL system variable `replica_lock_wait_timeout`, and replace the hardcoded assignment in init_replica_thread() with this variable.
(I'll attatch a patch to add this variable)