Skip to content
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

Use Prisma's Node-API query engine #6920

Merged
merged 16 commits into from
Nov 22, 2021
Merged

Conversation

emmatown
Copy link
Member

@emmatown emmatown commented Nov 11, 2021

Basically this should improve performance when using the Prisma client. See https://www.prisma.io/docs/concepts/components/prisma-engines/query-engine and the section mentioned Node-API on https://github.com/prisma/prisma/releases/tag/3.0.1 for more details. This doesn't look to have an impact on CI performance which is expected since we generally create lots of Prisma clients and do only a couple operations with each of them in tests.

Using this caused some tests to more consistently fail with doing multiple writes on SQLite at the same time so I've made it so we limit writes on SQLite to 1 at a time for a given Prisma client rather than the previous sorta limiting but only if you use *Many operations and not if you do a bunch of single writes, see https://github.com/keystonejs/keystone/pull/6920/files#diff-a6e92b0e6eb325370eba0e5e2be3a8afdb3e866d484db7af462670267dcfc070 for more details.

@changeset-bot

This comment was marked as resolved.

@vercel
Copy link

vercel bot commented Nov 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/F6BVBGthRiHc2fwacmf4gHFHnmjf
✅ Preview: https://keystone-next-docs-git-try-using-prisma-engin-cc8d56-keystonejs.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 11, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@vercel vercel bot temporarily deployed to Preview November 11, 2021 04:59 Inactive
@vercel vercel bot temporarily deployed to Preview November 11, 2021 05:14 Inactive
@vercel vercel bot temporarily deployed to Preview November 12, 2021 01:12 Inactive
@vercel vercel bot temporarily deployed to Preview November 12, 2021 01:15 Inactive
@vercel vercel bot temporarily deployed to Preview November 12, 2021 01:41 Inactive
@vercel vercel bot temporarily deployed to Preview November 12, 2021 01:43 Inactive
@vercel vercel bot temporarily deployed to Preview November 12, 2021 01:50 Inactive
@vercel vercel bot temporarily deployed to Preview November 12, 2021 01:57 Inactive
@vercel vercel bot temporarily deployed to Preview November 12, 2021 02:49 Inactive
@vercel vercel bot temporarily deployed to Preview November 12, 2021 05:09 Inactive
Comment on lines +79 to +83
await prisma.$transaction(
Object.values(prisma)
.filter((x: any) => x?.deleteMany)
.map((x: any) => x?.deleteMany?.({}))
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing things in transactions also gets around the SQLite write timeout immediately thing so I've done that here

@@ -0,0 +1,67 @@
import { text } from '@keystone-next/keystone/fields';
Copy link
Member Author

@emmatown emmatown Nov 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests show what previously didn't work on SQLite, they fail (or rather the update and delete ones fail, the create one for some reason does not) on writes-in-parallel-failure(which is main + this file) for me locally. For some reason they passed on CI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I got these tests to fail on CI on this branch without the limiting: https://github.com/keystonejs/keystone/runs/4205904123?check_suite_focus=true#step:8:17

@emmatown emmatown marked this pull request as ready for review November 12, 2021 05:30
@emmatown emmatown requested a review from a team November 12, 2021 05:30
@vercel vercel bot temporarily deployed to Preview November 12, 2021 05:58 Inactive
@vercel vercel bot temporarily deployed to Preview November 14, 2021 23:12 Inactive
@vercel vercel bot temporarily deployed to Preview November 14, 2021 23:15 Inactive
@dcousens
Copy link
Member

dcousens commented Nov 17, 2021

LGTM but let's wait until after the next release for this

@emmatown emmatown merged commit 82539fa into main Nov 22, 2021
@emmatown emmatown deleted the try-using-prisma-engine-type-library branch November 22, 2021 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants