Issue Details (XML | Word | Printable)

Key: MBS-3597
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Normal Normal
Assignee: Ian McEwen
Reporter: nikki
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
MusicBrainz Server

Internal Server Error (deadlock detected)

Created: 05/Oct/11 09:26 AM   Updated: 20/Aug/12 09:51 AM   Resolved: 20/Aug/12 09:51 AM
Component/s: Release editor
Affects Version/s: None
Fix Version/s: Bug fixes, 2012-08-20

Issue Links:
Duplicate
 


 Description  « Hide
Caught exception in MusicBrainz::Server::Controller::ReleaseEditor::Edit->edit "Failed query:
	'UPDATE editor SET edits_accepted = edits_accepted + 1 WHERE id = ?'
	(53705)
DBD::Pg::st execute failed: ERROR:  deadlock detected
DETAIL:  Process 11487 waits for ShareLock on transaction 96888350; blocked by process 12561.
Process 12561 waits for ExclusiveLock on tuple (6975,37) of relation 1514451 of database 1416385; blocked by process 11487.
HINT:  See server log for query details. at /home/musicbrainz/musicbrainz-server/script/../lib/Sql.pm line 103.

 at /home/musicbrainz/musicbrainz-server/script/../lib/Sql.pm line 109
	Sql::__ANON__('DBD::Pg::st execute failed: ERROR:  deadlock detected\x{a}DETAIL:...') called at /usr/local/share/perl/5.10.1/Try/Tiny.pm line 100
	Try::Tiny::try('CODE(0xd9e37e0)', 'Try::Tiny::Catch=REF(0xd9e35a0)') called at /home/musicbrainz/musicbrainz-server/script/../lib/Sql.pm line 110
	Sql::do('Sql=HASH(0xa30afe8)', 'UPDATE editor SET edits_accepted = edits_accepted + 1 WHERE i...', 53705) called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Data/Editor.pm line 371
	MusicBrainz::Server::Data::Editor::credit('MusicBrainz::Server::Data::Editor=HASH(0xd9b0b10)', 53705, 2) called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Data/Edit.pm line 590
	MusicBrainz::Server::Data::Edit::_close('MusicBrainz::Server::Data::Edit=HASH(0x889b428)', 'MusicBrainz::Server::Edit::Release::Edit=HASH(0xd9e34c8)', 'CODE(0xd9b72d0)') called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Data/Edit.pm line 558
	MusicBrainz::Server::Data::Edit::accept('MusicBrainz::Server::Data::Edit=HASH(0x889b428)', 'MusicBrainz::Server::Edit::Release::Edit=HASH(0xd9e34c8)') called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Data/Edit.pm line 416
	MusicBrainz::Server::Data::Edit::__ANON__() called at /home/musicbrainz/musicbrainz-server/script/../lib/Sql.pm line 264
	Sql::__ANON__() called at /usr/local/share/perl/5.10.1/Try/Tiny.pm line 76
	eval {...} called at /usr/local/share/perl/5.10.1/Try/Tiny.pm line 67
	Try::Tiny::try('CODE(0xd9b2be0)', 'Try::Tiny::Catch=REF(0xd9c6ab8)') called at /home/musicbrainz/musicbrainz-server/script/../lib/Sql.pm line 277
	Sql::_auto_transaction('CODE(0xd988810)', 'Sql=HASH(0xa30afe8)') called at /home/musicbrainz/musicbrainz-server/script/../lib/Sql.pm line 282
	Sql::_run_in_transaction_one('CODE(0xd988810)', 'Sql=HASH(0xa30afe8)') called at /home/musicbrainz/musicbrainz-server/script/../lib/Sql.pm line 296
	Sql::run_in_transaction('CODE(0xd988810)', 'Sql=HASH(0xa30afe8)') called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Data/Edit.pm line 421
	MusicBrainz::Server::Data::Edit::create('MusicBrainz::Server::Data::Edit=HASH(0x889b428)', 'edit_type', 32, 'editor_id', 53705, 'packaging_id', 1, 'privileges', 41, ...) called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 1203
	MusicBrainz::Server::Wizard::ReleaseEditor::__ANON__('edit_type', 32, 'editor_id', 53705, 'packaging_id', 1, 'privileges', 41, 'date', ...) called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 1228
	eval {...} called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 1227
	MusicBrainz::Server::Wizard::ReleaseEditor::_create_edit('MusicBrainz::Server::Wizard::ReleaseEditor::Edit=HASH(0xbef2f68)', 'CODE(0xc43ba00)', 32, 53705, 'privileges', 41, 'packaging_id', 1, 'date', ...) called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 1204
	MusicBrainz::Server::Wizard::ReleaseEditor::_submit_edit('MusicBrainz::Server::Wizard::ReleaseEditor::Edit=HASH(0xbef2f68)', 32, undef, 'packaging_id', 1, 'date', 'HASH(0xc337ef0)', 'name', 'Crazy', ...) called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 790
	MusicBrainz::Server::Wizard::ReleaseEditor::__ANON__(32, undef, 'packaging_id', 1, 'date', 'HASH(0xc337ef0)', 'name', 'Crazy', 'barcode', ...) called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor/Edit.pm line 39
	MusicBrainz::Server::Wizard::ReleaseEditor::Edit::__ANON__('MusicBrainz::Server::Wizard::ReleaseEditor::Edit=HASH(0xbef2f68)', 'data', 'HASH(0xc46a198)', 'create_edit', 'CODE(0xbf71d68)', 'edit_note', undef, 'previewing', '', ...) called at /usr/local/lib/perl/5.10.1/Moose.pm line 110
	Moose::inner() called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 862
	MusicBrainz::Server::Wizard::ReleaseEditor::create_edits('MusicBrainz::Server::Wizard::ReleaseEditor::Edit=HASH(0xbef2f68)', 'data', 'HASH(0xc46a198)', 'create_edit', 'CODE(0xbf71d68)', 'edit_note', undef, 'previewing', '', ...) called at /usr/local/lib/perl/5.10.1/Moose/Meta/Method/Augmented.pm line 46
	MusicBrainz::Server::Wizard::ReleaseEditor::Edit::create_edits('MusicBrainz::Server::Wizard::ReleaseEditor::Edit=HASH(0xbef2f68)', 'data', 'HASH(0xc46a198)', 'create_edit', 'CODE(0xbf71d68)', 'edit_note', undef, 'previewing', '', ...) called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 791
	MusicBrainz::Server::Wizard::ReleaseEditor::prepare_edits('MusicBrainz::Server::Wizard::ReleaseEditor::Edit=HASH(0xbef2f68)') called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 94
	MusicBrainz::Server::Wizard::ReleaseEditor::run('MusicBrainz::Server::Wizard::ReleaseEditor::Edit=HASH(0xbef2f68)') called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Controller/ReleaseEditor/Edit.pm line 17
	MusicBrainz::Server::Controller::ReleaseEditor::Edit::edit('MusicBrainz::Server::Controller::ReleaseEditor::Edit=HASH(0x9...', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst/Action.pm line 65
	Catalyst::Action::execute('Catalyst::Action=HASH(0x9db0c90)', 'MusicBrainz::Server::Controller::ReleaseEditor::Edit=HASH(0x9...', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1665
	eval {...} called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1665
	Catalyst::execute('MusicBrainz::Server=HASH(0xc47b8f0)', 'MusicBrainz::Server::Controller::ReleaseEditor::Edit', 'Catalyst::Action=HASH(0x9db0c90)') called at /usr/local/share/perl/5.10.1/Catalyst/Plugin/StackTrace.pm line 94
	Catalyst::Plugin::StackTrace::execute('MusicBrainz::Server=HASH(0xc47b8f0)', 'MusicBrainz::Server::Controller::ReleaseEditor::Edit', 'Catalyst::Action=HASH(0x9db0c90)') called at /usr/local/share/perl/5.10.1/Catalyst/Action.pm line 60
	Catalyst::Action::dispatch('Catalyst::Action=HASH(0x9db0c90)', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst/ActionChain.pm line 39
	Catalyst::ActionChain::dispatch('Catalyst::ActionChain=HASH(0xc349c20)', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst/Controller.pm line 110
	Catalyst::Controller::_ACTION('MusicBrainz::Server::Controller::ReleaseEditor::Add=HASH(0x9b...', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst/Action.pm line 65
	Catalyst::Action::execute('Catalyst::Action=HASH(0x9da51a0)', 'MusicBrainz::Server::Controller::ReleaseEditor::Add=HASH(0x9b...', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1665
	eval {...} called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1665
	Catalyst::execute('MusicBrainz::Server=HASH(0xc47b8f0)', 'MusicBrainz::Server::Controller::ReleaseEditor::Add', 'Catalyst::Action=HASH(0x9da51a0)') called at /usr/local/share/perl/5.10.1/Catalyst/Plugin/StackTrace.pm line 94
	Catalyst::Plugin::StackTrace::execute('MusicBrainz::Server=HASH(0xc47b8f0)', 'MusicBrainz::Server::Controller::ReleaseEditor::Add', 'Catalyst::Action=HASH(0x9da51a0)') called at /usr/local/share/perl/5.10.1/Catalyst/Action.pm line 60
	Catalyst::Action::dispatch('Catalyst::Action=HASH(0x9da51a0)', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst/Dispatcher.pm line 257
	Catalyst::Dispatcher::_do_forward('Catalyst::Dispatcher=HASH(0x22d6230)', 'forward', 'MusicBrainz::Server=HASH(0xc47b8f0)', '_ACTION') called at /usr/local/share/perl/5.10.1/Catalyst/Dispatcher.pm line 237
	Catalyst::Dispatcher::forward('Catalyst::Dispatcher=HASH(0x22d6230)', 'MusicBrainz::Server=HASH(0xc47b8f0)', '_ACTION') called at /usr/local/share/perl/5.10.1/Catalyst.pm line 377
	Catalyst::forward('MusicBrainz::Server=HASH(0xc47b8f0)', '_ACTION') called at /usr/local/share/perl/5.10.1/Catalyst/Controller.pm line 84
	Catalyst::Controller::_DISPATCH('MusicBrainz::Server::Controller::ReleaseEditor::Add=HASH(0x9b...', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst/Action.pm line 65
	Catalyst::Action::execute('Catalyst::Action=HASH(0x9ec61b0)', 'MusicBrainz::Server::Controller::ReleaseEditor::Add=HASH(0x9b...', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1665
	eval {...} called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1665
	Catalyst::execute('MusicBrainz::Server=HASH(0xc47b8f0)', 'MusicBrainz::Server::Controller::ReleaseEditor::Add', 'Catalyst::Action=HASH(0x9ec61b0)') called at /usr/local/share/perl/5.10.1/Catalyst/Plugin/StackTrace.pm line 94
	Catalyst::Plugin::StackTrace::execute('MusicBrainz::Server=HASH(0xc47b8f0)', 'MusicBrainz::Server::Controller::ReleaseEditor::Add', 'Catalyst::Action=HASH(0x9ec61b0)') called at /usr/local/share/perl/5.10.1/Catalyst/Action.pm line 60
	Catalyst::Action::dispatch('Catalyst::Action=HASH(0x9ec61b0)', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst/Dispatcher.pm line 257
	Catalyst::Dispatcher::_do_forward('Catalyst::Dispatcher=HASH(0x22d6230)', 'forward', 'MusicBrainz::Server=HASH(0xc47b8f0)', '/release_editor/_DISPATCH') called at /usr/local/share/perl/5.10.1/Catalyst/Dispatcher.pm line 237
	Catalyst::Dispatcher::forward('Catalyst::Dispatcher=HASH(0x22d6230)', 'MusicBrainz::Server=HASH(0xc47b8f0)', '/release_editor/_DISPATCH') called at /usr/local/share/perl/5.10.1/Catalyst.pm line 377
	Catalyst::forward('MusicBrainz::Server=HASH(0xc47b8f0)', '/release_editor/_DISPATCH') called at /usr/local/share/perl/5.10.1/Catalyst/Dispatcher.pm line 105
	Catalyst::Dispatcher::dispatch('Catalyst::Dispatcher=HASH(0x22d6230)', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1611
	Catalyst::dispatch('MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst/Plugin/Static/Simple.pm line 76
	Class::MOP::Class:::around('CODE(0x29322f0)', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 159
	Class::MOP::Method::Wrapped::__ANON__('MusicBrainz::Server=HASH(0xc47b8f0)') called at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server.pm line 273
	Class::MOP::Class:::around('CODE(0xa12c788)', 'MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 159
	Class::MOP::Method::Wrapped::__ANON__('MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 89
	MusicBrainz::Server::dispatch('MusicBrainz::Server=HASH(0xc47b8f0)') called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1952
	eval {...} called at /usr/local/share/perl/5.10.1/Catalyst.pm line 1943
	Catalyst::handle_request('MusicBrainz::Server', 'env', 'HASH(0x3696b90)') called at /home/musicbrainz/musicbrainz-server/script/../lib/Catalyst/Plugin/AutoRestart.pm line 119
	Catalyst::Plugin::AutoRestart::handle_request('MusicBrainz::Server', 'env', 'HASH(0x3696b90)') called at /usr/local/share/perl/5.10.1/Catalyst/Engine/FastCGI.pm line 149
	Catalyst::Engine::FastCGI::run('Catalyst::Engine::FastCGI=HASH(0x3661f70)', 'MusicBrainz::Server', '127.0.0.1:55901', 'HASH(0x11bfd48)') called at /usr/local/share/perl/5.10.1/Catalyst.pm line 2396
	Catalyst::run('MusicBrainz::Server', '127.0.0.1:55901', 'HASH(0x11bfd48)') called at ./script/musicbrainz_fastcgi.pl line 28
 at /home/musicbrainz/musicbrainz-server/script/../lib/Sql.pm line 277
	...propagated at /home/musicbrainz/musicbrainz-server/script/../lib/MusicBrainz/Server/Wizard/ReleaseEditor.pm line 1237."


Stack trace:
line 1237 MusicBrainz::Server::Wizard::ReleaseEditor
line 1204 MusicBrainz::Server::Wizard::ReleaseEditor
line 790 MusicBrainz::Server::Wizard::ReleaseEditor
line 39 MusicBrainz::Server::Wizard::ReleaseEditor::Edit
line 862 MusicBrainz::Server::Wizard::ReleaseEditor
line 791 MusicBrainz::Server::Wizard::ReleaseEditor
line 94 MusicBrainz::Server::Wizard::ReleaseEditor
line 17 MusicBrainz::Server::Controller::ReleaseEditor::Edit
line 273 MusicBrainz::Server


Request data: 
$VAR1 = {
          'query_parameters' => {},
          'body_parameters' => {
                                 'save' => 'Enter edit',
                                 'wizard_page_id' => '4',
                                 'edit_note' => '',
                                 'as_auto_editor' => '1',
                                 'wizard_session_id' => '0.7236968333108'
                               }
        };

URL: http://musicbrainz.org/release/ef136470-8f63-449c-bc33-91e104f1eefc/edit



Sort Order: Ascending order - Click to sort in descending order
nikki added a comment - 21/Nov/11 08:02 PM

I've been getting deadlocks in several places (edit release group, edit release and edit url are the places I've seen it so far), but I seem to be getting huge amounts while trying to edit Amazon URLs. I'm already up to 48 in just two hours.

As I mentioned on IRC a while back, I didn't see a single deadlock between the launch of NGS and when I reported this ticket.

Rob thought vacuuming the database might help, but it doesn't seem to have.


Brian Schweitzer added a comment - 22/Nov/11 05:08 AM

I've been getting them as well, about every 4th artist split edit I've tried to enter in the past day or so.


Oliver Charles added a comment - 24/Nov/11 01:19 PM

My only guess as to what is happening here is:

  • Edit X:
    • Insert the edit
    • Apply the edit (as it's an auto-edit) and do an UPDATE to whatever needs it
    • Credit the editor
  • Edit Y
    • Insert the edit
    • Apply the edit (as it's an auto-edit) and do an UPDATE to whatever needs it
    • Credit the editor

Now, if Edit X takes a while to make its changes, Edit Y could rush ahead and credit the editor. Now, when edit X comes to credit the editor, there is already a lock on this row (implicit, from the UPDATE on the editor table), and this happens.

I don't know how to fix this problem though. Presumably we need to lock something, but I don't know what that something is. We could lock the editor row at the start of an edit, so only that only one edit can be applied at once, and force the other edit to wait until this one has applied?


Michael Wiencek added a comment - 06/Jan/12 03:45 AM

I get tons of deadlocks when I have multiple release editor sessions open (>10) and I cycle through the tabs to submit them all at once (which is a common workflow when I have to edit the same thing on many releases at once). A bunch of the requests always end in deadlock for me, so it's very easy to reproduce using this method.


Oliver Charles added a comment - 12/Jan/12 10:43 PM

As this issue has been delayed, I am moving it back to be rescheduled.


Ian McEwen added a comment - 10/Jul/12 12:40 AM

I think pessimistically locking the editor table at the start of the edit transaction is the correct thing to do here, if ocharles' assessment is correct as to the cause.


Ian McEwen added a comment - 10/Jul/12 07:28 PM
Internal Server Error

Oops, something went wrong!

Error: 

Caught exception in MusicBrainz::Server::Controller::URL->edit "The edit could not be created.
POST: $VAR1 = {
          'edit-url.as_auto_editor' => '1',
          'edit-url.description' => '',
          'edit-url.url' => 'http://itunes.apple.com/album/id506043907',
          'edit-url.edit_note' => ''
        };

Exception:$VAR1 = 'DBD::Pg::st execute failed: ERROR:  deadlock detected
DETAIL:  Process 29659 waits for ShareLock on tuple (10540,33) of relation 1514451 of database 1416385; blocked by process 29645.
Process 29645 waits for ShareLock on transaction 444400218; blocked by process 29217.
Process 29217 waits for ExclusiveLock on tuple (10540,33) of relation 1514451 of database 1416385; blocked by process 29659.
HINT:  See server log for query details.
CONTEXT:  SQL statement "SELECT 1 FROM ONLY "musicbrainz"."editor" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x" at lib/Sql.pm line 409.
 at lib/Sql.pm line 423
	Sql::__ANON__(\'DBD::Pg::st execute failed: ERROR:  deadlock detected\\x{a}DETAIL:...\') called at local/lib/perl5/Try/Tiny.pm line 100
	Try::Tiny::try(\'CODE(0xed8d330)\', \'Try::Tiny::Catch=REF(0xed79a90)\') called at lib/Sql.pm line 424
	Sql::_select_list(\'Sql=HASH(0xb7016e8)\', \'INSERT INTO edit (status,data,close_time,open_time,editor,typ...\', \'ARRAY(0x4d26fa0)\', \'arrayref\', \'CODE(0x4d27018)\') called at lib/Sql.pm line 443
	Sql::select_list_of_lists(\'Sql=HASH(0xb7016e8)\', \'INSERT INTO edit (status,data,close_time,open_time,editor,typ...\', 1, \'{"entity":{"name":"http://itunes.apple.com/album/they-found-y...\', undef, \'DateTime=HASH(0xed7a2a0)\', 53705, 101, \'DateTime=HASH(0xed7a660)\', ...) called at lib/Sql.pm line 377
	Sql::select_single_column_array(\'Sql=HASH(0xb7016e8)\', \'INSERT INTO edit (status,data,close_time,open_time,editor,typ...\', 1, \'{"entity":{"name":"http://itunes.apple.com/album/they-found-y...\', undef, \'DateTime=HASH(0xed7a2a0)\', 53705, 101, \'DateTime=HASH(0xed7a660)\', ...) called at lib/Sql.pm line 392
	Sql::select_single_value(\'Sql=HASH(0xb7016e8)\', \'INSERT INTO edit (status,data,close_time,open_time,editor,typ...\', 1, \'{"entity":{"name":"http://itunes.apple.com/album/they-found-y...\', undef, \'DateTime=HASH(0xed7a2a0)\', 53705, 101, \'DateTime=HASH(0xed7a660)\', ...) called at lib/Sql.pm line 146
	Sql::insert_row(\'Sql=HASH(0xb7016e8)\', \'edit\', \'HASH(0xed83de8)\', \'id\') called at lib/MusicBrainz/Server/Data/Edit.pm line 404
	MusicBrainz::Server::Data::Edit::create(\'MusicBrainz::Server::Data::Edit=HASH(0xa025e10)\', \'editor_id\', 53705, \'privileges\', 185, \'url\', \'http://itunes.apple.com/album/id506043907\', \'edit_type\', 101, ...) called at lib/MusicBrainz/Server/Controller.pm line 85
	MusicBrainz::Server::Controller::__ANON__() called at local/lib/perl5/Try/Tiny.pm line 76
	eval {...} called at local/lib/perl5/Try/Tiny.pm line 67
	Try::Tiny::try(\'CODE(0xc7657b0)\', \'Try::Tiny::Catch=REF(0xc7656d8)\') called at lib/MusicBrainz/Server/Controller.pm line 101
	MusicBrainz::Server::Controller::_insert_edit(\'MusicBrainz::Server::Controller::URL=HASH(0xb0bca68)\', \'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Form::URL=HASH(0x747f3e0)\', \'edit_type\', 101, \'url\', \'http://itunes.apple.com/album/id506043907\', \'description\', undef, ...) called at lib/MusicBrainz/Server/Controller.pm line 136
	MusicBrainz::Server::Controller::__ANON__() called at lib/Sql.pm line 277
	Sql::__ANON__() called at local/lib/perl5/Try/Tiny.pm line 76
	eval {...} called at local/lib/perl5/Try/Tiny.pm line 67
	Try::Tiny::try(\'CODE(0xc765438)\', \'Try::Tiny::Catch=REF(0xc680530)\') called at lib/Sql.pm line 290
	Sql::_auto_transaction(\'CODE(0xc7652d0)\', \'Sql=HASH(0xb7016e8)\') called at lib/Sql.pm line 295
	Sql::_run_in_transaction_one(\'CODE(0xc7652d0)\', \'Sql=HASH(0xb7016e8)\') called at lib/Sql.pm line 309
	Sql::run_in_transaction(\'CODE(0xc7652d0)\', \'Sql=HASH(0xb7016e8)\') called at lib/MusicBrainz/Server/Model/MB.pm line 17
	MusicBrainz::Server::Model::MB::with_transaction(\'MusicBrainz::Server::Model::MB=HASH(0x99c1be0)\', \'CODE(0xc7652d0)\') called at lib/MusicBrainz/Server/Controller.pm line 144
	MusicBrainz::Server::Controller::edit_action(\'MusicBrainz::Server::Controller::URL=HASH(0xb0bca68)\', \'MusicBrainz::Server=HASH(0xb6f3428)\', \'form\', \'URL\', \'type\', 101, \'item\', \'MusicBrainz::Server::Entity::URL=HASH(0xc3331d0)\', \'edit_args\', ...) called at lib/MusicBrainz/Server/Controller/Role/Edit.pm line 37
	Moose::Meta::Role::__ANON__::SERIAL::33::edit(\'MusicBrainz::Server::Controller::URL=HASH(0xb0bca68)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst/Action.pm line 65
	Catalyst::Action::execute(\'Catalyst::Action=HASH(0xb31c048)\', \'MusicBrainz::Server::Controller::URL=HASH(0xb0bca68)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst.pm line 1667
	eval {...} called at local/lib/perl5/Catalyst.pm line 1667
	Catalyst::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb31c048)\') called at local/lib/perl5/Catalyst/Plugin/StackTrace.pm line 94
	Catalyst::Plugin::StackTrace::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb31c048)\') called at lib/MusicBrainz/Server.pm line 306
	MusicBrainz::Server::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb31c048)\') called at local/lib/perl5/Catalyst/Action.pm line 60
	Catalyst::Action::dispatch(\'Catalyst::Action=HASH(0xb31c048)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst/ActionChain.pm line 38
	Catalyst::ActionChain::dispatch(\'Catalyst::ActionChain=HASH(0xbec37f8)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst/Controller.pm line 125
	Catalyst::Controller::_ACTION(\'MusicBrainz::Server::Controller::URL=HASH(0xb0bca68)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst/Action.pm line 65
	Catalyst::Action::execute(\'Catalyst::Action=HASH(0xb31a670)\', \'MusicBrainz::Server::Controller::URL=HASH(0xb0bca68)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst.pm line 1667
	eval {...} called at local/lib/perl5/Catalyst.pm line 1667
	Catalyst::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb31a670)\') called at local/lib/perl5/Catalyst/Plugin/StackTrace.pm line 94
	Catalyst::Plugin::StackTrace::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb31a670)\') called at lib/MusicBrainz/Server.pm line 306
	MusicBrainz::Server::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb31a670)\') called at local/lib/perl5/Catalyst/Action.pm line 60
	Catalyst::Action::dispatch(\'Catalyst::Action=HASH(0xb31a670)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 257
	Catalyst::Dispatcher::_do_forward(\'Catalyst::Dispatcher=HASH(0x3643780)\', \'forward\', \'MusicBrainz::Server=HASH(0xb6f3428)\', \'_ACTION\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 237
	Catalyst::Dispatcher::forward(\'Catalyst::Dispatcher=HASH(0x3643780)\', \'MusicBrainz::Server=HASH(0xb6f3428)\', \'_ACTION\') called at local/lib/perl5/Catalyst.pm line 342
	Catalyst::forward(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'_ACTION\') called at local/lib/perl5/Catalyst/Controller.pm line 99
	Catalyst::Controller::_DISPATCH(\'MusicBrainz::Server::Controller::URL=HASH(0xb0bca68)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst/Action.pm line 65
	Catalyst::Action::execute(\'Catalyst::Action=HASH(0xb316fe8)\', \'MusicBrainz::Server::Controller::URL=HASH(0xb0bca68)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst.pm line 1667
	eval {...} called at local/lib/perl5/Catalyst.pm line 1667
	Catalyst::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb316fe8)\') called at local/lib/perl5/Catalyst/Plugin/StackTrace.pm line 94
	Catalyst::Plugin::StackTrace::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb316fe8)\') called at lib/MusicBrainz/Server.pm line 306
	MusicBrainz::Server::execute(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'MusicBrainz::Server::Controller::URL\', \'Catalyst::Action=HASH(0xb316fe8)\') called at local/lib/perl5/Catalyst/Action.pm line 60
	Catalyst::Action::dispatch(\'Catalyst::Action=HASH(0xb316fe8)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 257
	Catalyst::Dispatcher::_do_forward(\'Catalyst::Dispatcher=HASH(0x3643780)\', \'forward\', \'MusicBrainz::Server=HASH(0xb6f3428)\', \'/url/_DISPATCH\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 237
	Catalyst::Dispatcher::forward(\'Catalyst::Dispatcher=HASH(0x3643780)\', \'MusicBrainz::Server=HASH(0xb6f3428)\', \'/url/_DISPATCH\') called at local/lib/perl5/Catalyst.pm line 342
	Catalyst::forward(\'MusicBrainz::Server=HASH(0xb6f3428)\', \'/url/_DISPATCH\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 105
	Catalyst::Dispatcher::dispatch(\'Catalyst::Dispatcher=HASH(0x3643780)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst.pm line 1613
	Catalyst::dispatch(\'MusicBrainz::Server=HASH(0xb6f3428)\') called at lib/MusicBrainz/Server.pm line 270
	Class::MOP::Class:::around(\'CODE(0x2e9f498)\', \'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/x86_64-linux-gnu-thread-multi/Class/MOP/Method/Wrapped.pm line 162
	Class::MOP::Method::Wrapped::__ANON__(\'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/x86_64-linux-gnu-thread-multi/Class/MOP/Method/Wrapped.pm line 91
	MusicBrainz::Server::dispatch(\'MusicBrainz::Server=HASH(0xb6f3428)\') called at local/lib/perl5/Catalyst.pm line 1963
	Catalyst::__ANON__() called at local/lib/perl5/Try/Tiny.pm line 76
	eval {...} called at local/lib/perl5/Try/Tiny.pm line 67
	Try::Tiny::try(\'CODE(0xbc1b8a8)\', \'Try::Tiny::Catch=REF(0xbe9ad50)\') called at local/lib/perl5/Catalyst.pm line 1969
	Catalyst::handle_request(\'MusicBrainz::Server\', \'env\', \'HASH(0xb6d7888)\') called at local/lib/perl5/Catalyst/Plugin/AutoRestart.pm line 114
	Catalyst::Plugin::AutoRestart::handle_request(\'MusicBrainz::Server\', \'env\', \'HASH(0xb6d7888)\') called at local/lib/perl5/Catalyst/Engine.pm line 856
	Catalyst::Engine::__ANON__(\'CODE(0xb6ece08)\') called at local/lib/perl5/Plack/Handler/FCGI.pm line 134
	Plack::Handler::FCGI::run(\'Plack::Handler::FCGI=HASH(0x133da30)\', \'CODE(0xb656008)\') called at local/lib/perl5/Plack/Loader.pm line 88
	Plack::Loader::run(\'Plack::Loader=HASH(0x1306e00)\', \'Plack::Handler::FCGI=HASH(0x133da30)\') called at local/lib/perl5/Plack/Runner.pm line 263
	Plack::Runner::run(\'Plack::Runner=HASH(0x1109808)\') called at local/bin/plackup line 10
';
 at lib/MusicBrainz/Server/Controller.pm line 101
 at lib/Sql.pm line 290"


Stack trace:
line 17 MusicBrainz::Server::Model::MB
line 144 MusicBrainz::Server::Controller
line 37 MusicBrainz::Server::Controller::Role::Edit
line 306 MusicBrainz::Server
line 306 MusicBrainz::Server
line 306 MusicBrainz::Server
line 270 MusicBrainz::Server


Request data: 
$VAR1 = {
          'query_parameters' => {},
          'body_parameters' => {
                                 'edit-url.as_auto_editor' => '1',
                                 'edit-url.description' => '',
                                 'edit-url.url' => 'http://itunes.apple.com/album/id506043907',
                                 'edit-url.edit_note' => ''
                               }
        };
            

URL: http://musicbrainz.org/url/70d79d44-db58-4185-92c7-a2c14f08ea1e/edit

This appears to be the "other end" of this deadlock.


Ian McEwen added a comment - 10/Jul/12 07:30 PM

Hm, maybe not, since that one's showing a three-way deadlock rather than the two-link one above.


Ian McEwen added a comment - 10/Jul/12 07:57 PM

Okay, researching further, and getting another stacktrace from nikki to match the one two comments up: one of these deadlocks is happening in Data::Edit::create when it's entering the edit, and the other is happening later when it credits the editor. Fix will be slightly different than what I'd pushed before, but it'll be: if the edit's an autoedit, lock the editor row before inserting the edit, so the transaction doesn't try to do a lock escalation (from Share, needed for inserting the edit, to Exclusive, needed for updating the editor row), which is what's causing the deadlock.


Nicolás Tamargo added a comment - 11/Jul/12 05:00 AM

Caught exception in MusicBrainz::Server::Controller::Recording->edit "The edit could not be created.
POST: $VAR1 = {
'edit-recording.edit_note' => '',
'edit-recording.artist_credit.names.0.artist.id' => '184151',
'edit-recording.artist_credit.names.0.artist.name' => "\x{5927}\x{8429}\x{5eb7}\x{53f8}",
'edit-recording.artist_credit.names.0.name' => "\x{5927}\x{8429}\x{5eb7}\x{53f8}",
'edit-recording.comment' => '',
'edit-recording.artist_credit.names.0.join_phrase' => '',
'edit-recording.length' => '3:23',
'edit-recording.as_auto_editor' => '1',
'edit-recording.name' => 'Schottish-choro',
'gc-roman' => 'on',
'gc-mode' => 'Sentence'
};

Exception:$VAR1 = 'Failed query:
\'UPDATE recording SET artist_credit = ? WHERE id = ?\'
(184151 9363124)
DBD::Pg::st execute failed: ERROR: deadlock detected
DETAIL: Process 6467 waits for ShareLock on transaction 444979342; blocked by process 6482.
Process 6482 waits for ShareLock on transaction 444979363; blocked by process 6467.
HINT: See server log for query details.
CONTEXT: SQL statement "SELECT 1 FROM ONLY "musicbrainz"."artist_credit" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x" at lib/Sql.pm line 103.

at lib/Sql.pm line 109
Sql::_ANON_(\'DBD::Pg::st execute failed: ERROR: deadlock detected\\x{a}DETAIL:...\') called at local/lib/perl5/Try/Tiny.pm line 100
Try::Tiny::try(\'CODE(0x10560f60)\', \'Try::Tiny::Catch=REF(0x10560c90)\') called at lib/Sql.pm line 110
Sql::do(\'Sql=HASH(0xc7eaab8)\', \'UPDATE recording SET artist_credit = ? WHERE id = ?\', 184151, 9363124) called at lib/Sql.pm line 167
Sql::update_row(\'Sql=HASH(0xc7eaab8)\', \'recording\', \'HASH(0x5ed7220)\', \'HASH(0x10560ed0)\') called at lib/MusicBrainz/Server/Data/Recording.pm line 180
MusicBrainz::Server::Data::Recording::update(\'MusicBrainz::Server::Data::Recording=HASH(0xb8fd808)\', 9363124, \'HASH(0x10555618)\') called at lib/MusicBrainz/Server/Edit/Generic/Edit.pm line 69
MusicBrainz::Server::Edit::Generic::Edit::_ANON_(\'MusicBrainz::Server::Edit::Recording::Edit=HASH(0xef63390)\') called at local/lib/perl5/x86_64-linux-gnu-thread-multi/Moose/Meta/Method/Overridden.pm line 38
MusicBrainz::Server::Edit::Generic::Edit::accept(\'MusicBrainz::Server::Edit::Recording::Edit=HASH(0xef63390)\') called at local/lib/perl5/x86_64-linux-gnu-thread-multi/Class/MOP/Method/Wrapped.pm line 50
Class::MOP::Method::Wrapped::_ANON_(\'MusicBrainz::Server::Edit::Recording::Edit=HASH(0xef63390)\') called at local/lib/perl5/x86_64-linux-gnu-thread-multi/Class/MOP/Method/Wrapped.pm line 91
MusicBrainz::Server::Edit::Recording::Edit::accept(\'MusicBrainz::Server::Edit::Recording::Edit=HASH(0xef63390)\') called at lib/MusicBrainz/Server/Data/Edit.pm line 515
MusicBrainz::Server::Data::Edit::_ANON_() called at local/lib/perl5/Try/Tiny.pm line 71
eval {...} called at local/lib/perl5/Try/Tiny.pm line 67
Try::Tiny::try(\'CODE(0x10538ee8)\', \'Try::Tiny::Catch=REF(0x10558df0)\') called at lib/MusicBrainz/Server/Data/Edit.pm line 541
MusicBrainz::Server::Data::Edit::_do_accept(\'MusicBrainz::Server::Data::Edit=HASH(0xb1115c0)\', \'MusicBrainz::Server::Edit::Recording::Edit=HASH(0xef63390)\') called at lib/MusicBrainz/Server/Data/Edit.pm line 580
MusicBrainz::Server::Data::Edit::_ANON_(\'MusicBrainz::Server::Edit::Recording::Edit=HASH(0xef63390)\') called at lib/MusicBrainz/Server/Data/Edit.pm line 607
MusicBrainz::Server::Data::Edit::_close(\'MusicBrainz::Server::Data::Edit=HASH(0xb1115c0)\', \'MusicBrainz::Server::Edit::Recording::Edit=HASH(0xef63390)\', \'CODE(0x104b39f0)\', \'auto_edit\', 1) called at lib/MusicBrainz/Server/Data/Edit.pm line 580
MusicBrainz::Server::Data::Edit::accept(\'MusicBrainz::Server::Data::Edit=HASH(0xb1115c0)\', \'MusicBrainz::Server::Edit::Recording::Edit=HASH(0xef63390)\', \'auto_edit\', 1) called at lib/MusicBrainz/Server/Data/Edit.pm line 430
MusicBrainz::Server::Data::Edit::create(\'MusicBrainz::Server::Data::Edit=HASH(0xb1115c0)\', \'editor_id\', 326637, \'privileges\', 57, \'length\', 203000, \'comment\', undef, ...) called at lib/MusicBrainz/Server/Controller.pm line 85
MusicBrainz::Server::Controller::_ANON_() called at local/lib/perl5/Try/Tiny.pm line 76
eval {...} called at local/lib/perl5/Try/Tiny.pm line 67
Try::Tiny::try(\'CODE(0xdf16248)\', \'Try::Tiny::Catch=REF(0xdf16140)\') called at lib/MusicBrainz/Server/Controller.pm line 101
MusicBrainz::Server::Controller::_insert_edit(\'MusicBrainz::Server::Controller::Recording=HASH(0xc1d3d10)\', \'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Form::Recording=HASH(0xd64a520)\', \'edit_type\', 72, \'name\', \'Schottish-choro\', \'length\', 203000, ...) called at lib/MusicBrainz/Server/Controller.pm line 136
MusicBrainz::Server::Controller::_ANON_() called at lib/Sql.pm line 277
Sql::_ANON_() called at local/lib/perl5/Try/Tiny.pm line 76
eval {...} called at local/lib/perl5/Try/Tiny.pm line 67
Try::Tiny::try(\'CODE(0xdf15f00)\', \'Try::Tiny::Catch=REF(0xded13e8)\') called at lib/Sql.pm line 290
Sql::_auto_transaction(\'CODE(0xdf15ed0)\', \'Sql=HASH(0xc7eaab8)\') called at lib/Sql.pm line 295
Sql::_run_in_transaction_one(\'CODE(0xdf15ed0)\', \'Sql=HASH(0xc7eaab8)\') called at lib/Sql.pm line 309
Sql::run_in_transaction(\'CODE(0xdf15ed0)\', \'Sql=HASH(0xc7eaab8)\') called at lib/MusicBrainz/Server/Model/MB.pm line 17
MusicBrainz::Server::Model::MB::with_transaction(\'MusicBrainz::Server::Model::MB=HASH(0xaaad3f8)\', \'CODE(0xdf15ed0)\') called at lib/MusicBrainz/Server/Controller.pm line 144
MusicBrainz::Server::Controller::edit_action(\'MusicBrainz::Server::Controller::Recording=HASH(0xc1d3d10)\', \'MusicBrainz::Server=HASH(0xd183ea0)\', \'form\', \'Recording\', \'type\', 72, \'item\', \'MusicBrainz::Server::Entity::Recording=HASH(0xd64a3a0)\', \'edit_args\', ...) called at lib/MusicBrainz/Server/Controller/Role/Edit.pm line 37
Moose::Meta::Role::_ANON_::SERIAL::159::edit(\'MusicBrainz::Server::Controller::Recording=HASH(0xc1d3d10)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst/Action.pm line 65
Catalyst::Action::execute(\'Catalyst::Action=HASH(0xc64cc30)\', \'MusicBrainz::Server::Controller::Recording=HASH(0xc1d3d10)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst.pm line 1667
eval {...} called at local/lib/perl5/Catalyst.pm line 1667
Catalyst::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc64cc30)\') called at local/lib/perl5/Catalyst/Plugin/StackTrace.pm line 94
Catalyst::Plugin::StackTrace::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc64cc30)\') called at lib/MusicBrainz/Server.pm line 306
MusicBrainz::Server::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc64cc30)\') called at local/lib/perl5/Catalyst/Action.pm line 60
Catalyst::Action::dispatch(\'Catalyst::Action=HASH(0xc64cc30)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst/ActionChain.pm line 38
Catalyst::ActionChain::dispatch(\'Catalyst::ActionChain=HASH(0xcfd9770)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst/Controller.pm line 125
Catalyst::Controller::_ACTION(\'MusicBrainz::Server::Controller::Recording=HASH(0xc1d3d10)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst/Action.pm line 65
Catalyst::Action::execute(\'Catalyst::Action=HASH(0xc633720)\', \'MusicBrainz::Server::Controller::Recording=HASH(0xc1d3d10)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst.pm line 1667
eval {...} called at local/lib/perl5/Catalyst.pm line 1667
Catalyst::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc633720)\') called at local/lib/perl5/Catalyst/Plugin/StackTrace.pm line 94
Catalyst::Plugin::StackTrace::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc633720)\') called at lib/MusicBrainz/Server.pm line 306
MusicBrainz::Server::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc633720)\') called at local/lib/perl5/Catalyst/Action.pm line 60
Catalyst::Action::dispatch(\'Catalyst::Action=HASH(0xc633720)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 257
Catalyst::Dispatcher::_do_forward(\'Catalyst::Dispatcher=HASH(0x472e470)\', \'forward\', \'MusicBrainz::Server=HASH(0xd183ea0)\', \'_ACTION\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 237
Catalyst::Dispatcher::forward(\'Catalyst::Dispatcher=HASH(0x472e470)\', \'MusicBrainz::Server=HASH(0xd183ea0)\', \'_ACTION\') called at local/lib/perl5/Catalyst.pm line 342
Catalyst::forward(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'_ACTION\') called at local/lib/perl5/Catalyst/Controller.pm line 99
Catalyst::Controller::_DISPATCH(\'MusicBrainz::Server::Controller::Recording=HASH(0xc1d3d10)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst/Action.pm line 65
Catalyst::Action::execute(\'Catalyst::Action=HASH(0xc633d08)\', \'MusicBrainz::Server::Controller::Recording=HASH(0xc1d3d10)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst.pm line 1667
eval {...} called at local/lib/perl5/Catalyst.pm line 1667
Catalyst::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc633d08)\') called at local/lib/perl5/Catalyst/Plugin/StackTrace.pm line 94
Catalyst::Plugin::StackTrace::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc633d08)\') called at lib/MusicBrainz/Server.pm line 306
MusicBrainz::Server::execute(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'MusicBrainz::Server::Controller::Recording\', \'Catalyst::Action=HASH(0xc633d08)\') called at local/lib/perl5/Catalyst/Action.pm line 60
Catalyst::Action::dispatch(\'Catalyst::Action=HASH(0xc633d08)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 257
Catalyst::Dispatcher::_do_forward(\'Catalyst::Dispatcher=HASH(0x472e470)\', \'forward\', \'MusicBrainz::Server=HASH(0xd183ea0)\', \'/recording/_DISPATCH\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 237
Catalyst::Dispatcher::forward(\'Catalyst::Dispatcher=HASH(0x472e470)\', \'MusicBrainz::Server=HASH(0xd183ea0)\', \'/recording/_DISPATCH\') called at local/lib/perl5/Catalyst.pm line 342
Catalyst::forward(\'MusicBrainz::Server=HASH(0xd183ea0)\', \'/recording/_DISPATCH\') called at local/lib/perl5/Catalyst/Dispatcher.pm line 105
Catalyst::Dispatcher::dispatch(\'Catalyst::Dispatcher=HASH(0x472e470)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst.pm line 1613
Catalyst::dispatch(\'MusicBrainz::Server=HASH(0xd183ea0)\') called at lib/MusicBrainz/Server.pm line 270
Class::MOP::Class:::around(\'CODE(0x3f8d5a8)\', \'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/x86_64-linux-gnu-thread-multi/Class/MOP/Method/Wrapped.pm line 162
Class::MOP::Method::Wrapped::_ANON_(\'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/x86_64-linux-gnu-thread-multi/Class/MOP/Method/Wrapped.pm line 91
MusicBrainz::Server::dispatch(\'MusicBrainz::Server=HASH(0xd183ea0)\') called at local/lib/perl5/Catalyst.pm line 1963
Catalyst::_ANON_() called at local/lib/perl5/Try/Tiny.pm line 76
eval {...} called at local/lib/perl5/Try/Tiny.pm line 67
Try::Tiny::try(\'CODE(0xc79b338)\', \'Try::Tiny::Catch=REF(0xd1f85a8)\') called at local/lib/perl5/Catalyst.pm line 1969
Catalyst::handle_request(\'MusicBrainz::Server\', \'env\', \'HASH(0xc7d7788)\') called at lib/Catalyst/Plugin/AutoRestart.pm line 119
Catalyst::Plugin::AutoRestart::handle_request(\'MusicBrainz::Server\', \'env\', \'HASH(0xc7d7788)\') called at local/lib/perl5/Catalyst/Engine.pm line 856
Catalyst::Engine::_ANON_(\'CODE(0xcfc4280)\') called at local/lib/perl5/Plack/Handler/FCGI.pm line 134
Plack::Handler::FCGI::run(\'Plack::Handler::FCGI=HASH(0x242ba30)\', \'CODE(0xc72c5c8)\') called at local/lib/perl5/Plack/Loader.pm line 88
Plack::Loader::run(\'Plack::Loader=HASH(0x23f4e00)\', \'Plack::Handler::FCGI=HASH(0x242ba30)\') called at local/lib/perl5/Plack/Runner.pm line 263
Plack::Runner::run(\'Plack::Runner=HASH(0x21f7808)\') called at local/bin/plackup line 10
';
at lib/MusicBrainz/Server/Controller.pm line 101
at lib/Sql.pm line 290"
Stack trace:
line 17 MusicBrainz::Server::Model::MB
line 144 MusicBrainz::Server::Controller
line 37 MusicBrainz::Server::Controller::Role::Edit
line 306 MusicBrainz::Server
line 306 MusicBrainz::Server
line 306 MusicBrainz::Server
line 270 MusicBrainz::Server
Request data:

$VAR1 = {
'query_parameters' => {},
'body_parameters' => {
'edit-recording.artist_credit.names.0.artist.id' => '184151',
'edit-recording.edit_note' => '',
'edit-recording.artist_credit.names.0.artist.name' => "\x{5927}\x{8429}\x{5eb7}\x{53f8}",
'edit-recording.artist_credit.names.0.name' => "\x{5927}\x{8429}\x{5eb7}\x{53f8}",
'edit-recording.artist_credit.names.0.join_phrase' => '',
'edit-recording.comment' => '',
'edit-recording.length' => '3:23',
'edit-recording.as_auto_editor' => '1',
'edit-recording.name' => 'Schottish-choro',
'gc-roman' => 'on',
'gc-mode' => 'Sentence'
}
};

URL: http://musicbrainz.org/recording/356e64c5-82eb-4ece-a843-4619c81dbb3f/edit


Ian McEwen added a comment - 12/Jul/12 12:28 AM

Had a thought on this: the issue definitely only comes up for autoedits, so: might it be valuable to enter autoedits using two transactions (one for making the edit, a second for accepting it), so they're more like normal edits? This would presumably also result in killing off the lock-escalation problems we have, since the first transaction really would only need the Share locks and the second would request Exclusive right away. The only problem I see is if the first succeeds but the second doesn't – but if we're setting expire_time correctly, that should just mean the edit gets re-tried when modbot comes along.

Thoughts?


Oliver Charles added a comment - 12/Jul/12 09:56 AM

My thoughts are still exactly the same as before, instead of hypothesizing where the problem might be, get someone to give us steps to reproduce, log all queries it does, and analyze these for triggers and locks that are created. Then we can manually determine what's actually deadlocking, and work out appropriate steps to go forward.


nikki added a comment - 12/Jul/12 12:02 PM

For me, the steps to reproduce are simple:
1. Submit lots of URL edits in quick succession.

The more you do, the higher the probability of triggering at least one deadlock.


Nicolás Tamargo added a comment - 12/Jul/12 12:15 PM

Option B:
1. Submit lots of recording artist edits in quick succession.

The more you do, the higher the probability of triggering at least one deadlock.


Ian McEwen added a comment - 12/Jul/12 07:44 PM

ocharles: let's be real clear here – that path is only available to people with production database access, such as you, and none of you are actually doing it. Which is why I started looking at this using other methods. I can definitely say that we're escalating our locks on some tables, for autoedits, which is exactly what the postgresql manual says to avoid in order to avoid deadlocks – should I put in a different bug for that, then? I'd figured it was probably okay to reuse this bug, given the rather high likelihood that they're related and that, once again: I cannot do that diagnosis you seem to insist on.


Oliver Charles added a comment - 13/Jul/12 12:52 PM

Why is that path only available to the production DB? The production DB runs the exact same code as all other machines such as sandboxes. I'm not insisting on some formal proofs, but you're adding more locks and I want to be absolutely 100% positive that we are doing the correct thing. That is all. Throwing more locks at things could make things worse if we get it wrong. Until we don't have a reproducible case that doesn't happen when we apply certain changes, how can I apply this patch? If I start applying things on trust I'm not doing my job, am I?