Some HTTP handlers still open their own transaction or run hand-written SQL #221
Open
opened 2026-10-16 01:51:32 +00:00 by cgalo5758
·
0 comments
Labels
Clear labels
accessibility
area/billing
area/catalog
area/discourse
area/domains
area/entitlements
area/fedwiki
area/identity
area/integrations
area/licensing
area/member-ui
area/meta
area/operator-ui
area/ops
area/testing
duplicate
good-first-issue
invalid
privacy
security
upstream
wontfix
A barrier for people using assistive technology or a keyboard alone.
The Stripe mirror, checkout, subscriptions, invoices, fulfillment.
Products, prices, plan ladders, purchasability.
The Discourse integration.
The domains registry, claims, placements, the certificate ask.
Entitlement sets, rules, grants, pools, provisioning.
The Federated Wiki integration and farm sync.
Sign-in, sessions, persons, organizations, workspaces, roles.
The provider registry, outbox and webhooks in general.
Licenses, the contributor agreement, SPDX headers.
Member pages.
The repository itself, its contributing guide, CI, the tracker and the workflow.
Operator pages, forms, lists, the design system.
Deployment, configuration, migrations, workflows, instance settings.
The test stack, screens, lint, walkthroughs.
Closed because another issue already covers it.
Small, self-contained, and explained enough to be a first contribution.
Closed because it is not a ticket for this repository.
Touches what a person's data reveals.
Touches authentication, authorization, secrets or data exposure.
Waits on another repository or project before it can move.
Closed because it will not be done, with the reason in the last comment.
kind
bug
The software does something other than what it promises; closed when it again does what it promises.
kind
debt
Code, tests or tooling to clean up with nothing visible changing; closed when they are cleaner.
kind
design
A question to settle before work can be defined; closed when the decision is written down.
kind
docs
Documentation that is wrong or missing; closed when it says the right thing.
kind
enhancement
Something the software does not do yet; closed when it does.
priority
critical
Blocks the active milestone or harms members now.
priority
high
Next in line inside the active milestone.
priority
low
Inside the active milestone, when nothing else is left.
priority
medium
Inside the active milestone, after the high ones.
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: wiki-cafe/member-console#221
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What a contributor runs into
A handler in this console parses the request, calls one function, maps that function's errors to a status and a sentence, and renders. It opens no transaction, takes no lock and runs no SQL. The function it calls lives in the package that owns the tables, opens its transaction through
db.InTxordb.Begin(internal/db/tx.go), and reads and writes through that package's sqlc queries.IssueGrant(internal/server/operator_enrollment.go:609) callingentitlements.ConferGrant, and the tier handlers calling the acts ininternal/entitlements/ladder_acts.go, have that shape.Six handlers in
internal/serverstill open their transaction themselves, and six functions there send SQL written as a string in the handler file. The Stripe webhook receiver does the same. A contributor who copies the nearest handler can copy either pattern, and nothing refuses it.Why it costs
ManageGrantandRevokeGrantAndTransitionopen theirs withentitlements.BeginMaterializing, which takes the shared materialization lock first. Each refusal renders the whole organization page while that lock is held, so a rule change that starts meanwhile waits for the page, up to its five-second lock timeout.core.webhook_eventshas no sqlc query in any package, so every statement against it is hand-written, including the five listed here.ownedResourceKeys(internal/server/operator_pages.go:337) says the entitlementsResourceKeymodel has no provider column; the model carriesProvider(internal/entitlements/models.go:193).Where
Transactions opened in a handler:
internal/server/operator_enrollment.go:838,ManageGrant:entitlements.BeginMaterializing, thenentitlements.ManageGrantTx, commit at:928.internal/server/operator_enrollment.go:1043,RevokeGrantAndTransition: the same shape aroundentitlements.RevokeGrantTx, commit at:1075.internal/server/operator_billing.go:1287,MakeDefaultPrice:BeginTx, thenClearDefaultPriceandMarkDefaultPrice.internal/server/operator_topology.go:382,ReorderPlanLadders:BeginTx, thenSetPlanLadderSortOrderfor each moved ladder.internal/server/workspace_partials.go:121,CreateWorkspace:BeginTx, thenprovisioning.CreateWorkspaceWithPrimaryAssignment.internal/server/operator_products.go:304,createProductWithSetunderCreateProduct:db.InTxaroundCreateEntitlementSetandCreateProduct.SQL written in the handler file:
internal/server/operator_billing.go:259,latestProcessedWebhookEventAt:core.webhook_events.internal/server/operator_integrations_stripe.go:156,loadInboundEvents, and:207,loadInboundDeadLetterEntries:core.webhook_events.internal/server/operator_integrations_stripe.go:318,loadDeadLetterEntries:core.outbox, whose queries are ininternal/integration/queries/outbox.sql.internal/server/operator_integrations_stripe.go:458,countMappedStripeIDs:stripe.product_mappingsandstripe.price_mappings, whose queries are ininternal/integrations/stripe/store/queries/.internal/server/operator_pages.go:343,ownedResourceKeys:core.resource_keys, whose queries are ininternal/entitlements/queries/resource_keys.sql.internal/integrations/stripe/web/webhook.go:219and:251, in the Stripe receiver'sServeHTTP: the insert and the duplicate read oncore.webhook_events.Done when
db.InTxordb.Beginwith the kind it needs and returns typed errors, and its handler renders after it returns.ManageGrantTx,RevokeGrantTxandCreateWorkspaceWithPrimaryAssignmentkeep their transaction-taking form for the callers that already hold one.core.webhook_eventsgets one owning package, and the Stripe receiver uses its queries too.internal/servercallsBeginTx,db.InTx,db.Begin,entitlements.BeginMaterializing,QueryContext,QueryRowContextorExecContext, and a forbidigo rule in.golangci.ymlkeeps it that way.Related: #186 lists the
BeginTxcalls inMakeDefaultPrice,ReorderPlanLaddersandCreateWorkspaceamong the transactions opened by hand; opening the moved transactions throughdb.InTxsettles those three entries there. #174 removes the FedWiki and Discourse handlers that do the same (internal/integrations/fedwiki/web/site_actions.go:735and:794,internal/integrations/fedwiki/web/partials.go:411,internal/integrations/discourse/web/webhook.go:125and:151). #207 covers what these reads show when they fail. #121 covers which file a handler belongs in.