Files
orbit/internal/storage/mysql/migrations/000011_keyed_concurrency.up.sql

11 lines
1.0 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 显式资源键互斥:旧业务关联键语义不变;旧任务、会话与尝试默认不启用。
-- 不使用外键,归属、许可与单调序号在任务事务内维护。
ALTER TABLE pulse_tasks
ADD COLUMN concurrency_key VARCHAR(191) NULL COMMENT '显式互斥资源键,同命名空间跨队列共享;空表示不启用,不代替业务幂等',
ADD COLUMN concurrency_key_digest BINARY(32) NULL COMMENT '资源键精确 UTF-8 字节的域分隔 SHA-256;与资源键同时为空或有值',
ADD CONSTRAINT ck_task_concurrency_key CHECK ((concurrency_key IS NULL) = (concurrency_key_digest IS NULL));
ALTER TABLE pulse_attempts
ADD COLUMN concurrency_token BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '当前资源键的单调许可序号,零表示未启用;重连不变,新尝试递增,不可单独证明执行授权';
ALTER TABLE pulse_worker_sessions
ADD COLUMN concurrency_keys BOOLEAN NOT NULL DEFAULT FALSE COMMENT '是否明确支持资源键互斥与序号交付;未声明的旧 Worker 不领取带资源键任务';