forked from Furumi/furumi-web
Publish matched import entries into private playlists over Device Sync
Each source playlist gets an ordinary private playlist, created with its
PlaylistCreated operation in one transaction even when nothing matched.
Matched entries follow in source order, at most 200 per transaction: the
playlist row, the item register, the existing PlaylistTrackAdded operation
and a receipt are written together, so fed_sync_ops serves as the outbox
and an interrupted batch leaves nothing behind. Locks are taken in a fixed
order (per-user advisory lock, import lease, playlist, fed-device identity,
registers). Registers are only inserted; an item the playlist has or had,
a removal committed to the journal but not yet applied, a repeat or a
receipt keep the publisher from adding it again. A deleted target pauses
publication until POST .../playlists/{pid}/recreate; POST .../resync
retries unmatched entries and appends new matches at the end.
Before each batch the outgoing Device Sync line is measured by serializing
the same parts the exchange sends. Tracks and new playlists are published
while the music snapshot stays within library_import_sync_budget (2 MiB)
and the whole line within 7 MiB; the rest waits as deferred_sync_limit.
Device Sync gets local helpers only: create_owned_playlist_tx is extracted
from the playlist handler, append_in_transaction takes an explicit
position, the two operations have in-transaction variants on
append_local_op, and applying a playlist item writes its register under an
atomic last-writer-wins condition and its playlist row in the same
transaction, so concurrent operations cannot make them diverge. The
protocol and its formats are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f10e384650
commit
4d6a1513d9
13 files changed
+3316
-45
No files matched your search
@@ -169,6 +169,18 @@ pass, a stopped node, manual choices with tampered candidates, and cancellation
|
||||
that leaves no catalogue request running. The database needs the `pg_trgm`
|
||||
extension; the tests install it into `public`.
|
||||
|
||||
The publisher tests (`src/library_import/tests/publisher.rs`) run against the
|
||||
Device Sync tables of the same schema. They cover source order, repeats, empty
|
||||
playlists, a second pass that adds nothing, Resync appending at the end, tracks
|
||||
removed by the user or by a committed but not yet applied operation, deleted
|
||||
target playlists and recreation, an entry failing after its operation was
|
||||
recorded, registers written concurrently, deletions from the web and from
|
||||
another device during a batch, older operations that arrive during a batch,
|
||||
concurrent operations that must keep registers and playlist rows consistent,
|
||||
two imports of one user publishing in turn, and the Device Sync budget for
|
||||
tracks and playlists. `library_import_measures_the_outgoing_device_sync_line`
|
||||
prints the measured line for 3,200 published tracks with `--nocapture`.
|
||||
|
||||
`cargo test federation::client` checks bounded artist catalogue lookups without a
|
||||
database: at most 16 owners and the given number of parallel requests, timeouts,
|
||||
errors, oversized catalogues, and that dropping a lookup stops its search and
|
||||
|
||||
Reference in new issue
Block a user