You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deleting a tenant in the multi-tenant plugin using the Postgres adapter fails. A Drizzle/Postgres error aborts the transaction.
{
"type": "DrizzleQueryError",
"message": "Failed query: delete from \"payload_preferences\" where \"payload_preferences\".\"key\" in ($1)\nparams: collection-tenants-3: current transaction is aborted, commands ignored until end of transaction block"
}
I'm getting the same error in a "magazines" collection. I try to delete an entry from the payloadui and get this log:
[21:03:48] ERROR: Failed query: deletefrom"payload_preferences"where"payload_preferences"."key"in($1)
params: collection-magazines-931
err: {"type": "d","message": "Failed query: delete from \"payload_preferences\" where \"payload_preferences\".\"key\" in ($1)\nparams: collection-magazines-931: current transaction is aborted, commands ignored until end of transaction block","stack":
Error: Failedquery: deletefrom"payload_preferences"where"payload_preferences"."key"in($1)params: collection-magazines-931atp.queryWithCache(/app/node_modules/.pnpm/drizzle-orm%400.44.7_%40opentelemetry%2Bapi%401.9.0_%40types%2Bpg%408.10.2_pg%408.16.3/node_modules/src/pg-core/session.ts:73:11)atprocessTicksAndRejections(node:internal/process/task_queues:105:5)atObject.t[asdeleteWhere](/app/node_modules/.pnpm/%40payloadcms%2Bdrizzle%403.68.0_%40opentelemetry%2Bapi%401.9.0_%40types%2Bpg%408.10.2_payload%403.68.0_graphql%401_hivkjcirgcunb4ymm4nslyycxy/node_modules/%40payloadcms/drizzle/src/postgres/deleteWhere.ts:5:39)atObject.s[asdeleteMany](/app/node_modules/.pnpm/%40payloadcms%2Bdrizzle%403.68.0_%40opentelemetry%2Bapi%401.9.0_%40types%2Bpg%408.10.2_payload%403.68.0_graphql%401_hivkjcirgcunb4ymm4nslyycxy/node_modules/%40payloadcms/drizzle/src/deleteMany.ts:59:3)ata_(/app/node_modules/.pnpm/payload%403.68.0_graphql%4016.12.0_typescript%405.9.3/node_modules/payload/dist/preferences/deleteUserPreferences.js:32:9)ataW(/app/node_modules/.pnpm/payload%403.68.0_graphql%4016.12.0_typescript%405.9.3/node_modules/payload/dist/collections/operations/delete.js:214:9)atty(/app/node_modules/.pnpm/payload%403.68.0_graphql%4016.12.0_typescript%405.9.3/node_modules/payload/dist/collections/endpoints/delete.js:10:20)atg(/app/node_modules/.pnpm/payload%403.68.0_graphql%4016.12.0_typescript%405.9.3/node_modules/payload/dist/utilities/handleEndpoints.js:191:26)at/app/node_modules/.pnpm/path-to-regexp%406.3.0/node_modules/path-to-regexp/src/index.ts:36:6atrU.do(/app/node_modules/.pnpm/next@16.1.0-canary.16_@babel+core@7.28.5_@opentelemetry+api@1.9.0_react-dom@19.2.1_react@19.2_zrylbxjvgq6pkukrnubleobvwe/node_modules/next/dist/compiled/next-server/webpack:/next/src/server/route-modules/app-route/module.ts:600:15)causedby: error: currenttransactionisaborted,commandsignoreduntilendoftransactionblockat/app/node_modules/.pnpm/pg@8.16.3/node_modules/pg/lib/client.js:545:17atprocessTicksAndRejections(node:internal/process/task_queues:105:5)at/app/node_modules/.pnpm/drizzle-orm%400.44.7_%40opentelemetry%2Bapi%401.9.0_%40types%2Bpg%408.10.2_pg%408.16.3/node_modules/src/node-postgres/session.ts:149:14atp.queryWithCache(/app/node_modules/.pnpm/drizzle-orm%400.44.7_%40opentelemetry%2Bapi%401.9.0_%40types%2Bpg%408.10.2_pg%408.16.3/node_modules/src/pg-core/session.ts:71:12)atObject.t[asdeleteWhere](/app/node_modules/.pnpm/%40payloadcms%2Bdrizzle%403.68.0_%40opentelemetry%2Bapi%401.9.0_%40types%2Bpg%408.10.2_payload%403.68.0_graphql%401_hivkjcirgcunb4ymm4nslyycxy/node_modules/%40payloadcms/drizzle/src/postgres/deleteWhere.ts:5:39)atObject.s[asdeleteMany](/app/node_modules/.pnpm/%40payloadcms%2Bdrizzle%403.68.0_%40opentelemetry%2Bapi%401.9.0_%40types%2Bpg%408.10.2_payload%403.68.0_graphql%401_hivkjcirgcunb4ymm4nslyycxy/node_modules/%40payloadcms/drizzle/src/deleteMany.ts:59:3)ata_(/app/node_modules/.pnpm/payload%403.68.0_graphql%4016.12.0_typescript%405.9.3/node_modules/payload/dist/preferences/deleteUserPreferences.js:32:9)ataW(/app/node_modules/.pnpm/payload%403.68.0_graphql%4016.12.0_typescript%405.9.3/node_modules/payload/dist/collections/operations/delete.js:214:9)atty(/app/node_modules/.pnpm/payload%403.68.0_graphql%4016.12.0_typescript%405.9.3/node_modules/payload/dist/collections/endpoints/delete.js:10:20)atg(/app/node_modules/.pnpm/payload%403.68.0_graphql%4016.12.0_typescript%405.9.3/node_modules/payload/dist/utilities/handleEndpoints.js:191:26)"query": "delete from \"payload_preferences\" where \"payload_preferences\".\"key\" in ($1)","params": ["collection-magazines-931"]}
we are heavily using the api for other tasks (inserting/updating), do you think an error that was not rolled back in another update is causing this?
I have the same issue trying to delete a particular file in the media collection. I was able to delete others fine, but not this specific file. it doesn't seem to have anything extraordinarily different in the db compared to other files.
Running Payload 3.70.0 in dev mode on localhost (app directory paths below adjusted to obfuscate personal info).
[17:04:53] ERROR: Failed query: deletefrom"payload_preferences"where"payload_preferences"."key"in($1)
params: collection-media-1err: {"type": "DrizzleQueryError","message": "Failed query: delete from \"payload_preferences\" where \"payload_preferences\".\"key\" in ($1)\nparams: collection-media-1: current transaction is aborted, commands ignored until end of transaction block","stack":
Error: Failedquery: deletefrom"payload_preferences"where"payload_preferences"."key"in($1)params: collection-media-1atNodePgPreparedQuery.queryWithCache(file:///app/node_modules/.pnpm/drizzle-orm@0.44.7_@types+pg@8.10.2_pg@8.16.3/node_modules/drizzle-orm/pg-core/session.js:41:15)atprocess.processTicksAndRejections(node:internal/process/task_queues:105:5)atasyncObject.deleteWhere(file:///app/node_modules/.pnpm/@payloadcms+drizzle@3.70.0_@types+pg@8.10.2_payload@3.70.0_graphql@16.12.0_typescript@5.9.3__pg@8.16.3/node_modules/@payloadcms/drizzle/dist/postgres/deleteWhere.js:3:5)atasyncObject.deleteMany(file:///app/node_modules/.pnpm/@payloadcms+drizzle@3.70.0_@types+pg@8.10.2_payload@3.70.0_graphql@16.12.0_typescript@5.9.3__pg@8.16.3/node_modules/@payloadcms/drizzle/dist/deleteMany.js:39:5)atasyncdeleteUserPreferences(file:///app/node_modules/.pnpm/payload@3.70.0_graphql@16.12.0_typescript@5.9.3/node_modules/payload/dist/preferences/deleteUserPreferences.js:32:9)atasyncdeleteOperation(file:///app/node_modules/.pnpm/payload@3.70.0_graphql@16.12.0_typescript@5.9.3/node_modules/payload/dist/collections/operations/delete.js:214:9)atasyncdeleteHandler(file:///app/node_modules/.pnpm/payload@3.70.0_graphql@16.12.0_typescript@5.9.3/node_modules/payload/dist/collections/endpoints/delete.js:10:20)atasynchandleEndpoints(file:///app/node_modules/.pnpm/payload@3.70.0_graphql@16.12.0_typescript@5.9.3/node_modules/payload/dist/utilities/handleEndpoints.js:196:26)atasynceval(webpack-internal:///(rsc)/./node_modules/.pnpm/@payloadcms+next@3.70.0_@types+react@19.2.8_graphql@16.12.0_monaco-editor@0.54.0_next@1_61c4383f3e2205334d475bd28c452ea7/node_modules/@payloadcms/next/dist/routes/rest/index.js:32:20)atasyncAppRouteRouteModule.do(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:5:38696)atasyncAppRouteRouteModule.handle(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:5:45978)atasyncresponseGenerator(webpack-internal:///(rsc)/./node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fapp%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fapp&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:206:38)atasyncAppRouteRouteModule.handleResponse(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:1:187565)atasynchandleResponse(webpack-internal:///(rsc)/./node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fapp%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fapp&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:268:32)atasynchandler(webpack-internal:///(rsc)/./node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fapp%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fapp&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:320:13)atasyncDevServer.renderToResponseWithComponentsImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:1422:9)atasyncDevServer.renderPageComponent(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:1474:24)atasyncDevServer.renderToResponseImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:1514:32)atasyncDevServer.pipeImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:1025:25)atasyncNextNodeServer.handleCatchallRenderRequest(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/next-server.js:393:17)atasyncDevServer.handleRequestImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:916:17)atasync/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/dev/next-dev-server.js:399:20atasyncSpan.traceAsyncFn(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/trace/trace.js:157:20)atasyncDevServer.handleRequest(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/dev/next-dev-server.js:395:24)atasyncinvokeRender(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/lib/router-server.js:240:21)atasynchandleRequest(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/lib/router-server.js:437:24)atasyncrequestHandlerImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/lib/router-server.js:485:13)atasyncServer.requestListener(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/lib/start-server.js:226:13)causedby: error: currenttransactionisaborted,commandsignoreduntilendoftransactionblockat/app/node_modules/.pnpm/pg@8.16.3/node_modules/pg/lib/client.js:545:17atprocess.processTicksAndRejections(node:internal/process/task_queues:105:5)atasyncfile:///app/node_modules/.pnpm/drizzle-orm@0.44.7_@types+pg@8.10.2_pg@8.16.3/node_modules/drizzle-orm/node-postgres/session.js:113:20atasyncNodePgPreparedQuery.queryWithCache(file:///app/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/pg-core/session.js:39:16)atasyncObject.deleteWhere(file:///app/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@payloadcms/drizzle/dist/postgres/deleteWhere.js:3:5)atasyncObject.deleteMany(file:///app/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@payloadcms/drizzle/dist/deleteMany.js:39:5)atasyncdeleteUserPreferences(file:///app/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/preferences/deleteUserPreferences.js:32:9)atasyncdeleteOperation(file:///app/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/collections/operations/delete.js:214:9)atasyncdeleteHandler(file:///app/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/collections/endpoints/delete.js:10:20)atasynchandleEndpoints(file:///app/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/utilities/handleEndpoints.js:196:26)atasynceval(webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_next@1_61c4383f3e2205334d475bd28c452ea7/node_modules/@payloadcms/next/dist/routes/rest/index.js:32:20)atasyncAppRouteRouteModule.do(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:5:38696)atasyncAppRouteRouteModule.handle(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:5:45978)atasyncresponseGenerator(webpack-internal:///(rsc)/./node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fapp%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fapp&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:206:38)atasyncAppRouteRouteModule.handleResponse(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:1:187565)atasynchandleResponse(webpack-internal:///(rsc)/./node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fapp%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fapp&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:268:32)atasynchandler(webpack-internal:///(rsc)/./node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fapp%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fapp&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:320:13)atasyncDevServer.renderToResponseWithComponentsImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:1422:9)atasyncDevServer.renderPageComponent(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:1474:24)atasyncDevServer.renderToResponseImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:1514:32)atasyncDevServer.pipeImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:1025:25)atasyncNextNodeServer.handleCatchallRenderRequest(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/next-server.js:393:17)atasyncDevServer.handleRequestImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/base-server.js:916:17)atasync/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/dev/next-dev-server.js:399:20atasyncSpan.traceAsyncFn(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/trace/trace.js:157:20)atasyncDevServer.handleRequest(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/dev/next-dev-server.js:395:24)atasyncinvokeRender(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/lib/router-server.js:240:21)atasynchandleRequest(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/lib/router-server.js:437:24)atasyncrequestHandlerImpl(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/lib/router-server.js:485:13)atasyncServer.requestListener(/app/node_modules/.pnpm/next@15.5.9_@playwright+test@1.56.1_react-dom@19.2.3_react@19.2.3__react@19.2.3_sass@1.77.4/node_modules/next/dist/server/lib/start-server.js:226:13)
"query": "deletefrom \"payload_preferences\" where \"payload_preferences\".\"key\" in($1)", "params": [ "collection-media-1"
]}DELETE/api/media?limit=0&where%5Band%5D%5B0%5D%5Bid%5D%5Bin%5D%5B0%5D=1500in44ms
I have the same issue trying to delete a particular file in the media collection. I was able to delete others fine, but not this specific file. it doesn't seem to have anything extraordinarily different in the db compared to other files.
Running Payload 3.70.0 in dev mode on localhost (app directory paths below adjusted to obfuscate personal info).
Ahh - so I worked it out. When trying to manually delete the entry from the media table I got a constraint error as the image in question was assigned to a relationship field of another post that was not allowed to be null.
Not sure what could natively be built into the payload engine - but would be great to get a useful error along the lines of "Unable to delete this document as it is currently referenced by another document." and better still a reference to which related document is using it.
You can test if this canary fixes it: 3.75.0-internal.836af83. Will require a schema migration, don't recommend using in a production db as we don't yet know if we'll go ahead with this fix
@AlessioGr Just following up after some additional testing.
It looks like there are two separate problems, both seem related to the afterTenantDelete cleanup hook.
1. Hang/deadlock when a tenant‑scoped collection exists
When deleting a tenant that has a relationship field pointing to documents in a tenant‑scoped collection, the request hangs indefinitely with no errors logged.
Setting cleanupAfterTenantDelete: false prevents the hang, which suggests the cleanup hook is competing with locks already held by the parent transaction and getting stuck.
2. Constraint violation when users are assigned to the tenant
Separately, if a user is associated with the tenant via the tenantsArrayField, the delete operation fails with the following constraint error:
Failed query: delete from "tenants" where "tenants"."id" = $1
params: 00000000-0000-0000-0000-000000000000: null value in column "tenant_id" of relation "admins_tenants" violates not-null constraint
If you have versions enabled on your Collections, then even after de-referencing the document you want to delete from all the other collections would still not remove the reference from older versions.
For example, you have media and posts (with versions enabled) Collections and posts have media as required. Now if you want to delete a media document you will have to de-reference it from all posts documents and from any older versions of that posts document
reproduced on 3.94.0 with @payloadcms/plugin-multi-tenant and @payloadcms/db-postgres. there are two causes.
the tenant column in the users tenants array is NOT NULL, because the plugin marks the field required. its foreign key is ON DELETE SET NULL. so deleting a tenant fails while a user still has it, before afterTenantDelete runs.
tenant-scoped rows also use ON DELETE SET NULL. when the tenant row goes, their tenant id becomes null before the afterDelete cleanup runs. the cleanup's where tenant in [id] then finds nothing, and the rows stay with no tenant.
Activity
mikkelwf commentedon Nov 13, 2025
Its not only a multi-tenant issue..
christopherpickering commentedon Dec 20, 2025
I'm getting the same error in a "magazines" collection. I try to delete an entry from the payloadui and get this log:
we are heavily using the api for other tasks (inserting/updating), do you think an error that was not rolled back in another update is causing this?
max-degterev commentedon Jan 13, 2026
I have this since upgrading to 3.70 in a collection with blocks
salaarkhan-dev commentedon Jan 13, 2026
Any solution facing this issue while deleting tenant?
christopherpickering commentedon Jan 14, 2026
...My error was caused by fk's I forgot to delete 🤭
mattbolt commentedon Jan 15, 2026
I have the same issue trying to delete a particular file in the media collection. I was able to delete others fine, but not this specific file. it doesn't seem to have anything extraordinarily different in the db compared to other files.
Running Payload 3.70.0 in dev mode on localhost (app directory paths below adjusted to obfuscate personal info).
mattbolt commentedon Jan 15, 2026
Ahh - so I worked it out. When trying to manually delete the entry from the media table I got a constraint error as the image in question was assigned to a relationship field of another post that was not allowed to be null.
Not sure what could natively be built into the payload engine - but would be great to get a useful error along the lines of "Unable to delete this document as it is currently referenced by another document." and better still a reference to which related document is using it.
AlessioGr commentedon Feb 5, 2026
You can test if this canary fixes it:3.75.0-internal.836af83. Will require a schema migration, don't recommend using in a production db as we don't yet know if we'll go ahead with this fixNvm, probably need to fix this a different way
TomSteer commentedon Feb 24, 2026
@AlessioGr Just following up after some additional testing.
It looks like there are two separate problems, both seem related to the
afterTenantDeletecleanup hook.1. Hang/deadlock when a tenant‑scoped collection exists
When deleting a tenant that has a relationship field pointing to documents in a tenant‑scoped collection, the request hangs indefinitely with no errors logged.
Setting
cleanupAfterTenantDelete: falseprevents the hang, which suggests the cleanup hook is competing with locks already held by the parent transaction and getting stuck.2. Constraint violation when users are assigned to the tenant
Separately, if a user is associated with the tenant via the
tenantsArrayField, the delete operation fails with the following constraint error:snakemastr commentedon Jun 11, 2026
Any updates on this issue? Cleanup after delete is a pretty usefull feature to me
zakiahmedkgp commentedon Oct 7, 2026
If you have versions enabled on your Collections, then even after de-referencing the document you want to delete from all the other collections would still not remove the reference from older versions.
For example, you have media and posts (with versions enabled) Collections and posts have media as required. Now if you want to delete a media document you will have to de-reference it from all posts documents and from any older versions of that posts document
MRNAQA commentedon Nov 18, 2026
reproduced on 3.94.0 with
@payloadcms/plugin-multi-tenantand@payloadcms/db-postgres. there are two causes.the tenant column in the users tenants array is NOT NULL, because the plugin marks the field required. its foreign key is
ON DELETE SET NULL. so deleting a tenant fails while a user still has it, beforeafterTenantDeleteruns.tenant-scoped rows also use
ON DELETE SET NULL. when the tenant row goes, their tenant id becomes null before theafterDeletecleanup runs. the cleanup'swhere tenant in [id]then finds nothing, and the rows stay with no tenant.running the cleanup in
beforeDeletefixes both.