mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-11-25 23:33:49 +03:00
Refactor document compaction and search projection to remove cross-workspace lock contention and hold zero locks during CRDT merges. Document compaction and user deletion changes: - Replace single-transaction compaction with lock-free reads, owned-permit blocking CRDT merges, and short strict-CAS write transactions. - Retry compaction on snapshot or update CAS mismatches and PostgreSQL 40P01 deadlocks. - Replace full-table pending update grouping with a rotating primary-key loose index scan and per-batch quota cache. - Delete owned personal workspaces in individual short transactions with post-lock Team verification and partial cleanup returns. Connection, rate-limit, and test harness changes: - Set default statement and idle transaction timeouts on dedicated PostgreSQL session connections. - Run deferred invite rate-limit effects only after rejected invite transactions roll back cleanly. - Pass prebound SMTP sinks in parity-harness replay tests to eliminate ephemeral port races. Search projection v6 and pure-Rust runtime changes: - Add search_projection_v6.sql with per-workspace advisory locks, post-lock mode re-checks, and a 30s pre-expiry dual-lock bridge. - Skip steady-state workspace_states updates during ordinary document snapshot writes to remove hot-row contention. - Validate forward-compatible contiguous prefixes in native_schema_migrations during rolling upgrades. - Add pure-Rust server-search (disabled by default) with committed marker-XID fences, deferred GC progress retention, repeatable-read ACL snapshots, and GraphQL resolvers.