question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connection issues never seem to go away(how to deploy prisma live reliably) [MySQL, TypeGraphQL, EBS]

See original GitHub issue

Bug description

Hello,

Ever since our migration from Prisma 1 to Prisma 2, and connection issues never got solved for us. We wanted to deploy our same Nextjs website(after query changes) using the new Prisma 2 backend hosted on lambda using serverless framework and TypeGraphQL.

We tried RDS proxy when it was first suggested by Prisma months ago, but then were surprised in the updated docs that it would be useless when used with Prisma.

That left us stuck, not knowing how to proceed from that. So we decided to step away from lambda and head to long running servers with elastic beanstalk. While preparing for that with the docker image, running the container locally using apollo server(not apollo server lambda), we still faced the same connection issues.

We referred back to the docs for the suggestions regarding deploying using the long running server model, we tried increasing the connection_limit from the default(9) to big numbers like 200 and 300. Connection issues were occurring just the same. We noticed that RDS connections never really go up to the number we specified while Prisma reports that it’s actually using the number, while same issues were happening.

Since we’re going the long-running server model, we want to guarantee that we won’t face these issues once we go live.

How to reproduce

What we were testing the most was the homepage. In getServerSideProps(Nextjs), we prepare 5 graphql requests to get page content, and send them concurrently using Promise.all to the Prisma 2 backend.

Expected behavior

The whole migration we did from Prisma 1 was in hopes of better database schema(Prisma 1 schema in the db level was a mess, many unnecessary relations, etc), better db access, reduced costs(no need for a separate server). But so far our experience has been horrible(deployment and testing stage), we kind of regretted doing the migration. We were better off with Prisma 1(despite Prisma 2 benefits).

Prisma information

const 1stPortion = services.getItems(
    user?.id,
    {
        ignoredBy: {
            none: {
                id: {
                    equals: user?.id ?? '',
                },
            },
        },
        status: {
            in: ['ACTIVE', 'ACTIVEUPDATED'],
        },
    },
    { score: 'desc' },
    4
);
const 2ndPortion = services.getItems(
    user?.id,
    {
        category: {
            equals: 'FARM',
        },
        type: {
            equals: 'RENT',
        },
        ignoredBy: {
            none: {
                id: {
                    equals: user?.id,
                },
            },
        },
        status: {
            in: ['ACTIVE', 'ACTIVEUPDATED'],
        },
    },
    { createdAt: 'desc' },
    4
);
const 3rdPortion = services.getItems(
    user?.id,
    {
        category: {
            equals: 'APARTMENT',
        },
        type: {
            equals: 'SALE',
        },
        ignoredBy: {
            none: {
                id: {
                    equals: user?.id,
                },
            },
        },
        status: {
            in: ['ACTIVE', 'ACTIVEUPDATED'],
        },
    },
    { createdAt: 'desc' },
    4
);
const 4thPortion = services.getItems(
    user?.id,
    {
        category: {
            equals: 'APARTMENT',
        },
        type: {
            equals: 'RENT',
        },
        ignoredBy: {
            none: {
                id: {
                    equals: user?.id,
                },
            },
        },
        status: {
            in: ['ACTIVE', 'ACTIVEUPDATED'],
        },
    },
    { createdAt: 'desc' },
    4
);
const 5thPortion = services.getItems(
    user?.id,
    {
        category: {
            equals: 'LAND',
        },
        type: {
            equals: 'SALE',
        },
        ignoredBy: {
            none: {
                id: {
                    equals: user?.id,
                },
            },
        },
        status: {
            in: ['ACTIVE', 'ACTIVEUPDATED'],
        },
    },
    { createdAt: 'desc' },
    4
);

const pageData = await Promise.all([
    1stPortion,
    2ndPortion,
    3rdPortion,
    4thPortion,
    5thPortion,
]); 

Environment & setup

  • OS: Ubuntu 18.04
  • Database: MySQL 5.7
  • Node.js version: v14.15.1
  • Prisma version: 2.19

Prisma Version

prisma               : 2.19.0
@prisma/client       : 2.18.0
Current platform     : debian-openssl-1.1.x
Query Engine         : query-engine c1455d0b443d66b0d9db9bcb1bb9ee0d5bbc511d (at ../../../../usr/local/lib/node_modules/prisma/node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine     : migration-engine-cli c1455d0b443d66b0d9db9bcb1bb9ee0d5bbc511d (at ../../../../usr/local/lib/node_modules/prisma/node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core c1455d0b443d66b0d9db9bcb1bb9ee0d5bbc511d (at ../../../../usr/local/lib/node_modules/prisma/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary        : prisma-fmt c1455d0b443d66b0d9db9bcb1bb9ee0d5bbc511d (at ../../../../usr/local/lib/node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Studio               : 0.358.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
albertoperdomocommented, Jul 22, 2021

Hello @omar-dulaimi and others,

we are working on a Prisma Data Proxy which will help with connection management in serverless backens. If you are interested in our upcoming Early Acess, you can sign up here: https://pris.ly/prisma-data-proxy

1reaction
Syttencommented, Jun 14, 2021

Many issues have been fixed in more recent prisma releases (>2.20 at least), see https://github.com/prisma/prisma/issues/6329#issuecomment-811097812.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma 3.12.0 Release - GitClear
Connection issues never seem to go away(how to deploy prisma live reliably) [MySQL, TypeGraphQL, EBS] · Error: [libs/datamodel/connectors/dml/src ...
Read more >
GraphQL Playground and Prisma Issue - Questions
I've been setting up 1.7+ and I've come into a slight problem with both I am getting this error: [GraphQL error]: Message: Project...
Read more >
Highlights - FeedsAnywhere
Introspecting databases that organize objects in multiple database schemas; Managing multi-schema database setups directly from Prisma schema; Generating ...
Read more >
@prisma/generator-helper: Versions | Openbase
Try it out and let us know what you think in this GitHub issue. ... Connection issues never seem to go away(how to...
Read more >
Ask HN: Companies of one, what is your tech stack?
I need to send out a newsletter, and most Saas options are crazy ... a very high bar for which plugins you install,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found