Skip to content

cashwalk/prisma-issue16912-reproduction

Repository files navigation

Description

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.

Version 4.8.1

스크린샷 2023-07-07 17 40 33

Version 4.9.0

스크린샷 2023-07-07 17 40 43

Clone

https://github.com/cashwalk/prisma-issue16912-reproduction.git

Install

npm install

Edit .env file

DATABASE_URL="postgresql:https://<user>:<password>@localhost:5432/<DB>?schema=public"

Generate profile file

clinic doctor -- node index

Run

npm run main

Report file

.clinic/4.8.1.html

.clinic/4.9.0.html

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages