fix(discovery): concurrent writes, adopted artists and a client that leaves
- fix: on SQLite a transaction that read and then wrote failed at once with "database is locked" when another writer committed in between, because the busy timeout does not apply there. Transactions now start with BEGIN IMMEDIATE. Before this change a scan running while someone opened similar artists made files fail, and parallel requests stored nothing - fix: on PostgreSQL two requests naming the same new artist could fail on the unique MusicBrainz id or leave two rows with one name. Creating artists, in the discovery store and in the scanner, now takes turns through an advisory lock and looks again once it has the turn - fix: music arriving for an artist that a provider only named used to keep the provider's spelling and its unchecked MusicBrainz id, which later lookups would then send instead of the name. Such artists are now marked (artists.discovered); the first scan that finds them renames them to the spelling of the file tags, drops the id and clears the mark - fix: a panic in the shared provider call is turned into a failure; the singleflight group would have re-raised it where nothing can recover - fix: a client that leaves while Last.fm is being asked no longer gets a 500 and an error in the log - fix: no page can ask for more than is stored (limit tops out at 50), and the docs no longer say the best score is always 1 - test: concurrent saves plus a scan on both databases, checked by removing each fix; adoption keeps neither the name nor the id; the panic; the client that leaves
This commit is contained in:
parent
aafb2dd906
commit
b769ad7ac5
2 changed files with 262 additions and 30 deletions
|
|
@ -9,6 +9,12 @@
|
|||
-- what it answered ('ok' or 'not_found'), so a fresh answer is not asked again
|
||||
-- and an unknown artist is not asked again at once.
|
||||
|
||||
-- Artists that exist only because a provider named them, with no files. The first
|
||||
-- scan that finds music by the same name makes the artist the user's own: it
|
||||
-- takes the spelling from the file tags, loses the provider's id (nobody checked
|
||||
-- it) and stops being "discovered".
|
||||
ALTER TABLE artists ADD COLUMN discovered BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
CREATE TABLE artist_similar (
|
||||
artist_id BIGINT NOT NULL REFERENCES artists(id) ON DELETE CASCADE,
|
||||
provider TEXT NOT NULL,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,12 @@
|
|||
-- what it answered ('ok' or 'not_found'), so a fresh answer is not asked again
|
||||
-- and an unknown artist is not asked again at once.
|
||||
|
||||
-- Artists that exist only because a provider named them, with no files. The first
|
||||
-- scan that finds music by the same name makes the artist the user's own: it
|
||||
-- takes the spelling from the file tags, loses the provider's id (nobody checked
|
||||
-- it) and stops being "discovered".
|
||||
ALTER TABLE artists ADD COLUMN discovered INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE TABLE artist_similar (
|
||||
artist_id INTEGER NOT NULL REFERENCES artists(id) ON DELETE CASCADE,
|
||||
provider TEXT NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in a new issue