Lazer_Pope (Vossi / Hendrik)
DTDrizzle Team
•Created by Lazer_Pope (Vossi / Hendrik) on 6/25/2024 in #help
Connection terminated unexpectedly after adding postgres.conf
I eventually gave up on using a conf file
7 replies
DTDrizzle Team
•Created by Lazer_Pope (Vossi / Hendrik) on 1/14/2025 in #help
Connection pool size > 1 leads to very erroneous DB behaviour
And here's a similar example of an insert seemingly being succesufll, until I actually want to access the row outside of the transaction:
export async function insertProject(projectDto: InsertProject, userId: number) {
const formFiles = projectDto.addFiles;
try {
const dbo = await db.transaction(async (trx) => {
const models = await trx
.insert(projects)
.values({ ...projectDto, updatedBy: userId })
.returning();
console.log('Inserted dbo', models);
console.log(
'Select inserted model from db in trx',
await trx.select().from(projects).where(eq(projects.id, models[0].id))
);
return models[0];
});
console.log('Select model outside of trx from db', await db.select().from(projects).where(eq(projects.id, dbo.id)));
return dbo;
} catch (e) {
console.error('🚀 ~ insertProject ~ e:', e);
handleErrorBackend(e);
}
}
Inserted dbo [
{
id: 94450,
dispatcherId: 6640,
created: '2025-01-14 11:34:49',
updated: '2025-01-14 11:34:49'
}
]
Select inserted model from db in trx [
{
id: 94450,
dispatcherId: 6640,
created: '2025-01-14 11:34:49',
updated: '2025-01-14 11:34:49'
}
]
Select model outside of trx from db []4 replies
DTDrizzle Team
•Created by Lazer_Pope (Vossi / Hendrik) on 1/14/2025 in #help
Connection pool size > 1 leads to very erroneous DB behaviour
Here's an example of deleting a row, which seems to fail silently:
export async function removeEquipmentById(id: number) {
const toDelete = await db.select().from(equipments).where(eq(equipments.id, id));
console.log('🚀 ~ removeEquipmentById ~ toDelete:', id, toDelete);
if (!toDelete) {
error(400, { message: 'Invalid project ID: ' + id });
}
const result = await db.delete(equipments).where(eq(equipments.id, id));
console.log('🚀 ~ removeEquipmentById ~ result:', id, result);
const stillExists = await db.select().from(equipments).where(eq(equipments.id, id));
console.log('🚀 ~ removeEquipmentById ~ stillExists:', id, stillExists);
}
🚀 ~ removeEquipmentById ~ toDelete: 50194 [
{
id: 50194,
name: 'Sony Alpha II_00',
description: null,
departmentId: 10099,
equipmentTypeId: 2731,
locationId: null,
created: 2025-01-14T11:16:46.000Z,
updated: 2025-01-14T11:16:46.000Z
}
]
🚀 ~ removeEquipmentById ~ result: 50194 Result {
command: 'DELETE',
rowCount: 1,
oid: null,
rows: [],
fields: [],
_parsers: undefined,
_types: { getTypeParser: [Function: getTypeParser] },
RowCtor: null,
rowAsArray: false,
_prebuiltEmptyResultObject: null
}
🚀 ~ removeEquipmentById ~ stillExists: 50194 [
{
id: 50194,
name: 'Sony Alpha II_00',
description: null,
departmentId: 10099,
equipmentTypeId: 2731,
locationId: null,
created: 2025-01-14T11:16:46.000Z,
updated: 2025-01-14T11:16:46.000Z
}
]4 replies
DTDrizzle Team
•Created by Lazer_Pope (Vossi / Hendrik) on 1/14/2025 in #help
Connection pool size > 1 leads to very erroneous DB behaviour
This conenction pool with the default max settings, causes those random errors:
return new Pool(dbCredentials);
Allowing only one connection works, but is slower:
return new Pool({
...dbCredentials,
max: 1,
});
Allowing only one use per connection also works, but is 3x slower than only having 1 connection with unlimited reuses.
return new Pool({
...dbCredentials,
max: 100,
maxUses: 1,
});
Multiple connection with multiple reuses doesn't work, without causing those wierd errors under high load. But reducing either is a huge bottleneck.4 replies
DTDrizzle Team
•Created by Lazer_Pope (Vossi / Hendrik) on 1/13/2025 in #help
Missing database entries under heavy load
The same happens for deletes. After deelting a row, it's still present in postgres.
2 replies
DTDrizzle Team
•Created by Lazer_Pope (Vossi / Hendrik) on 6/25/2024 in #help
Connection terminated unexpectedly after adding postgres.conf
Correct, the settings are valid and postgres applies them when I add them via environment variables. But when I try to use a conf file, it fails.
7 replies
DTDrizzle Team
•Created by smiley on 5/2/2024 in #help
Cannot migrate/push after adding column to sqlite table
I haven't used sqLite, but I am sure that it won't require you to delete your db.
'No config path provided, using default path
Reading config file' sounds like drizzle can't finde your drizzle configuration. I would double check all my drizzle related file paths. If it worked before, check if you changed anything in your file and directory strucutre. I had something like that when I tydied up my project and moved my db migrations into a different folder.
'/home/radh/src/radh/drizzle.config.ts'
Are you 100% sure that the path is correct?
2 replies
DTDrizzle Team
•Created by Lazer_Pope (Vossi / Hendrik) on 10/16/2023 in #help
Automatic migrationbs
I've figured out that I can just do all the db setup in src/hooks.server.ts
I use it to setup, migrate & seed the database on start-up, seems to work really well and explicit.
2 replies