fix(datastore): commit a remote repository PATCH in one transaction

Summary

A PATCH on a remote repository that carries both a client column and a settings object writes the two halves in two transactions today: the metadata half through RepositoryStore.Update, the settings half through the family's composer. This MR moves the metadata patch into the composer's envelope, so both halves commit in one transaction.

What that changes:

  • A settings failure no longer leaves the metadata change committed with no update audit event. The whole PATCH rolls back.
  • A concurrent settings write can no longer land between the halves, so the row cannot hold one request's description with another's url.
  • The parent repositories row is written before the store takes the remote row, which keeps the delete's lock order.

The handler now calls the family seam once for a remote PATCH that carries settings; every other shape keeps the separate metadata write, since no other kind defines settings to write. The composer returns the parent row the metadata patch wrote, so the response serializes the committed state.

Found in review of !3092 (merged) (note 3977635736), where the same split also lets a combined PATCH record the wrong updater. The reviewer asked for the fix in its own MR that merges before !3092 (merged); !3092 (merged) rebases onto this one and drops its settingsUpdater() / settingsOutcome.attributed helpers.

Governing ADRs

  • ADR-009 (API design): conformant. The namespace-level PATCH contract is unchanged; the change makes one PATCH one transaction, the shape ADR-009 already states for the whole-list reconcile.

No ADR governs the transaction boundary itself.

Database review evidence

Not applicable, and no /db-review-prep run is needed: the MR adds no migration, and no changed hand-written non-test file carries a dispatch signature (instrumentQuery/instrumentExec/execAffected or a direct QueryContext/QueryRowContext/ExecContext call). queryRepositoriesUpdate is unchanged — the same SET list, the same WHERE; only the transaction it runs in changes.

Testing

  • internal/datastore: the composer suites for the three families pass with the new signature; TestRemoteRepositoryUpdaters_MetadataAndSettingsShareOneTransaction pins, per family, that the metadata patch commits with the settings write and that a refused settings write rolls it back; and TestNpmRemoteRepositoryUpdater_TakesTheDeletesLockOrder pins that the parent repositories row is taken before the store's remote-row lock, with the inverted order shown to deadlock against the delete and a settings-only write shown to take no parent lock.
  • internal/managementapi: the combined-body test runs for maven, docker, oci, and npm — docker and oci separately, because each is a distinct format reaching the shared container seam through its own row — and asserts that the family seam received the metadata patch and that the response serializes the row that write produced; a subtest pins the 500 when a metadata patch comes back with no row. TestContract_RepositoryWrites_DeclareTheUpstreamListRefusal pins the contract's one-transaction clause for a remote update as well as the virtual one.
  • go test ./..., go test -tags=integration for the two touched packages, and golangci-lint with and without the integration tag are clean.

No e2e scenario is added or affected: the change is internal transaction composition, and the one row touching this failure arm, e2e.npm.remote.url-change-evicts, already carries a caveat that its 503 clause cannot be forced from outside the service. No docs/user/ page is affected: the contract's request and response shapes are unchanged, and only its prose moved from two transactions to one.

Size

Past the 500-line review guideline: 1033 changed lines, 729 insertions and 304 deletions. Split by group — service code 376 (internal/datastore and internal/managementapi), tests 538, datastore docs 80, api/** 33, cmd/** stubs 6.

Splitting would not help. The change is one transaction composition, so the envelope, the three composers, and the handler move together; the test churn is the new signature threading through the existing suites plus the combined-path coverage, and it lands with the code it exercises. Part of the deletion count is comment churn the comment-caps gate forces on every block a diff touches, not removed behavior.

Related to #1608 (closed)

Edited by Moaz Khalifa

Merge request reports

Loading
Loading