Mailing List Archive

[Bricolage #272] Crash when accessing a desk
// Add your reply above here
==================================================
theory updated this ticket at September 28th, 2011 @ 04:04 PM

Hey Nick, what's the latest on those triggers? They holding up and preventing further problems?
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
Nick Legg updated this ticket at September 28th, 2011 @ 06:56 PM

I haven't found any desk-asset sync issues on my test server after running a number of api scripts and bric_soap bulk operations. We've been moving a lot of assets between categories lately, and I usually run the operation against the test server first to see how it goes. The triggers also don't seem to induce any noticeable performance issues.

Remember how you patched the desk_has_story method because it threw an error any time a user attempted to create a new story? That error happens with new media and new templates, too, so I haven't actually pushed the triggers into the production server (it's probably a really easy fix, but haven't had much time lately).

New media error:
Unable to commit transaction: DBD::Pg::db commit failed: ERROR: record "old" is not assigned yet\nDETAIL: The tuple structure of a not-yet-assigned record is indeterminate.\nCONTEXT: PL/pgSQL function "desk_has_media" line 2 at IF at /usr/local/bricolage/lib/Bric/Util/DBI.pm line 639, <GEN46> line 120.\n, referer: https://bricolage-test.myuniv.edu/workflow/profile/media/new/1247
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:640]
[/usr/local/bricolage/lib/Bric/Util/Job.pm:2302]
[/usr/local/bricolage/lib/Bric/Util/Job.pm:1881]
[/usr/local/bricolage/lib/Bric/Util/Burner.pm:1045]
[/usr/local/bricolage/lib/Bric/Biz/Asset/Business/Media.pm:2373]
[/usr/local/bricolage/lib/Bric/Biz/Asset/Business/Media.pm:1923]
[/usr/local/bricolage/lib/Bric/App/Callback/Profile/Media.pm:577]
[/usr/local/share/perl5/Params/CallbackRequest.pm:296]
[/usr/local/share/perl5/MasonX/Interp/WithCallbacks.pm:119]
[/usr/local/share/perl5/HTML/Mason/ApacheHandler.pm:868]
[/usr/local/share/perl5/HTML/Mason/ApacheHandler.pm:822]
[/usr/local/bricolage/lib/Bric/App/Handler.pm:308]
[-e:0]

New template error:
Unable to commit transaction: DBD::Pg::db commit failed: ERROR: record "old" is not assigned yet\nDETAIL: The tuple structure of a not-yet-assigned record is indeterminate.\nCONTEXT: PL/pgSQL function "desk_has_template" line 2 at IF at /usr/local/bricolage/lib/Bric/Util/DBI.pm line 639, <GEN19> line 86.\n, referer: https://bricolage-test.myuniv.edu/workflow/profile/template/new/103
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:640]
[/usr/local/bricolage/lib/Bric/App/Handler.pm:310]
[-e:0]

Pending fixes for those issues, the triggers are probably ready for wider testing.
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
theory updated this ticket at September 29th, 2011 @ 05:29 PM

> I haven't found any desk-asset sync issues on my test server after running a number of api scripts and bric_soap bulk operations. We've been moving a lot of assets between categories lately, and I usually run the operation against the test server first to see how it goes. The triggers also don't seem to induce any noticeable performance issues.

Excellent!

> Remember how you patched the desk_has_story method because it threw an error any time a user attempted to create a new story? That error happens with new media and new templates, too, so I haven't actually pushed the triggers into the production server (it's probably a really easy fix, but haven't had much time lately).

Oops, sorry I didn't do it before. Here you go:

CREATE OR REPLACE FUNCTION desk_has_media(
) RETURNS TRIGGER LANGUAGE PLPGSQL AS $$
BEGIN
IF TG_OP = 'UPDATE' THEN
IF NEW.desk__id = OLD.desk__id THEN RETURN NEW; END IF;
END IF;
IF NEW.desk__id > 0 THEN
IF EXISTS (
SELECT media_member.object_id
FROM desk
JOIN member ON member.grp__id = desk.asset_grp
JOIN media_member ON media_member.member__id = member.id
WHERE desk.id = NEW.desk__id
AND media_member.object_id = NEW.id
) THEN RETURN NEW; END IF;
RAISE EXCEPTION 'Desk % should have media % in its group but does not',
NEW.desk__id, NEW.id;
ELSIF TG_OP = 'UPDATE' THEN
IF NOT EXISTS (
SELECT media_member.object_id
FROM desk
JOIN member ON member.grp__id = desk.asset_grp
JOIN media_member ON media_member.member__id = member.id
WHERE desk.id = OLD.desk__id
AND media_member.object_id = NEW.id
) THEN RETURN NEW; END IF;
RAISE EXCEPTION 'Desk % should not have media % in its group but does',
OLD.desk__id, NEW.id;
ELSE
RETURN NEW;
END IF;
END;
$$;

CREATE OR REPLACE FUNCTION desk_has_media(
) RETURNS TRIGGER LANGUAGE PLPGSQL AS $$
BEGIN
IF TG_OP = 'UPDATE' THEN
IF NEW.desk__id = OLD.desk__id THEN RETURN NEW; END IF;
END IF;
IF NEW.desk__id > 0 THEN
IF EXISTS (
SELECT media_member.object_id
FROM desk
JOIN member ON member.grp__id = desk.asset_grp
JOIN media_member ON media_member.member__id = member.id
WHERE desk.id = NEW.desk__id
AND media_member.object_id = NEW.id
) THEN RETURN NEW; END IF;
RAISE EXCEPTION 'Desk % should have media % in its group but does not',
NEW.desk__id, NEW.id;
ELSIF TG_OP = 'UPDATE' THEN
IF NOT EXISTS (
SELECT media_member.object_id
FROM desk
JOIN member ON member.grp__id = desk.asset_grp
JOIN media_member ON media_member.member__id = member.id
WHERE desk.id = OLD.desk__id
AND media_member.object_id = NEW.id
) THEN RETURN NEW; END IF;
RAISE EXCEPTION 'Desk % should not have media % in its group but does',
OLD.desk__id, NEW.id;
ELSE
RETURN NEW;
END IF;
END;
$$;

> Pending fixes for those issues, the triggers are probably ready for wider testing.

Great. I think I'd get them committed, and the update the installer to require PL/pgSQL. Might be annoying for folks, but in truth will give us a lot more power on the backend to do other stuff, should we so choose.
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
Nick Legg updated this ticket at September 29th, 2011 @ 05:43 PM

> Oops, sorry I didn't do it before. Here you go:

Hmm, it looks like desk_has_media was pasted here twice, instead of desk_has_template. In any case, there seems to be a second issue with the new desk_has_media applied:
Unable to execute SQL statement: DBD::Pg::st execute failed: ERROR: Desk 1223 should have media 56420 in its group but does not [.for Statement "UPDATE media SET uuid = ?, element_type__id = ?, priority = ?, source__id = ?, published_version = ?, usr__id = ?, first_publish_date = ?, publish_date = ?, expire_date = ?, workflow__id = ?, desk__id = ?, publish_status = ?, active = ?, site__id = ?, alias_id = ? WHERE id = ?" with ParamValues: 1='CA782FAE-EAC1-11E0-B42A-2D3E39598376', 2='4', 3='3', 4='1025', 5=undef, 6='1478', 7=undef, 8=undef, 9=undef, 10='1247', 11='1223', 12='0', 13='1', 14='100', 15=undef, 16='56420'] at /usr/local/bricolage/lib/Bric/Util/DBI.pm line 1138, <GEN31> line 659.\n, referer: https://bricolage-test.myuniv.edu/workflow/profile/media/new/1247
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:1139]
[/usr/local/bricolage/lib/Bric/Biz/Asset/Business/Media.pm:2148]
[/usr/local/bricolage/lib/Bric/Biz/Asset/Business/Media.pm:1860]
[/usr/local/bricolage/lib/Bric/Biz/Workflow/Parts/Desk.pm:1253]
[/usr/local/bricolage/lib/Bric/Biz/Workflow/Parts/Desk.pm:1177]
[/usr/local/bricolage/lib/Bric/App/Callback/Profile/Media.pm:581]
[/usr/local/share/perl5/Params/CallbackRequest.pm:296]
[/usr/local/share/perl5/MasonX/Interp/WithCallbacks.pm:119]
[/usr/local/share/perl5/HTML/Mason/ApacheHandler.pm:868]
[/usr/local/share/perl5/HTML/Mason/ApacheHandler.pm:822]
[/usr/local/bricolage/lib/Bric/App/Handler.pm:308]
[-e:0]

> Great. I think I'd get them committed, and the update the installer to require PL/pgSQL. Might be annoying for folks, but in truth will give us a lot more power on the backend to do other stuff, should we so choose.

Sounds good to me.
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
theory updated this ticket at September 29th, 2011 @ 05:50 PM

> Hmm, it looks like desk_has_media was pasted here twice, instead of desk_has_template.

Damnit, sorry. Here's the template one:

CREATE OR REPLACE FUNCTION desk_has_template(
) RETURNS TRIGGER LANGUAGE PLPGSQL AS $$
BEGIN
IF TG_OP = 'UPDATE' THEN
IF NEW.desk__id = OLD.desk__id THEN RETURN NEW; END IF;
END;
IF NEW.desk__id > 0 THEN
IF EXISTS (
SELECT template_member.object_id
FROM desk
JOIN member ON member.grp__id = desk.asset_grp
JOIN template_member ON template_member.member__id = member.id
WHERE desk.id = NEW.desk__id
AND template_member.object_id = NEW.id
) THEN RETURN NEW; END IF;
RAISE EXCEPTION 'Desk % should have template % in its group but does not',
NEW.desk__id, NEW.id;
ELSIF TG_OP = 'UPDATE' THEN
IF NOT EXISTS (
SELECT template_member.object_id
FROM desk
JOIN member ON member.grp__id = desk.asset_grp
JOIN template_member ON template_member.member__id = member.id
WHERE desk.id = OLD.desk__id
AND template_member.object_id = NEW.id
) THEN RETURN NEW; END IF;
RAISE EXCEPTION 'Desk % should not have template % in its group but does',
OLD.desk__id, NEW.id;
ELSE
RETURN NEW;
END IF;
END;
$$;

> In any case, there seems to be a second issue with the new desk_has_media applied:

Huh. Run the cleanup queries again.
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
Nick Legg updated this ticket at September 29th, 2011 @ 06:10 PM

> Here's the template one:

Great - new templates work now!

> Huh. Run the cleanup queries again.

Done. Unfortunately the new media issue persists. I get the 500 page upon media creation, but after returning to my Workspace it seems the media _is_ there, but the file I selected didn't upload. And it thinks it's not on a desk when I go into the edit profile:
Warning: object "My New Test Media" had no associated desk. It has been assigned to the "Web Services" desk.
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
theory updated this ticket at September 29th, 2011 @ 06:13 PM

Okay, good, the trigger is actually highlighting a bug in the Perl code. Can you post instructions for how to replicate this error? I'll try to find some tuits tonight or tomorrow to fix it.
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
Nick Legg updated this ticket at September 29th, 2011 @ 06:26 PM

> Okay, good, the trigger is actually highlighting a bug in the Perl code. Can you post instructions for how to replicate this error? I'll try to find some tuits tonight or tomorrow to fix it.

Sure thing.

1. Open a media workflow and click **New Media**
2. Provide a Title, Media Type, Source, Primary Category, Priority, and Cover Date
3. Select a file to upload, then click the **Create** button
4. You'll be presented with the Bricolage 500 error page (it asks you to log back in, but just click on your user profile in the top right to get back to Bric - you're technically still logged in)
5. Open *bricolage/logs/error_log* (or wherever you keep your error log) to see the 500 error output

Alternatively, if RELATED_MEDIA_UPLOAD is enabled:

1. Edit a story and add an element which can contain a related media
2. In the related media dialog, select a file to upload and create a new media
3. After clicking the **Create** button, you'll see the 500 error directly in the related media dialog window

Both methods yield the same error.
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
theory updated this ticket at October 12th, 2011 @ 05:19 AM

Oh, MySQL doesn't support deferred triggers which is required to keep this sane, so I won't bother to add them.
--------------------------------------------------------------------------------

Assigned: theory
State: resolved
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com
[Bricolage #272] Crash when accessing a desk [ In reply to ]
// Add your reply above here
==================================================
theory updated this ticket at October 12th, 2011 @ 05:24 AM
* State changed from "resolved" to "open"
Nick, I'm not able to replicate that error with the new triggers installed. Maybe it's because of [this change](https://github.com/bricoleurs/bricolage/commit/ddffd06403d76695ee728529c8b5799887845a8b#diff-3)? I kind of doubt it, but it might be worth a try to apply it.

David
--------------------------------------------------------------------------------

Assigned: theory
State: open
Milestone: 2.1.0
View this ticket online: http://bricolage.lighthouseapp.com/projects/29601/tickets/272-crash-when-accessing-a-desk

Stop being notified of this ticket's changes: http://bricolage.lighthouseapp.com/watching/3769b563149c133b788665e1974a03a8a714b96c
Update your Profile: http://bricolage.lighthouseapp.com/profile
Support: support@lighthouseapp.com or http://help.lighthouseapp.com