-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Description
Intermittent Prisma transaction error when editing documents. Documents save successfully, but version history/snapshots fail to update.
Environment
- AFFiNE Version: 0.25.7 (ghcr.io/toeverything/affine-graphql:0.25.7)
- Deployment: Self-hosted on Railway
- Database: PostgreSQL 17
- Redis: 8.x
- Storage: Cloudflare R2 (S3-compatible)
Error Log
[Nest] 1 - 12/16/2025, 10:51:43 AM ERROR [EventBus] selfhosted:ws:fda6ba8e-6285-486f-921e-91fdc284dcca Error happened when handling event doc.snapshot.updated
PrismaClientKnownRequestError:
Invalid prisma.workspaceDoc.upsert() invocation:
Transaction API error: Transaction already closed: A query cannot be executed on a committed transaction.
at Zn.handleRequestError (/app/node_modules/.prisma/client/runtime/library.js:124:7459)
at Zn.handleAndLogRequestError (/app/node_modules/.prisma/client/runtime/library.js:124:6784)
at Zn.request (/app/node_modules/.prisma/client/runtime/library.js:124:6491)
at async l (/app/node_modules/.prisma/client/runtime/library.js:133:9778)
at async DocModel.upsertMeta (file:///app/dist/main.js:13791:21)
at async DocEventsListener.markDocContentCacheStale (file:///app/dist/main.js:22390:13)
at async file:///app/dist/main.js:5603:28
at async handler.event.event (file:///app/dist/main.js:5595:20)
at async EventEmitter. (file:///app/dist/main.js:6375:20)
at async Promise.all (index 0)
Steps to Reproduce
- Self-host AFFiNE v0.25.7 with PostgreSQL and Redis
- Create/edit a text document
- Make changes and let it sync
- Check server logs - error appears intermittently
Expected Behavior
Document changes should be saved AND version history snapshots should be recorded consistently.
Actual Behavior
- Documents save correctly ✓
- Version history snapshots fail intermittently ✗
- Error indicates transaction commits before snapshot write completes
Additional Context
- Single user testing (not a load/concurrency issue)
- Simple text document edits
- Redis metrics show minimal usage
- Database performance is normal
This appears to be a race condition where the main document transaction commits before the doc.snapshot.updated event handler completes its database write.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status