ERR * [db sql] INSERT INTO "hashtag"("id", "name", "mentionedUserIds", "mentionedUsersCount", "mentionedLocalUserId...
QueryFailedError: duplicate key value violates unique constraint "IDX_347fec870eafea7b26c8a73bac"
at PostgresQueryRunner.query (/workspace/node_modules/.pnpm/typeorm@1.0.0_ioredis@5.11.1_pg@8.22.0/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:231:19)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async InsertQueryBuilder.execute (/workspace/node_modules/.pnpm/typeorm@1.0.0_ioredis@5.11.1_pg@8.22.0/node_modules/typeorm/query-builder/InsertQueryBuilder.js:107:33) {
query: 'INSERT INTO "hashtag"("id", "name", "mentionedUserIds", "mentionedUsersCount", "mentionedLocalUserIds", "mentionedLocalUsersCount", "mentionedRemoteUserIds", "mentionedRemoteUsersCount", "attachedUserIds", "attachedUsersCount", "attachedLocalUserIds", "attachedLocalUsersCount", "attachedRemoteUserIds", "attachedRemoteUsersCount") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) RETURNING "mentionedUsersCount", "mentionedLocalUsersCount", "mentionedRemoteUsersCount", "attachedUsersCount", "attachedLocalUsersCount", "attachedRemoteUsersCount"',
parameters: [
'ao1bg68tycwi000f',
'my_new_hashtag',
[ 'ao1b68wrycwi0003' ],
1,
[ 'ao1b68wrycwi0003' ],
1,
[],
0,
[],
0,
[],
0,
[],
0
],
driverError: error: duplicate key value violates unique constraint "IDX_347fec870eafea7b26c8a73bac"
at /workspace/node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/client.js:652:17
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async PostgresQueryRunner.query (/workspace/node_modules/.pnpm/typeorm@1.0.0_ioredis@5.11.1_pg@8.22.0/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:196:25)
at async InsertQueryBuilder.execute (/workspace/node_modules/.pnpm/typeorm@1.0.0_ioredis@5.11.1_pg@8.22.0/node_modules/typeorm/query-builder/InsertQueryBuilder.js:107:33) {
length: 237,
severity: 'ERROR',
code: '23505',
detail: 'Key (name)=(my_new_hashtag) already exists.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'hashtag',
column: undefined,
dataType: undefined,
constraint: 'IDX_347fec870eafea7b26c8a73bac',
file: 'nbtinsert.c',
line: '666',
routine: '_bt_check_unique'
},
length: 237,
severity: 'ERROR',
code: '23505',
detail: 'Key (name)=(my_new_hashtag) already exists.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'hashtag',
column: undefined,
dataType: undefined,
constraint: 'IDX_347fec870eafea7b26c8a73bac',
file: 'nbtinsert.c',
line: '666',
routine: '_bt_check_unique'
}
💡 Summary
同じハッシュタグ(ただし、そのハッシュタグはまだDBに存在しない)を含むノートが同時に複数作成されると、サーバーでエラーが発生します。
エラー例:
🥰 Expected Behavior
エラーが発生しない
🤬 Actual Behavior
エラーが発生する
📝 Steps to Reproduce
💻 Frontend Environment
🛰 Backend Environment (for server admin)
Do you want to address this bug yourself?