Repository navigation
fix(service-datasource): a pool rebuild syncs the managed objects bound to the datasource (#27750) - #27874
Conversation
…nd to the datasource An admin update that rebuilds a runtime managed datasource's pool (a changed config, credential, schemaMode or active) went through reconnect, whose inner connect carried no objects, so the objects bound to it got no table on the new database. reconnect now takes the bound objects and forwards them to the rebuild's connect; registerPool and reregisterPool read them through one managed-only helper, so an external or validate-only datasource still never gets DDL. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1ZEsJ6Xne4sn5EXtT
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 2 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin db97f0ea77aef97c39ab6b5294d7b0ee56eef4f8 && git checkout db97f0ea77aef97c39ab6b5294d7b0ee56eef4f8
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c4cb5ec0c3936dd2c24ae2aa9a349449d8e33bef f0ef0a93476dc0a7c1f197d21c4b93a1d7ed56a9 && git checkout -B drift-repro c4cb5ec0c3936dd2c24ae2aa9a349449d8e33bef && git merge --no-ff f0ef0a93476dc0a7c1f197d21c4b93a1d7ed56a9
node scripts/docs-audit/affected-docs.mjs --json c4cb5ec0c3936dd2c24ae2aa9a349449d8e33bef
|
|
domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia Seat ACCEPT · PR #27874 · head
|
Requested by Elon · project thread
Fixes #27750
维护者速读
schemaMode: managed生效,external/validate-only依旧零 DDL;重建失败保留旧池时不同步。回滚 = revert 本 PR。datasource-admin-plugin.ts新的共用 helpermanagedObjectsBoundTo,以及reconnect新增的objects参数。pnpm --filter @objectstack/service-datasource exec vitest run src/__tests__/runtime-datasource-bound-object-storage.test.ts(新增 3 例;回退连接服务的改动后换库那例变红)。What changes
DatasourceConnectionService.reconnecttakes an optionalobjectslist and forwards it to both of its innerconnectcalls (the swap rebuild and the nothing-to-swap plain connect), so the connect's sync loop gives those objects their tables on the pool the new record opens. The kept-old-pool path syncs nothing.DatasourceAdminServicePlugin: the managed-only gate and bound-name list thatregisterPoolcomputed inline (service-datasource: a code object bound to a runtime (Setup-created) managed datasource never gets its table; registerPool connects with no objects, so reads 500 with 42P01 on create and after restart #27701) moved into one helper,managedObjectsBoundTo, which bothregisterPoolandreregisterPoolcall.reregisterPoolpasses the objects bound to the NEW record.schemaMode: external/validate-onlystill pass no objects, so they never get DDL.Why
#27701 synced bound managed objects when a runtime datasource's pool opens. An admin update that rebuilds the pool (
PATCH /api/v1/datasources/:name→updateDatasource→reregisterPool→reconnect) still passed none, so movingwarehouseto a new database leftwh_notewithout a table there and every read of it failed.Verification
mainfirst: inruntime-datasource-bound-object-storage.test.ts(real plugin, realObjectQL, SQLite), createwarehouseona.db, updateconfigtob.db→hasTable('wh_note')wasfalseonb.db. Green with the fix; ablating the connection-service change turns it red again, restoring turns it green.externalandvalidate-onlydatasources updated to a new database sync nothing and create no table.@objectstack/service-datasource: 63 files / 1031 tests pass;tsc --noEmitclean.dispatch-gates --ran: 60 derived families accounted for: 59 run green, 1 NOT MEASURED (check:dual-build-cjs-loads, exit 3, needs a whole-tree build; CI runs it).pnpm lintexit 0.check:commit-card-trailersgreen.Clause-②: no
Metadata-protocol: none
Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintpasses.main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Serial note: draft PR #27819 (#27746) edits both files; this PR keeps to
reconnect,registerPool/reregisterPooland the shared helper. The later lander mergesmain.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4d1ZEsJ6Xne4sn5EXtT