Feature(s) impacted
Introspection on datasource-sql
Observed behavior
Since I upgraded forest admin to latest version, I’m having intermittent issues when introspecting my database.
This happens like one out of 20 restarts (been coding for a few hours with the server restarting when I make changes, it happened twice).
Absolutely no idea of what could be causing that, but I never saw that issue before.
Just posting in case you upgraded that part of the code lately (can’t be sure on my side this is from the upgrade, as the issue is difficult to reproduce)
Expected behavior
Not to crash
Failure Logs
Error in forest agent:
/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/sequelize@6.35.2_pg@8.8.0/node_modules/sequelize/src/dialects/postgres/query.js:76
const errForStack = new Error();
^
Error
at Query.run (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/sequelize@6.35.2_pg@8.8.0/node_modules/sequelize/src/dialects/postgres/query.js:76:25)
at /home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/sequelize@6.35.2_pg@8.8.0/node_modules/sequelize/src/sequelize.js:650:28
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PostgreSQLDialect.listColumns (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/@forestadmin+datasource-sql@1.11.2_pg@8.8.0/node_modules/@forestadmin/datasource-sql/src/introspection/dialects/postgresql-dialect/index.ts:114:21)
at async Function.getTables (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/@forestadmin+datasource-sql@1.11.2_pg@8.8.0/node_modules/@forestadmin/datasource-sql/src/introspection/introspector.ts:122:27)
at async Function.introspect (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/@forestadmin+datasource-sql@1.11.2_pg@8.8.0/node_modules/@forestadmin/datasource-sql/src/introspection/introspector.ts:24:20)
at async introspect (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/@forestadmin+datasource-sql@1.11.2_pg@8.8.0/node_modules/@forestadmin/datasource-sql/src/index.ts:25:12)
Original error:
original: error: failed to find plan for subquery ss
at Parser.parseErrorMessage (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/pg-protocol@1.6.0/node_modules/pg-protocol/src/parser.ts:369:69)
at Parser.handlePacket (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/pg-protocol@1.6.0/node_modules/pg-protocol/src/parser.ts:188:21)
at Parser.parse (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/pg-protocol@1.6.0/node_modules/pg-protocol/src/parser.ts:103:30)
at Socket.<anonymous> (/home/eloims/Projects/freelance/roundtable/node_modules/.pnpm/pg-protocol@1.6.0/node_modules/pg-protocol/src/index.ts:7:48)
at Socket.emit (node:events:514:28)
at Socket.emit (node:domain:488:12)
at addChunk (node:internal/streams/readable:545:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
at Socket.Readable.push (node:internal/streams/readable:375:5)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
length: 106,
severity: 'ERROR',
code: 'XX000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'ruleutils.c',
line: '7661',
routine: 'get_name_for_var_field',
sql: 'SELECT \n' +
' c.table_schema as "Schema",\n' +
' c.table_name as "Table",\n' +
' c.column_name as "Field", \n' +
' pk.constraint_type as "Constraint",\n' +
' c.column_default as "Default",\n' +
' c.is_nullable as "Null", \n' +
' c.identity_generation as "Identity",\n' +
" (CASE WHEN c.udt_name = 'hstore' THEN c.udt_name ELSE c.data_type END) \n" +
' || (CASE WHEN c.character_maximum_length IS NOT NULL \n' +
" THEN '(' || c.character_maximum_length || ')' \n" +
` ELSE '' END) as "Type", \n` +
' (SELECT array_agg(en.enumlabel) \n' +
' FROM pg_catalog.pg_type t JOIN pg_catalog.pg_enum en ON t.oid = en.enumtypid \n' +
' WHERE t.typname = c.udt_name OR t.typname = e.udt_name\n' +
' ) AS "Special",\n' +
' (SELECT pgd.description \n' +
' FROM pg_catalog.pg_statio_all_tables AS st\n' +
' INNER JOIN pg_catalog.pg_description pgd on (pgd.objoid=st.relid) \n' +
' WHERE c.ordinal_position=pgd.objsubid AND c.table_name=st.relname\n' +
' ) AS "Comment",\n' +
' e.data_type AS "ElementType",\n' +
' e.udt_name AS "TechnicalElementType"\n' +
' FROM \n' +
' information_schema.columns c \n' +
' LEFT JOIN (\n' +
' SELECT tc.table_schema, tc.table_name, \n' +
' cu.column_name, tc.constraint_type \n' +
' FROM information_schema.TABLE_CONSTRAINTS tc \n' +
' JOIN information_schema.KEY_COLUMN_USAGE cu \n' +
' ON tc.table_schema=cu.table_schema \n' +
' AND tc.table_name=cu.table_name \n' +
' AND tc.constraint_name=cu.constraint_name \n' +
" AND tc.constraint_type='PRIMARY KEY'\n" +
" AND tc.constraint_catalog='roundtable'\n" +
' ) pk ON pk.table_schema=c.table_schema \n' +
' AND pk.table_name=c.table_name \n' +
' AND pk.column_name=c.column_name \n' +
' LEFT JOIN INFORMATION_SCHEMA.element_types e ON (\n' +
' c.table_catalog = e.object_catalog AND\n' +
' c.table_schema = e.object_schema AND\n' +
' c.table_name = e.object_name AND\n' +
" 'TABLE' = e.object_type AND\n" +
' c.dtd_identifier = e.collection_type_identifier\n' +
' )\n' +
" WHERE c.table_catalog = 'roundtable' \n" +
" AND ((c.table_schema = 'public'\n" +
" AND c.table_name = '
... skipping this as it contains all tables in our db ...
' ))\n' +
' ORDER BY c.table_schema, c.table_name, c.ordinal_position;',
Context
- Project name: Roundtable
- Team name: Does not matter
- Environment name: Dev
- Agent (forest package) name & version: See screenshot for previous and after versions
- Database type: postgres
- Recent changes made on your end if any: upgraded all forest packages