{
  "synthetic": true,
  "execution": "Teaching record only; no live integration tested",
  "slug": "waitlist-priority-versus-worker-locks",
  "group": "commerce-operations",
  "title": [
    "A waitlist needs a priority policy beyond worker locks",
    "候补名单：进程锁之外，还要有明确优先规则"
  ],
  "intro": [
    "A workshop website can avoid duplicate processing and still invite the wrong person from its waitlist. Database locking answers which worker may act; the business must separately approve eligibility, priority and how long an invitation lasts. Commission a decision log before automatic promotion.",
    "课程网站即使避免重复处理，也可能邀请错候补人员。数据库锁回答哪个进程可操作；业务仍须批准资格、优先顺序及邀请有效期。自动递补前，应先验收决定记录。"
  ],
  "facts": [
    [
      "PostgreSQL18 documents that SKIP LOCKED skips rows that cannot be locked immediately and can be useful for queue-like tables. It produces an inconsistent view and does not by itself establish business fairness or FIFO selection.",
      "PostgreSQL18说明SKIP LOCKED会跳过不能立即锁定的行，可用于队列表；它提供不一致视图，本身不保证业务公平或先进先出。",
      "https://www.postgresql.org/docs/18/sql-select.html#SQL-FOR-UPDATE-SHARE"
    ]
  ],
  "example": [
    [
      [
        "One place; W1 joined09:00, eligible, opted in",
        "Declared policy: oldest eligible first",
        "Propose invitation to W1; not a confirmed booking"
      ],
      [
        "一个名额；W1于09:00加入，有资格且同意联系",
        "声明规则：最早合格者优先",
        "拟邀请W1，不等于预约确认"
      ]
    ],
    [
      [
        "W2 joined09:01; W1 temporarily worker-locked",
        "Worker uses SKIP LOCKED",
        "May observe W2; do not claim strict FIFO fairness"
      ],
      [
        "W2于09:01加入，W1被其他进程暂锁",
        "进程使用SKIP LOCKED",
        "可能读到W2，不能声称严格先进先出"
      ]
    ],
    [
      [
        "W1 invitation expiry10:00; now10:00",
        "This policy uses half-open validity",
        "Invitation expired; resolve before another promise"
      ],
      [
        "W1邀请10:00截止，现在10:00",
        "本规则采用截止时即失效",
        "邀请过期，先核对再承诺下一人"
      ]
    ],
    [
      [
        "W3 earliest but consent withdrawn",
        "Eligibility includes current permission",
        "Exclude W3 without contacting them"
      ],
      [
        "W3最早但已撤回联系同意",
        "资格包含当前许可",
        "排除W3，不联系对方"
      ]
    ]
  ],
  "steps": [
    [
      "Write the merchant-approved eligibility and priority rules, including withdrawn requests, ties and invitation expiry. Keep waitlist entry, invitation and confirmed booking separate.",
      "写明资格与优先规则，包括撤回、同时间及邀请到期；排队、邀请、确认预约分状态。"
    ],
    [
      "Replay the four records with a fixed test clock and two simulated workers. Require a log that explains why a person was selected or skipped.",
      "用固定时钟及两个模拟进程重放，记录为何选中或跳过某人。"
    ],
    [
      "Ask the implementer to demonstrate atomic capacity and invitation updates in an authorised test database. A sequential teaching log cannot prove concurrent correctness.",
      "要求实施方在获准测试数据库证明名额与邀请的原子更新；顺序教学记录不能证明并发正确。"
    ]
  ],
  "result": [
    "The first row approves only a proposed invitation. The locked-row example exposes a trade-off between worker throughput and strict business ordering. A system promising FIFO must demonstrate that policy explicitly, rather than cite a database option as its fairness evidence.",
    "首行只批准拟邀请。锁定行例揭示处理效率与严格顺序的取舍；承诺先进先出的系统必须证明该规则，不能以数据库选项代替。"
  ],
  "accept": [
    "Require explainable selection, no contact after withdrawal and no duplicate capacity promise under the approved concurrency tests.",
    "须选择可解释、撤回后不联系，并按批准并发测试避免重复承诺名额。"
  ],
  "limit": [
    "Synthetic people IDs and timing only. No attendee data, messages, real database queries, invitation or booking are created. This is not a complete scheduling engine.",
    "仅合成人员ID及时间，未读取参加者资料、发消息、查真实数据库、邀请或预约，也不是完整排程系统。"
  ],
  "oldLinks": []
}
