AuthRecipe user lookups: run them on the transaction connection inside recipe flows
Part of PLAN-018, Unit 3 (core caller + in-memory impl). Full design: agent-plans PLAN-018.
Cross-repo dependency (wired by append-cross-deps.sh): needs the
PLAN-018 pi contract (listPrimaryUsersByEmail_Transaction /
listPrimaryUsersByPhoneNumber_Transaction) and the pg impl merged /
available. Build against the pi + pg bases (same branch name -> CI pairs).
Problem. AuthRecipe.getUserById (AuthRecipe.java:243),
getUsersByAccountInfo (:534), and loadAuthRecipeUserInfosByVariousIds
(:627) each borrow their own connection (-> Start.getPrimaryUser* ->
GeneralQueries.getPrimaryUserInfoForUserId(s)[_new]), and recipe code
calls them inside a startTransaction — e.g.
EmailPassword.consumeResetPasswordToken (EmailPassword.java:597, :633,
lambda :664), account-info lookups, and pagination.
Fix — keep the lookup in the SAME transaction (do NOT hoist). Thread
con so the read runs on the transaction's own connection:
- by-id path: use the existing
getPrimaryUserById_Transaction; - third-party account-info: use the existing
listPrimaryUsersByThirdPartyInfo_Transaction; - email / phone account-info: use the NEW
listPrimaryUsersByEmail_Transaction/listPrimaryUsersByPhoneNumber_Transactionfrom the pi ticket, and implement them in the in-memory (sqlite)Startmirroring the pg impl (this is the core-side half of the Unit-3 contract); - where an
AuthRecipehelper has no_Transactionform yet, CREATE it (e.g.AuthRecipe.getUserById_Transaction) rather than hoisting the read beforestartTransaction. loadAuthRecipeUserInfosByVariousIds: run the batch oncon(loop the single-id_Transactionread, or add a batch_Transactionif the query is a single round-trip) — no second connection either way.
Hoisting stays acceptable ONLY for a stable external->internal id translation that needs no transactional consistency with the body, never for a live user-record read.
Acceptance.
- No
AuthRecipelookup borrows a second pooled connection when called inside a recipe transaction. EmailPasswordTest,GetUserByAccountInfoTest,UserPaginationTest,RecoverAccountFlowTestpass with no nested-acquisition warning.- In-memory impls of the two new
_Transactionreads added and behaviour identical to the non-tx forms. - CHANGELOG line under the topmost unreleased section:
Fix: recipe user lookups ran on a second pooled connection inside transactions. - No version bump in the PR.
Plan: PLAN-018
Depends-on: supertokens/supertokens-plugin-interface#227
Depends-on: supertokens/supertokens-postgresql-plugin#413
Source: supertokens/supertokens-core