Upgrade assetpack-core to 0.4.2 (default-features = false, file-transform), assetpack-transform-precomp2 to 0.4.4 (precomp2 0.3.4), brotli to 9, and zstd to 0.14, and drop the direct lzma-rust2 dependency. Refactor AssetpackBlobStorage onto sqlx SqlitePool, FileTransformConfig::fast, FileReader, and TransformDecoderRegistry with zero-clone chunk reads, separate read/write/transform semaphores, manifest-only promote_object, and Unix-second object/cache timestamps. Add config.precomp2 (default true), reject precomp2 on fs configs in both validation and startup parsing, document v0.27.5 coexistence in docs/rollout-coexistence.md, and cover real 0.1.0 interop, PCF2 segment bombs, and 16000x16000 PNG regressions.
5.3 KiB
Rollout and Coexistence
This document specifies coexistence rules when affine-server shares PostgreSQL and Redis with AFFiNE v0.27.5.
1. Schema Baseline
- Upgrade every existing database to the
v0.27.5Prisma migration baseline before you startaffine-server. - Do not modify rows in
_prisma_migrationsduring coexistence. - Record native component schema versions in
native_schema_migrations.
2. Forward-Compatible Native Migrations
- Frozen
v0.27.5(@affine/server-native) checksnative_schema_migrationschecksums for versions1..=5and ignores higher versions such asv6. - A database migrated to
v6can roll back directly tov0.27.5.
Older development builds of affine-server before this change do not skip higher versions.
Upgrade affine-server to a build with prefix verification before you apply v6, and target v0.27.5 for rollback.
Never edit an existing SQL migration file. Add a new versioned file instead.
3. Session and Lock Compatibility
- Share
SessionRedis(base_db + 2) withMutexLock:<resource>keys and atomic Lua scripts. - Prefix new worker-only Redis keys with
v2:to avoid collisions. - Drain active workers before you release tracked leases on shutdown.
- Set
AFFINE_CHANNEL=canaryonaffine-serverwhereverv0.27.5usesAFFINE_ENV=devfor the canary date client version window. affine-serverhashes spoofed request-tracker headers longer than 256 bytes tosha256:<hex>; normal session IDs, IPs, andCF-Rayvalues (<= 256bytes) share exactthrottler:<tracker>;<tier>Redis keys withv0.27.5.
4. Document Lifecycle Coexistence
- Startup on an existing
v0.27.5database accepts a missing globalworkspace_doc_lifecycle_activationcheckpoint (defaultv1sync protocol) or a checkpoint withstatus = 'active'. - Startup rejects any other
workspace_doc_lifecycle_activationcheckpoint status without modifying the database. - While the checkpoint is absent, search and sync read the legacy workspace root document inventory.
5. Blob and Storage Coexistence
- Serialize blob writes and deletes with per-object advisory locks outside the pooled connection.
- Keep local and S3 object key layouts identical to
v0.27.5. - Keep
v0.27.5workspace storage reconciliation active during mixed rollout untilaffine-serverowns orphan object sweeps. provider: "assetpack"enablesconfig.precomp2 = trueby default (writingPCF2 v2recipes while decodingv0.27.5PCF2 v1,PCF2 v2, and raw FastCDC chunks). Setconfig.precomp2 = falseduring mixed rollout withv0.27.5or while keeping a rollback window tov0.27.5so newly written objects remain readable byv0.27.5.AssetpackBlobStoragebounds total decoded transform output per read to512 MiB(DECODE_MAX_TOTAL_OUTPUT_BYTES, 4x the128 MiBFileTransformConfig::fast()write transform cap). Legacyv0.27.5PCF2 v1PNG objects whose uncompressed pixel stream exceeds512 MiB(for example RGB images above roughly13,000 x 13,000or RGBA images above roughly11,500 x 11,500) remain intact on disk, and reading them returns adecode output exceeds budgeterror instead of allocating unbounded memory.
6. Search Projection v6 and Dual-Mode Lock Fence
- Run only one search maintainer against a database at a time.
- Keep
indexer.enabled=falseon allv0.27.5nodes before you setAFFINE_INDEXER_ENABLED=true. affine-serverreads search settings from environment variables and CLI flags only, not from adminindexer.*config.- To roll back to
v0.27.5search, stop or disable allaffine-serversearch workers. - Wait 90 seconds until
search_projection.lockless_v2_active()returnsfalse, then runSELECT pg_current_xact_id()in a transaction to commit a marker XID. - Wait until
pg_snapshot_xmin(pg_current_snapshot())exceeds that marker XID so steady-state writers drain, then enablev0.27.5search.
Lock transition rules:
search_projection_v6.sqlrunsCREATE OR REPLACE FUNCTIONstatements only and takes no table locks.- The
server-searchworker renewssearch_projection_lockless_v2every 15 seconds with a 90 second expiry inmetadata.lease_expires_at. - When more than 30 seconds remain on the lease, triggers take only
search-projection-ws:<workspace_id>. - During the final 30 second bridge window, triggers take both
search-projection-generationandsearch-projection-ws:<workspace_id>.
Trigger and fence rules:
- Per-workspace orphan GC stops when 30 seconds or less remain on the lease.
- Multi-workspace permission updates lock workspace keys in
LEASTthenGREATESTorder to prevent deadlocks. - The two-step
fenceXiddiscovery fence requires writers to useREAD COMMITTEDisolation. - In steady state, ordinary document snapshot writes skip redundant updates to
search_projection.workspace_states. - Generation creation and activation take only
search-projection-lifecycle.
Orphan GC takes only search-projection-ws:<workspace_id> with a source_version <= H bound.
If all server-search workers stop, triggers revert to the global shared lock after 90 seconds.
Set idle_in_transaction_session_timeout to >= 60s on the legacy database role.
v0.27.5 lazy compaction can wait up to 60 seconds for a Redis lock.
This timeout still bounds idle transactions that stall pg_snapshot_xmin.