tomchristensen
tomchristensen
DTDrizzle Team
Created by tomchristensen on 9/4/2023 in #help
Inconsistent transactions with Drizzle/Planetscale
Ok after some more testing it seems like this might be an issue with Planetscale's library. I'll open an issue there
16 replies
DTDrizzle Team
Created by tomchristensen on 9/4/2023 in #help
Inconsistent transactions with Drizzle/Planetscale
No, there's a single example of a transaction in their docs (https://github.com/planetscale/database-js#transactions) but it just shows how to run a couple of statements in sequence.
16 replies
DTDrizzle Team
Created by tomchristensen on 9/4/2023 in #help
Inconsistent transactions with Drizzle/Planetscale
Yep, it's fetch-based. That's also the motivation for trying to parallelize - to avoid a waterfall of http roundtrips when those requests are independent (at least within the context of the transaction).
16 replies
DTDrizzle Team
Created by tomchristensen on 9/4/2023 in #help
Inconsistent transactions with Drizzle/Planetscale
Right, but that seems like an issue that's unique to using the Planetscale driver. The code in the example works as expected if you swap out the Planetscale driver for mysql2.
16 replies
DTDrizzle Team
Created by tomchristensen on 9/4/2023 in #help
Inconsistent transactions with Drizzle/Planetscale
In the example, imagine that each foo record belongs to some foo_group and that there's a business rule that dictates that the sum of n for all foo records in a given foo_group must sum up to 5. Now suppose we want to update n for the foo records in some foo_group - to ensure that our business rule remains satisfied, we would perform the updates in a transaction to ensure that all records are either updated together or none are updated.
16 replies
DTDrizzle Team
Created by tomchristensen on 9/4/2023 in #help
Inconsistent transactions with Drizzle/Planetscale
The specific example I've given is contrived and doesn't need to be a transaction, I agree. The real-world use case is that I need to update a list of records with different values, and I need all the updates to either succeed or fail together.
16 replies