---
id: ADR-ACC-CLS-004
title: The Period Lock Coordinates Close Work with Posting
product_area: accounting
module: close
revision: 1
status: proposed
design_intent: confirmed
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
decision: >-
  Changing close tasks use an exclusive target-period lock and postings use a
  shared lock, so their transactions are ordered on the same month.
constrains:
  - DOM-ACC-CLS-001
  - WF-ACC-CLS-006
  - WF-ACC-CLS-001
  - STATE-ACC-CLS-001
  - RESP-ACC
origin: >-
  fiscal-close design L8 (Rhythm 1.0 CLOSE-10 fixed);
  services-accounting:docs/milestones/plans/ACCT-M4-plan.md#4a row 74 (class A;
  plan approved 2026-10-21)
alternatives:
  - option: Use only optimistic period versions.
    why_not: >-
      A version check on the period does not alone order a separate posting
      transaction against a state change.
  - option: Read an application close flag before posting.
    why_not: >-
      A pretransaction flag check leaves a window for closure to commit before
      posting.
consequences:
  - A long revalidation can hold later postings until its transaction ends.
  - >-
    Different period rows have separate locks, but year triggers and shared
    monthly aging can still cause contention.
  - >-
    The shared protection affects Batch management, Reconciliation and credit
    reversal, so changes need those owners.
supersedes: []
evidence:
  - >-
    services-accounting at f47cb263:
    modules/fiscal-close/services/persistence/fiscal-periods.ts:lockPeriodForUpdate;
    modules/batches/services/posting-period-guard.ts;
    modules/reconciliation/services/persistence/fiscal-period-locks.ts.
---

# The Period Lock Coordinates Close Work with Posting

## Context

An unlocked state read can allow posting to pass a close that is protecting the month. Both paths need a shared serialization boundary.

## Decision

Take the period lock before evaluating whether that month accepts the operation. Exclusive changes wait for shared postings, and later postings observe the resulting state.

## Alternatives Considered

Use only optimistic period versions. A version check on the period does not alone order a separate posting transaction against a state change.

Read an application close flag before posting. A pretransaction flag check leaves a window for closure to commit before posting.

## Consequences

A long revalidation can hold later postings until its transaction ends. Different period rows have separate locks, but year triggers and shared monthly aging can still cause contention. The shared protection affects Batch management, Reconciliation and credit reversal, so changes need those owners.
