I cache my D1 connection like this (on workers): ```js let cached_db = null; export const useDb = (
I cache my D1 connection like this (on workers):
Can this be the cause of:
Can this be the cause of:
[request error] [unhandled] [500] D1_ERROR: D1 DB storage operation exceeded timeout which caused object to be reset. let cached_db = null;
export const useDb = () => {
if (!cached_db) {
const binding = process?.env?.DB || globalThis?.__env__?.DB || globalThis?.DB
cached_db = drizzle(binding, { schema })
}
return cached_db
}env.{DATABASE_BINDING} you get in each request, otherwise you will definitely hit issues at some point.0.3ms on average so why are you worried about it? [request error] [unhandled] [500] D1_ERROR: D1 DB storage operation exceeded timeout which caused object to be reset.npx wrangler d1 create. Without a wrangler project with the DB in it that is probably true, but once I have one it is no problem.--persist-to ../../../cloudflare/.workers/cache/ which will allow for access to the DB from multiple microservices.
What is your database ID?
Are other queries working, and only that specific migration failing?
If you run the same (or similar) statement in the D1 console does it work or also fail?
You could even put them outside your worker projects entirely and run them in your CItried to find documentation on this but doesn't seem to have any examples I could reference, I assume a wrangler.json is required but I would rather not have a dummy worker project just to house the migrations
why we cant just have normal sql connectionsD1 is built on top of SQLite. There is no "normal SQL connections" because unlike Postgres/MySQL/SQL Server, SQLite DBs are normally used locally and have no connection protocol or way to connect remotely.

X
•4/1/24, 1:30 PM

Combined with db round trips (even with smart placement) being consistently high latency, has led us to have to move to Postgres. We notice that “cold start” times and round trips are consistently better from across the globe, even with a single Postgres instance in us-east :/
wrangler d1 insights into the dash)
env.{DATABASE_BINDING} "avgRowsRead": 0,
"totalRowsRead": 13401,
"avgRowsWritten": 0,
"totalRowsWritten": 0,
"avgDurationMs": 0.33640454375886003,
"totalDurationMs": 4508.830100000001,
"numberOfTimesRun": 13403,
"queryEfficiency": 00.3ms[request error] [unhandled] [500] D1_ERROR: D1 DB storage operation exceeded timeout which caused object to be reset.✘ [ERROR] Migration 0043_cultured_the_stranger.sql failed with the following errors:
✘ [ERROR] <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</... (length = 168)
POST /accounts/***/d1/database/<DATABASE_ID>/query -> 504 Gateway Time-outALTER TABLE `app_devices` DROP COLUMN `force_app_bundle_id`;
ALTER TABLE `app_devices` DROP COLUMN `force_app_channel_id`;npx wrangler d1 create--persist-to ../../../cloudflare/.workers/cache/wrangler d1 insights