Files
AIclinicalresearch/backend/check_queue_table.ts
HaHafeng 61cdc97eeb feat(platform): Fix pg-boss queue conflict and add safety standards
Summary:
- Fix pg-boss queue conflict (duplicate key violation on queue_pkey)
- Add global error listener to prevent process crash
- Reduce connection pool from 10 to 4
- Add graceful shutdown handling (SIGTERM/SIGINT)
- Fix researchWorker recursive call bug in catch block
- Make screeningWorker idempotent using upsert

Security Standards (v1.1):
- Prohibit recursive retry in Worker catch blocks
- Prohibit payload bloat (only store fileKey/ID in job.data)
- Require Worker idempotency (upsert + unique constraint)
- Recommend task-specific expireInSeconds settings
- Document graceful shutdown pattern

New Features:
- PKB signed URL endpoint for document preview/download
- pg_bigm installation guide for Docker
- Dockerfile.postgres-with-extensions for pgvector + pg_bigm

Documentation:
- Update Postgres-Only async task processing guide (v1.1)
- Add troubleshooting SQL queries
- Update safety checklist

Tested: Local verification passed
2026-01-23 22:07:26 +08:00

53 lines
1.0 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
const cols: any[] = await prisma.$queryRaw`
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_schema = 'platform_schema' AND table_name = 'queue'
ORDER BY ordinal_position
`;
console.log('platform_schema.queue 表的列:');
cols.forEach(c => console.log(` ${c.column_name}: ${c.data_type} ${c.is_nullable === 'NO' ? 'NOT NULL' : ''}`));
// 检查必要的列是否存在
const requiredCols = ['table_name', 'partition', 'retention_seconds', 'warning_queued'];
const existingCols = cols.map(c => c.column_name);
console.log('\n检查 create_queue 函数需要的列:');
for (const col of requiredCols) {
if (existingCols.includes(col)) {
console.log(`${col} 存在`);
} else {
console.log(`${col} 缺失!`);
}
}
}
main()
.catch(console.error)
.finally(() => prisma.$disconnect());