Skip to content

PG19: thread real LWLock tranche names (drop citus-deferred placeholder) #8609

@ihalatci

Description

@ihalatci

Part of the PG19 support umbrella: #8597.

The build foundation (#8601) ships a temporary LWLockNewTrancheId()
shim in src/include/pg_version_compat.h that registers every Citus
tranche under the placeholder name "citus-deferred":

#define LWLockNewTrancheId() ((LWLockNewTrancheId) ("citus-deferred"))
#define LWLockRegisterTranche(id, name) ((void) 0)

PG19 internalised tranche registration: LWLockNewTrancheId() now takes
the tranche name directly and the public two-step
LWLockRegisterTranche(id, name) API was removed. The shim keeps Citus'
pre-PG19 two-step code compiling, but the real name (previously passed to
LWLockRegisterTranche) is dropped.

Why this needs a real fix

The tranche name is user-visible: it is the wait_event reported in
pg_stat_activity / pg_wait_events when a backend waits on the lock.
Under the shim, on PG19 every Citus lightweight-lock wait shows up as
citus-deferred regardless of subsystem — a diagnostics regression vs.
PG <= 18. It is not a correctness bug (ids stay unique; locking is
unaffected), hence its own low-priority follow-up rather than blocking
the build PR.

Scope

  • Pass the real tranche name to LWLockNewTrancheId(name) at each Citus
    call site; drop the now-redundant LWLockRegisterTranche() call.
  • Remove the "citus-deferred" placeholder macros from
    pg_version_compat.h.
  • Remove the pg_attribute_unused() markers the build foundation added
    to silence the now-unused trancheName (shardsplit_shared_memory.c,
    backend_data.c; audit for others).
  • Guard with #if PG_VERSION_NUM >= PG_VERSION_19; PG <= 18 two-step
    path unchanged.

Validation

PG17.10 / PG18.4 / PG19devel build green under -Werror; on PG19
pg_stat_activity.wait_event shows the correct per-subsystem name.

Plan detail: pg19-pr-plan/10-lwlock-tranche-cleanup.md (PR10).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions