-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use transaction with serializable #12
fix: use transaction with serializable #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpError: {"message":"version '3618' for the application '062bb243-f1ef-4786-87e9-466cf3b94984' already exists","error":"Conflict","statusCode":409}
at /Users/sunrabbit/Desktop/wrtn/github/agent/node_modules/.pnpm/@nestia+fetcher@5.0.0_typescript@5.7.3/node_modules/@nestia/fetcher/src/internal/FetcherBase.ts:38:15
at step (/Users/sunrabbit/Desktop/wrtn/github/agent/node_modules/.pnpm/@nestia+fetcher@5.0.0_typescript@5.7.3/node_modules/@nestia/fetcher/lib/internal/FetcherBase.js:44:23)
at Object.next (/Users/sunrabbit/Desktop/wrtn/github/agent/node_modules/.pnpm/@nestia+fetcher@5.0.0_typescript@5.7.3/node_modules/@nestia/fetcher/lib/internal/FetcherBase.js:25:53)
at fulfilled (/Users/sunrabbit/Desktop/wrtn/github/agent/node_modules/.pnpm/@nestia+fetcher@5.0.0_typescript@5.7.3/node_modules/@nestia/fetcher/lib/internal/FetcherBase.js:16:58)
at processTicksAndRejections (node:internal/process/task_queues:105:5) {
method: 'POST',
path: '/applications/by-ids/062bb243-f1ef-4786-87e9-466cf3b94984/versions',
status: 409,
headers: {
'access-control-allow-origin': '*',
connection: 'keep-alive',
'content-length': '138',
'content-type': 'application/json; charset=utf-8',
date: 'Wed, 12 Mar 2025 05:14:42 GMT',
etag: 'W/"8a-5qdmYUCQxPVbjrt4p+18waHeguE"',
'keep-alive': 'timeout=5',
'x-powered-by': 'Express'
},
body_: {}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"level":30,"time":1741758370459,"pid":22500,"hostname":"sunrabbitui-MacBookPro-2.local","req":{"id":2112,"method":"POST","url":"/application-versions/by-ids/b0968d25-12a5-4fb3-96d7-743e5cf32a9b/connectors","query":{},"params":{"path":["application-versions","by-ids","b0968d25-12a5-4fb3-96d7-743e5cf32a9b","connectors"]},"headers":{"host":"localhost:37001","connection":"keep-alive","content-type":"application/json","accept":"/","accept-language":"","sec-fetch-mode":"cors","user-agent":"node","accept-encoding":"gzip, deflate","content-length":"446"},"remoteAddress":"127.0.0.1","remotePort":49707},"res":{"statusCode":500,"headers":{"x-powered-by":"Express","access-control-allow-origin":"","content-type":"application/json; charset=utf-8","content-length":"52","etag":"W/"34-rlKccw1E+/fV8niQk4oFitDfPro""}},"err":{"type":"Error","message":"failed with status code 500","stack":"Error: failed with status code 500\n at onResFinished (/Users/sunrabbit/Desktop/wrtn/github/connector-hive/node_modules/pino-http/logger.js:115:39)\n at ServerResponse.onResponseComplete (/Users/sunrabbit/Desktop/wrtn/github/connector-hive/node_modules/pino-http/logger.js:178:14)\n at ServerResponse.emit (node:events:530:35)\n at onFinish (node:_http_outgoing:1077:10)\n at callback (node:internal/streams/writable:766:21)\n at afterWrite (node:internal/streams/writable:710:5)\n at afterWriteTick (node:internal/streams/writable:696:10)\n at processTicksAndRejections (node:internal/process/task_queues:89:21)"},"responseTime":2002,"msg":"request errored"}
{"level":30,"time":1741758370459,"pid":22500,"hostname":"sunrabbitui-MacBookPro-2.local","req":{"id":2113,"method":"POST","url":"/application-versions/by-ids/e6242777-8f6e-4ff1-b60e-cb7d084317e0/connectors","query":{},"params":{"path":["application-versions","by-ids","e6242777-8f6e-4ff1-b60e-cb7d084317e0","connectors"]},"headers":{"host":"localhost:37001","connection":"keep-alive","content-type":"application/json","accept":"/","accept-language":"","sec-fetch-mode":"cors","user-agent":"node","accept-encoding":"gzip, deflate","content-length":"876"},"remoteAddress":"127.0.0.1","remotePort":49710},"res":{"statusCode":500,"headers":{"x-powered-by":"Express","access-control-allow-origin":"","content-type":"application/json; charset=utf-8","content-length":"52","etag":"W/"34-rlKccw1E+/fV8niQk4oFitDfPro""}},"err":{"type":"Error","message":"failed with status code 500","stack":"Error: failed with status code 500\n at onResFinished (/Users/sunrabbit/Desktop/wrtn/github/connector-hive/node_modules/pino-http/logger.js:115:39)\n at ServerResponse.onResponseComplete (/Users/sunrabbit/Desktop/wrtn/github/connector-hive/node_modules/pino-http/logger.js:178:14)\n at ServerResponse.emit (node:events:530:35)\n at onFinish (node:_http_outgoing:1077:10)\n at callback (node:internal/streams/writable:766:21)\n at afterWrite (node:internal/streams/writable:710:5)\n at afterWriteTick (node:internal/streams/writable:696:10)\n at processTicksAndRejections (node:internal/process/task_queues:89:21)"},"responseTime":2001,"msg":"request errored"}
This PR resolves the problem that the server returns 500 internal server error when the client creates massive amount of application creation requests in parallel.
It adds
ON CONFLICT DO NOTHING
clause, and introduces retry attempts with random delay.