Skip to content

Add a read-only report of custodial take-ownership marker state - #599

Merged
tompscanlan merged 1 commit into
mainfrom
atproto-custodial-marker-counts
Aug 16, 2026
Merged

tompscanlan merged 1 commit into
mainfrom
atproto-custodial-marker-counts

Conversation

@tompscanlan

Copy link
Copy Markdown
Contributor

What this adds

scripts/atproto-custodial-marker-counts.sql, a read only report of how many custodial AT Protocol identities sit in each take-ownership marker state, broken down per tenant schema.

Why

When a custodial user resets their PDS password, the API has to end custody and clear the stored credential in the same request. If it does not, the API keeps a password that no longer works and that user's events stop publishing. The marker column records how far a reset got. This script makes a stuck state visible without anyone having to write the query again.

A non-zero confirmed count means the automatic repair is not draining. That is worth raising on its own.

How to run it

psql -U <user> -d <database> -f scripts/atproto-custodial-marker-counts.sql

It discovers tenant schemas itself, so it does not need editing when a tenant is added. On a database with no tenant schemas it prints the header and stops.

Safety

  • Every statement is a SELECT. There is no UPDATE, INSERT or DELETE.
  • pdsCredentials holds an encrypted password. It is only tested for null. Its value is never selected.
  • No login is attempted against any account.

One thing to read carefully

The count of identities with no marker is not a count of broken accounts. The column was added after the password reset fix shipped, and only the new code path writes it, so every identity that predates the fix has no marker whether it is healthy or not. A healthy custodial row and a stranded one are identical in this schema. The only thing that tells them apart is whether the stored credential still works at the PDS, and that is not recorded. The script comments say this too, so the number is hard to misread later.

When a custodial user resets their PDS password, the API has to end
custody and clear the stored credential in the same request. This
script reports how many custodial identities sit in each marker state,
per tenant schema, so a stuck state is visible.

The script is read only. It finds tenant schemas itself, so it does not
need editing when a tenant is added. The encrypted credential column is
only tested for null, never selected.

A count of identities with no marker is not a count of broken accounts.
The column was added after the fix shipped, and only the new code path
writes it, so every identity that predates the fix has no marker whether
it is healthy or not.
@tompscanlan
tompscanlan merged commit 3108078 into main Aug 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant