Skip to content

Commit bfcedc6

Browse files
committed
Remove the D1-to-R2 oversized-value offload
The transparent D1 driver wrap (intercept bound params >800KB, stash in R2 under a content hash, rehydrate pointer strings on read) existed only because resolved OpenAPI specs were inlined in integration.config and D1 caps a value at ~1-2MB. Specs now live in the blob seam, written straight to R2 through the handle's blobs backend, so nothing that flows through D1 approaches the cap: across the whole fleet the largest non-spec values are tool rows ~165KB, definitions ~256KB, and plugin_storage ~206KB. The canonical deployment's database was scanned for offload pointer strings before removal — zero exist in any table, so this is code-only. A deployment that still had legacy oversized rows stored as pointers would need the spec backfill before taking this change. The workerd e2e still pushes a ~1MB spec through the real worker; it now proves the spec lands in the R2 blob seam rather than the offload. maxBoundParameters stays — that is D1's parameter-count platform limit, unrelated to value size.
1 parent cbc815f commit bfcedc6

5 files changed

Lines changed: 15 additions & 382 deletions

File tree

apps/host-cloudflare/src/db/d1.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
} from "@executor-js/fumadb/adapters/drizzle";
66
import type { D1Database, R2Bucket } from "@cloudflare/workers-types";
77

8-
import { wrapD1WithR2Offload } from "./r2-blob-offload";
9-
108
import {
119
collectTables,
1210
createExecutorFumaDb,
@@ -38,12 +36,8 @@ export const createD1ExecutorDb = async (
3836
provider: "sqlite" as const,
3937
};
4038

41-
// Offload oversized values to R2 (D1 caps a value at ~1-2MB). No-op for
42-
// ordinary small rows; only multi-MB values (e.g. a large OpenAPI spec) leave
43-
// D1. Without a bucket bound, fall back to plain D1 (small values only).
44-
const connection = blobs ? wrapD1WithR2Offload(db, blobs) : db;
4539
const schema = createDrizzleRuntimeSchemaFromTables(options);
46-
const drizzleDb = drizzle(connection, { schema });
40+
const drizzleDb = drizzle(db, { schema });
4741

4842
// D1 rejects SQL `BEGIN TRANSACTION` / `SAVEPOINT` (it requires the JS batch
4943
// API), and the shared ensure wraps its DDL in a transaction when the handle
@@ -70,9 +64,10 @@ export const createD1ExecutorDb = async (
7064
fuma,
7165
// The D1 binding owns its own lifecycle; nothing to release.
7266
close: async () => {},
73-
// Blob-seam writes go straight to R2 — they never enter D1, so they never
74-
// need the offload wrap above (which remains only for legacy oversized
75-
// values already inlined in D1 rows).
67+
// Multi-MB values (resolved OpenAPI specs, introspection snapshots) go
68+
// through the blob seam straight to R2 — they never enter D1, which caps
69+
// a value at ~1-2MB. Without a bucket bound, the executor falls back to
70+
// the FumaDB blob table (small values only).
7671
blobs: blobs ? makeR2BlobStore(blobs) : undefined,
7772
};
7873
};

apps/host-cloudflare/src/db/r2-blob-offload.test.ts

Lines changed: 0 additions & 126 deletions
This file was deleted.

apps/host-cloudflare/src/db/r2-blob-offload.ts

Lines changed: 0 additions & 234 deletions
This file was deleted.

0 commit comments

Comments
 (0)