40001 is not a query errorThe PostgreSQL manual is unusually direct about this: When an application receives this error message, it should abort the current transaction and retry the whole transaction from the beginning. "Th12AAug 25 · 10 min readmohamedaboelmagd.hashnode.dev