pandareaper
pandareaper
DTDrizzle Team
Created by Joseph Justus on 4/20/2024 in #help
How not to exceed the max connections limit in the DB in a Serverless env like AWS lambda?
If we move the connection creation and drizzle initialization steps inside the handler and close it after use each time
This won't help your problem, it's best practice to keep these connections open since Lambda will keep your function warm between invocations, so don't do this.
Would using AWS RDS proxy help in any way?
RDS Proxy will most definitely help here, it's greatest strength is the ability to increase the number of connections your app can consume while constraining it to what the DB can actually provide. Comes at a cost of course
Are there other strategies
If cost is a concern and you just want to prevent your DB from falling over then reserved concurrency for your function might be an easy mitigation, with the downside of constraining how much you can scale
3 replies
DTDrizzle Team
Created by pandareaper on 8/6/2023 in #help
Issues with timestamp precision with postgres
This is my custom timestamp data type
export const pgTimestamp = customType<{ data: Date; driverData: Date }>({
dataType() {
return 'timestamptz(3)';
},
toDriver: (date: Date) => {
return date;
},
fromDriver: (date: Date) => {
return date;
},
});
export const pgTimestamp = customType<{ data: Date; driverData: Date }>({
dataType() {
return 'timestamptz(3)';
},
toDriver: (date: Date) => {
return date;
},
fromDriver: (date: Date) => {
return date;
},
});
Looking at my migrations I don't see any space, I can't see how drizzle would introduce that either. Have you put that space there in your datatType() ?
8 replies
DTDrizzle Team
Created by pandareaper on 8/6/2023 in #help
Issues with timestamp precision with postgres
Yeah I ended up creating a customType to address this. I saw a post yesterday suggesting it might have just been fixed though
8 replies
DTDrizzle Team
Created by predragnikolic on 11/15/2023 in #help
Is drizzle safe to use in production?
@soulsizzle have you got a link to any GH issues regarding that?
5 replies
DTDrizzle Team
Created by Kevin on 11/1/2023 in #help
Does throwing an error in a TX automatically rollback?
Yes indeed. tx.rollback simply throws an Error itself I believe
2 replies
DTDrizzle Team
Created by lolmaus (Andrey Mikhaylov) on 10/27/2023 in #help
Acceptance testing practices? In-memory Postgres mock for high-speed acceptance testing?
I use testcontainers to spin up a postgres db for each test suite, with some optimisations (e.g. turn off fsync) it starts up in <2 seconds We have hundreds of tests like this, best way to test DB queries IMO
13 replies
DTDrizzle Team
Created by Cale McCollough on 10/7/2023 in #help
How do you use 128-bit values with varbinary and what is the fastest way to search for rows?
Why do you want two 64 bit integers? Storing UUIDs as 128bit binary is the industry standard. Where a database has higher level type support for "UUID", it will still be the 128 bit binary value under the hood
8 replies
DTDrizzle Team
Created by Cale McCollough on 10/7/2023 in #help
How do you use 128-bit values with varbinary and what is the fastest way to search for rows?
You need to use a Buffer to represent your UUID when interacting with the DB e.g. Buffer.from('975b2add-6362-4cda-ae30-a9e56361f857'.replace(/-/g, ''),'hex')
8 replies
DTDrizzle Team
Created by net-tech- on 10/7/2023 in #help
Alerting if there is conflict
in my experience, the error you get will be from whatever DB driver you are using under the hood, not drizzle
3 replies
DTDrizzle Team
Created by msu on 9/8/2023 in #help
Postgres read slaves?
repliwhat 😂
16 replies
DTDrizzle Team
Created by imoby on 9/19/2023 in #help
Best practice on running migrations
We currently have a lambda function dedicated to running migrations, using await migrate(...). At least at the time, drizzle wasn't safe for running migrations across multiple machines concurrently AFAIK. We run this manually at the moment, but soon plan on making it a custom cloudformation resource so that it runs as part of our CDK deployment (I'm sure the same can be done in sls). Or a more trivial approach, we will just invoke it as part of our deployment pipeline
16 replies
DTDrizzle Team
Created by msu on 9/8/2023 in #help
Postgres read slaves?
Not that specifically, it would be quite a niche pattern so I wouldn’t expect any to support it either
16 replies
DTDrizzle Team
Created by msu on 9/8/2023 in #help
Postgres read slaves?
True, I might consider something like that as well. I do have some more advanced read replica query patterns where I would route based on async context / environment configuration where this might be useful
16 replies
DTDrizzle Team
Created by msu on 9/8/2023 in #help
Postgres read slaves?
It would be good to see Drizzle support this more natively like many other ORMs do. As an ORM it is well positioned to know read vs write queries and automatically route queries to the correct connection/pool
16 replies
DTDrizzle Team
Created by Hugo on 9/11/2023 in #help
Is it good to use UUID as primary key ?
I'm also using V7 UUIDs as primary keys, which mimic the monotonically increasing behaviour of auto incrementing IDs. I use this library https://github.com/jetpack-io/typeid-js to Base32 encode our UUIDs improves the usability of IDs (shorter, URL friendly, double clickable) I would be weary of using nanoids as a primary key, they would suffer the same problems that V4 UUIDs have. They are suitable in the context of planetscale because it is a sharded database and having a good random key means a nice distribution across your shards. This is not the case for most database
39 replies
DTDrizzle Team
Created by aakrit512 on 8/2/2023 in #help
PostgreSQL migration issue in AWS RDS with Drizzle ORM: 'no pg_hba.conf entry for host' error
This will be an SSL issue, there are extra steps to add the root certificates from RDS in order to allow connections to be verified. See a related thread with details on how to configure SSL https://discord.com/channels/1043890932593987624/1128455867021398087/1141231166754664509
4 replies
DTDrizzle Team
Created by roob on 8/7/2023 in #help
Do I need to close the DB connection after running a script using drizzle?
@spiritanand you could try create a connection pool instead of a single connection mysql.createPool Over time, idle connections will close automatically. I'm guessing the singleton connection that you are getting doesn't automatically reconnect, which also seems odd. A pool will manage that for you, automatically creating a new connection when it's needed. You could test this locally by running your app, restarting the DB and verifying that your app reconnects on it's own
25 replies
DTDrizzle Team
Created by roob on 8/7/2023 in #help
Do I need to close the DB connection after running a script using drizzle?
What error are you getting @spiritanand ? In 99% of cases, you do not want to close the connection after each query, you want to re-use it. Creating connections is a slow process
25 replies
DTDrizzle Team
Created by DYELbrah on 8/19/2023 in #help
date column not being returned as string by drizzle
Be careful with timestamp as well, because it has a bug where it drops millisecond precision
9 replies
DTDrizzle Team
Created by DYELbrah on 8/19/2023 in #help
date column not being returned as string by drizzle
timestamp has a few bugs, I don't use it but instead use a custom type with a timestamp(3) column.
9 replies