-
Bug
-
Resolution: Fixed
-
Normal
-
None
-
None
-
None
This seems to be a crash caused when there's two simultaneous attempts to rate the same entity by the same user. Ratings run in transactions that first check whether the rating does exist, and then either INSERT or UPDATE accordingly. But two concurrent transactions could be checking, then running INSERT at the same time, and the second of them would fail with this ISE.
Sentry Issue: MUSICBRAINZ-SERVER-6P
None: Failed query: 'INSERT INTO recording_rating_raw (rating, recording, editor) VALUES (?, ?, ?)' (100 32697996 2310585) 23505 DBD::Pg::st execute failed: ERROR: duplicate key value violates unique constraint "recording_rating_raw_pkey" DETAIL: Key (recording, editor)=(32697996, 2310585) already exists. [for Statement "INSERT INTO recording_rating_raw (rating, recording, editor) VALUES (?, ?, ?)" with ParamValues: 1='100', 2='32697996', 3='2310585'] Sql::catch {...} (MusicBrainz::Server::Exceptions::DatabaseError=HASH(0x556db8699d20)) called at /home/musicbrainz/carton-local/lib/perl5/Try/Tiny.pm line 123 Try::Tiny::try(CODE(0x556db8462250), Try::Tiny::Catch=REF(0x556db8cb6830)) called at lib/Sql.pm line 117 Sql::do(Sql=HASH(0x556db87f8a50), "INSERT INTO recording_rating_raw (rating, recording, editor)\x{a}"..., 100, 32697996, 2310585) called at lib/MusicBrainz/Server/Data/Rating.pm line 155 MusicBrainz::Server::Data::Rating::__ANON__() called at lib/Sql.pm line 322 Sql::try {...} () called at /home/musicbrainz/carton-local/lib/perl5/Try/Tiny.pm line 102 eval {...} called at /home/musicbrainz/carton-local/lib/perl5/Try/Tiny.pm line 93 Try::Tiny::try(CODE(0x556db89300a8), Try::Tiny::Catch=REF(0x556db878bf70)) called at lib/Sql.pm line 335 Sql::_auto_transaction(CODE(0x556db87f5948), Sql=HASH(0x556db87f8a50)) called at lib/Sql.pm line 340 Sql::_run_in_transaction_one(CODE(0x556db87f5948), Sql=HASH(0x556db87f8a50)) called at lib/Sql.pm line 355 Sql::run_in_transaction(CODE(0x556db87f5948), Sql=HASH(0x556db87f8a50)) called at lib/MusicBrainz/Server/Data/Rating.pm line 182 MusicBrainz::Server::Data::Rating::update(MusicBrainz::Server::Data::Rating=HASH(0x556db8d4fdc0), 2310585, 32697996, 100) called at lib/MusicBrainz/Server/Controller/Rating.pm line 47 MusicBrainz::Server::Controller::Rating::rate(MusicBrainz::Server::Controller::Rating=HASH(0x556db6485b10), MusicBrainz::Server=HASH(0x556db8db73a0)) called at /home/musicbrainz/carton-local/lib/perl5/Catalyst/Action.pm line 369 Catalyst::Action::execute(Catalyst::Action=HASH(0x556db673ed80), MusicBrainz::Server::Controller::Rating=HASH(0x556db6485b10), MusicBrainz::Server=HASH(0x556db8db73a0)) called at /home/musicbrainz/carton-local/lib/perl5/Catalyst.pm line 2060 eval {...} called at /home/musicbrainz/carton-local/lib/perl5/Catalyst.pm line 2060 Catalyst::execute(MusicBrainz::Server=HASH(0x556db8db73a0), "MusicBrainz::Server::Controller::Rating", Catalyst::Action=HASH(0x556db673ed80)) called at lib/Catalyst/Plugin/ErrorInfo.pm line 34 Catalyst::Plugin::ErrorInfo::execute(MusicBrainz::Server=HASH(0x556db8db73a0), "MusicBrainz::Server::Controller::Rating", Catalyst::Action=HASH(0x556db673ed80)) called at /home/musicbrainz/carton-local/lib/perl5/Catalyst/Action.pm line 364 Catalyst::Action::dispatch(Catalyst::Action=HASH(0x556db673ed80), MusicBrainz::Server=HASH(0x556db8db73a0)) called at /home/musicbrainz/carton-local/lib/perl5/Catalyst/Controller.pm line 170 Catalyst::Controller::_ACTION(MusicBrainz::Server::Controller::Rating=HASH(0x556db6485b10), MusicBrainz::Server=HASH(0x556db8db73a0)) called at /home/musicbrainz/carton-local/lib/perl5/Catalyst/Action.pm line 369 Catalyst::Action::execute(Catalyst::Action=HASH(0x556db672a008), MusicBrainz::Server::Controller::Rating=HASH(0x556db6485b10), MusicBrainz::Server=HASH(0x556db8db73a0)) called at /home/musicbrainz/carton-local/lib/perl5/Catalyst.pm line 2060 eval {...} called at /home/musicbrainz/carton-local/lib/perl5/Catalyst.pm line 2060 Catalyst::execute(MusicBrainz::Server=HASH(0x556db8db73a0), "MusicBrainz::Server::Controller::Rating", Catalyst::Action=HASH(0x556db672a008)) called at lib/Catalyst/Plugin/ErrorInfo.pm line 34 Catalyst::Plugin::ErrorInfo::execute(MusicBrainz::Server=HASH(0x556db8db73a0), "MusicBrainz::Server::Controller::Rating", Catalyst::Action=HASH(0x556db672a008)) called at /home/musicbrainz/carton-local/lib/perl5/Catalyst/Action.pm line 364 Catalyst::Action::dispatch(Catalyst::Action=HASH(0x556db672a008), MusicBrainz::Server=HASH File "Rating.pm", line 182, in MusicBrainz::Server::Data::Rating::update }, $self->c->sql); File "Rating.pm", line 47, in Catalyst::dispatch my ($sum, $count) = $model->rating->update($c->user->id, $entity_id, $rating); File "Server.pm", line 388, in MusicBrainz::Server::__ANON__ $c->$orig(@args) File "Server.pm", line 353, in MusicBrainz::Server::with_translations $code->(); File "Server.pm", line 389, in Class::MOP::Method::Wrapped::__ANON__ }); ... (2 additional frame(s) were not displayed)