MASTRA_STORAGE_POSTGRES_STORE_INIT_FAILED + MASTRA_STORAGE_PG_STORE_CREATE_TABLE_FAILED

I am all of a sudden getting these errors when trying to fetch resources using the following:
const oa = mastra.getAgent("orchestratorAgent");
const memory = await oa.getMemory();
const thread = await memory?.query({
threadId: clientSessionId,
});
const oa = mastra.getAgent("orchestratorAgent");
const memory = await oa.getMemory();
const thread = await memory?.query({
threadId: clientSessionId,
});
MastraError: remaining connection slots are reserved for non-replication superuser connections
at PostgresStore.init (webpack-internal:///(rsc)/./node_modules/@mastra/pg/dist/index.js:4204:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
id: 'MASTRA_STORAGE_POSTGRES_STORE_INIT_FAILED',
domain: 'STORAGE',
category: 'THIRD_PARTY',
details: {},
[cause]: MastraError: remaining connection slots are reserved for non-replication superuser connections

id: 'MASTRA_STORAGE_PG_STORE_CREATE_TABLE_FAILED',
domain: 'STORAGE',
category: 'THIRD_PARTY',
details: { tableName: 'mastra_scorers' },
[cause]: error: remaining connection slots are reserved for non-replication superuser connections
MastraError: remaining connection slots are reserved for non-replication superuser connections
at PostgresStore.init (webpack-internal:///(rsc)/./node_modules/@mastra/pg/dist/index.js:4204:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
id: 'MASTRA_STORAGE_POSTGRES_STORE_INIT_FAILED',
domain: 'STORAGE',
category: 'THIRD_PARTY',
details: {},
[cause]: MastraError: remaining connection slots are reserved for non-replication superuser connections

id: 'MASTRA_STORAGE_PG_STORE_CREATE_TABLE_FAILED',
domain: 'STORAGE',
category: 'THIRD_PARTY',
details: { tableName: 'mastra_scorers' },
[cause]: error: remaining connection slots are reserved for non-replication superuser connections
Any ideas as to what might be causing it? My storage config looks like this:
export const mastraStorageStore = new PostgresStore({
connectionString: process.env.DATABASE_URL,
});
export const mastraStorageStore = new PostgresStore({
connectionString: process.env.DATABASE_URL,
});
DB Url is a Supabase connection string. Any ideas?
6 Replies
Mastra Triager
GitHub
[DISCORD:1428445200551776256] MASTRA_STORAGE_POSTGRES_STORE_INIT_FA...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1428445200551776256 I am all of a sudden getting these errors when trying to fetch resources using the fol...
_roamin_
_roamin_4d ago
Hey @bighitbiker3 ! You might have too many connections open in your pool, can you try setting the max option to something like 5 and see if you're still getting the error?
export const mastraStorageStore = new PostgresStore({
connectionString: process.env.DATABASE_URL,
max: 5
});
export const mastraStorageStore = new PostgresStore({
connectionString: process.env.DATABASE_URL,
max: 5
});
bighitbiker3
bighitbiker3OP4d ago
Ok will give that a shot. It's intermittent so that may be the issue @Romain this did not fix it. Still getting it
_roamin_
_roamin_4d ago
Thanks for trying! Are you using the connection pooling string from supabase?
bighitbiker3
bighitbiker3OP4d ago
nope I was using direct connection string. pooling port works!
_roamin_
_roamin_4d ago
Awesome!!!!

Did you find this page helpful?