for reproduction of this problem prisma/prisma#16912 (comment)
executed the upsert operation in parallel
script(index.ts)
async function main() {
const prisma = new PrismaClient();
await prisma.$connect();
await prisma.user.deleteMany();
const promises: Promise<void>[] = []
for (let i = 1; i <= 100; i++){
promises.push(runThread(prisma, i))
}
await Promise.all(promises);
await prisma.$disconnect();
}
async function runThread(prisma: PrismaClient, index: number) {
while (true) {
const data = { id : randomInt(250000) };
await prisma.user.upsert({
where: { id: data.id },
create: data,
update: data,
});
}
}
Please check the memory usage of the RSS below.
https://github.com/cashwalk/prisma-issue16912-reproduction.git
npm install
DATABASE_URL="postgresql://<user>:<password>@localhost:5432/<DB>?schema=public"
clinic doctor -- node index
npm run main
.clinic/4.8.1.html
.clinic/4.9.0.html