Skip to content

[Bug]: [4.2-dev] Named publication grants can block DROP ACCOUNT for an unrelated account #32986

Done

Description

@LeftHandCold

Branch and revision

4.2-dev at 53b3bc7c95c500de89a60001d947001c5d77d958, which includes #32937. Reproduced on two local CNs and one TN using the MySQL protocol.

Customer-visible behavior

An administrator changing a publication with a named recipient list can delay another administrator deleting an account outside the list. The second DDL waits on mo_catalog.mo_account until the publication transaction ends. The observed impact is DDL availability.

CN row-lock threshold Named recipients Does an unrelated DROP wait on mo_account?
16 1 Yes
16 17, with an unrelated ID between named IDs Yes
20,000 (default), same small catalog 1 or 17 No

Reproduction and expected result

  1. Configure the two test CNs with max-row-lock-count = 16. Create a source database, a publication and named recipient accounts. Create an additional account outside the publication.
  2. Hold the publication row in an explicit SQL transaction. On the other CN, run ALTER PUBLICATION ... ACCOUNT .... Wait until the ALTER is queued on mo_pubs, after it has resolved and locked its recipient set.
  3. Run DROP ACCOUNT for the unrelated account. It queues on mo_account until the publication row is released. With the pre-[4.2-dev] fix(frontend): prevent publication grants from recreating dropped subscriber IDs #32937 implementation, the unrelated DROP completes before release.

The unrelated DROP should complete independently. Dropping an actual recipient must serialize with the grant, and the deleted ID must have zero grants when both statements finish.

Cause and scope

#32937 correctly pins subscriber IDs to prevent a stale grant after deletion. The new locking SELECT can become table-level when the planner's estimated row count exceeds the threshold. The 4.2 single-account locking read and final catalog DELETE also have lock-planning paths that can widen the conflict. Production frequency at the default threshold on larger catalogs has not been measured. The ACCOUNT ALL/new-account race is tracked separately in #32941.

Activity

  1. added
    severity/s0
    and removed on Nov 20, 2026
  2. added a commit that references this issue on Nov 26, 2026
    3768534
  3. XuPeng-SH commented on Nov 26, 2026

    @XuPeng-SH
    Contributor

    #32987 已合入 4.2-dev(376853498154aa054bef72bf0878f71e4fc154f8),转 QA;此处不表示 QA 验收已通过。

    作者记录两个 CN + 一个 TN、真实 MySQL、锁阈值 16 下的对照:1/17 个命名接收方时,无关 DROP 可独立完成,命中接收方的 DROP 仍正确等待,删除后旧 ID 无 grant;旧生产文件恢复后宽用例在 30 秒截止处失败。作者另外验证了阈值 1 下 DROP/RESTORE、代理锁跨 CN、129 个接收方以及 optimistic 与回滚相关路径。本轮未独立执行。

    建议在合入版本确认上述并发时序、精确授权和同名重建不继承旧 grant;补默认阈值下的大 catalog 及混合负载,混合版本未测。ACCOUNT ALL 的独立新账号竞态仍由 #32941 跟踪,不纳入本单验收。

  4. Ariznawlll commented on Nov 29, 2026

    @Ariznawlll
    Collaborator

    结论

    测试不通过,失败范围限定为 4.2-dev、受限发布 CN、129 个命名接收方 的扩展场景。原问题的 1/17 接收方锁范围符合预期,但不能据此外推更宽的授权列表通过。本次不关闭、不转派。

    关键证据

    版本与隔离环境

    • 官方 4.2-dev:2bdc8daf527846ace58ab465c33127d02174e83b,包含修复 [4.2-dev] fix(pubsub): keep named publication grants on exact account rows #32987,merge SHA 376853498154aa054bef72bf0878f71e4fc154f8。
    • 两个独立、未修改产品代码的 mo-service 进程,单 TN/LogService,真实 MySQL 协议;两个 SQL 入口逐轮核对 git_version() 完整 SHA。
    • owner CN 保持默认锁配置;publisher CN 使用:
    [cn.lockservice]
    max-row-lock-count = 4
    max-fixed-slice-size = 16

    这是明确的低预算扩展,不能推断默认配置全部失败。所有账号、数据库、publication 使用本轮独立前缀,结束后已清理,两台自建 CN 进程已退出,未影响其他实例。

    原始锁范围和恢复控制

    以下已有集成根测试各执行 3 次,12/12 通过:

    TestDropAccountWithMinimumRowLockCount             3/3
    TestAlterPublicationExplicitTargetLockScope        3/3
    TestCreatePublicationBeyondLockSliceCapacity       3/3
    TestRestoreClusterRemotePublicationLocks           3/3
    

    覆盖:阈值 16 下 1/17 个接收方,ALTER 实际等在 mo_pubs 时,无关 DROP 独立完成;真正接收方 DROP 仍等待,删除后旧 ID 不残留授权;阈值 1 的删除和恢复;跨 CN 代理锁恢复。创建发布的官方根测试实际是 17 个接收方(16+1),不是 129 个。 该测试从两个锁键分段删除接收方后剩余授权精确为 15。上述集成 CN 是测试进程中的服务实例;下面 129 扩展则使用独立服务进程,不混写两种环境。

    129 个接收方复现步骤

    每轮执行:

    1. owner 创建空数据库与 129 个有效测试账号。publisher 有界等待,确认能查询到这 129 个已提交账号。
    2. 在受限 publisher 上执行一条完整 CREATE PUBLICATION ... DATABASE ... ACCOUNT ...,实际 ACCOUNT 列表包含全部 129 个名称,没有省略或分批。
    3. 记录错误,并从 owner 的新语句按本轮 publication 名精确查询 mo_catalog.mo_pubs 和 mo_catalog.mo_subs,检查失败后是否残留部分目录/授权。
    4. 保持数据库和 129 个账号不变,直接在默认配置 owner 上执行字节相同的 CREATE PUBLICATION SQL,检查有效授权数为 129。
    5. 删除本轮 publication、129 个账号及数据库,下一轮使用新前缀。
    轮次 受限 publisher 失败后 publication / grant 默认 owner 同 SQL 有效授权 清理
    1 20707 0 / 0 成功 129 完成
    2 20105 0 / 0 成功 129 完成
    3 20707 0 / 0 成功 129 完成

    错误原文:

    20707 row level lock is too large that need upgrade to table level lock
    20105 not supported: merge range lock not support with shared lock
    

    三轮都验证了失败原子性和默认配置成功对照。20707 与 20105 是两种实际观察,不能把它们合写成同一种已证明根因;20105 与已有 #33325 的共享范围锁症状相关,但本轮没有证明二者全部调用链完全相同,也没有重复提单。

    待解决点

    • 受限 publisher 上 129 接收方无法创建发布,仍需定位并修复;不能仅以 17 接收方测试通过结束验收。
    • 默认 20,000 阈值下的大 catalog、混合负载、混合版本尚未完成验收。本轮不将其标为失败或通过。
    • 4.2-dev 正常锁范围测试已追加现有 MOTR #353,提交 8fe4b0e 的 QA prepared metadata, role rules and scan acceptance job 在 release checkout 上执行四个根测试各三次,明确检查 PASS 次数。新增 job 的 CI 仍待完成。未把 129 失败写成预期成功的 golden,也未往 MatrixOne 主库提测试 PR。

    最终结论:测试不通过。未通过项:最新本轮 4.2-dev 在 max-row-lock-count=4 / max-fixed-slice-size=16 下,129 命名接收方创建发布连续三轮失败(20707、20105、20707);同 SQL 的默认 CN 对照均成功且授权精确,失败回滚无部分授权。原始小规模锁范围与恢复符合预期;大 catalog/混合负载及新增 CI 尚未完成。本次不关闭、不转派。

  5. Ariznawlll commented on Nov 30, 2026

    @Ariznawlll
    Collaborator

    原锁范围验收通过;129 接收方低预算反例已拆分

    原 Issue 的 1/17 个命名接收方、无关账号 DROP、真实接收方等待、旧 ID 授权清理及跨 CN 恢复控制,在 4.2-dev 2bdc8daf527846ace58ab465c33127d02174e83b 上四个原生根测试各 3 轮,合计 12/12 PASS。该范围与低预算 129 接收方扩展不同。

    MOTR 已由 PR 353 的提交 8fe4b0e5da55803d8d031d3c018fba7f62f245cb 接入 QA prepared metadata, role rules and scan acceptance,对四个根测试执行三轮硬计数;当前 PR head 29ec7643be4b62d9cc81d0d0f6e8850bf0f9b894 仍包含该提交。远端检查不以 pending 冒充成功。

    受限 publisher(max-row-lock-count=4、max-fixed-slice-size=16)上的 129 命名接收方失败已另提 #33506:#33506 。三轮 20707 / 20105 / 20707、失败原子性及默认 CN 对照均保留在新 Bug;没有录成 PASS golden,也不推断默认大 catalog/混合负载已经验收。

    因此关闭本 Issue 的原始锁范围;#33506 继续保持 OPEN。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions