feat(storage): add RustFS attachments and presigned uploads

Add two API replicas, safe object reconciliation, upload validation, regression tests and documented load experiments.
This commit is contained in:
2026-11-12 10:16:39 +03:00
parent ec540a1a72
commit dc46ac213d
118 changed files with 44628 additions and 38 deletions
+16
View File
@@ -0,0 +1,16 @@
import { Prisma } from '../generated/prisma/client';
export const OBJECT_TRANSACTION = { maxWait: 5000, timeout: 20000 };
/** All writers and cleaners use the same transaction-scoped lock for an immutable key. */
export async function tryAttachmentObjectLock(
tx: Prisma.TransactionClient,
objectKey: string,
): Promise<boolean> {
// A suspended/crashed writer must not keep an idle transaction open indefinitely.
await tx.$executeRaw`SET LOCAL idle_in_transaction_session_timeout = '15s'`;
const [result] = await tx.$queryRaw<{ locked: boolean }[]>(Prisma.sql`
SELECT pg_try_advisory_xact_lock(hashtextextended(${`attachment:${objectKey}`}, 0)) AS locked
`);
return result.locked;
}