fynn
fynn
Explore posts from servers
PPrisma
Created by fynn on 10/15/2024 in #help-and-questions
Timed out fetching a new connection from the connection pool.
Hey guys, I am using Next.js and Im trying to deploy my app to my Kubernetes Cluster which is using Prisma. I'll got this error, what could I do about this? Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 5)
3 replies
DTDrizzle Team
Created by fynn on 6/11/2024 in #help
how to properly close mysql pool connection?
Just wanted to add a migrate.ts file, and got this out a example:
import "dotenv/config"
import { migrate } from "drizzle-orm/mysql2/migrator"
import db from "@/app/db/drizzle"

// This will run migrations on the database, skipping the ones already applied
migrate(db, { migrationsFolder: "./drizzle" }).catch(() => {});

// Don't forget to close the connection, otherwise the script will hang
import "dotenv/config"
import { migrate } from "drizzle-orm/mysql2/migrator"
import db from "@/app/db/drizzle"

// This will run migrations on the database, skipping the ones already applied
migrate(db, { migrationsFolder: "./drizzle" }).catch(() => {});

// Don't forget to close the connection, otherwise the script will hang
but how would I close the connection there? thats my drizzle.ts file:
import "dotenv/config";
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2";

// we are using createPool instead of createConnection as createConnection won't work over long run time.
export const sql = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
})

const db = drizzle(sql);

export default db;
import "dotenv/config";
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2";

// we are using createPool instead of createConnection as createConnection won't work over long run time.
export const sql = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
})

const db = drizzle(sql);

export default db;
1 replies