We have a lot of smart groups, and consequently a lot of deadlocks. There's already code in Civi that detects deadlock Exceptions, and then retries the query a few times. This is really helpful - I have extra logging on this, and I can see that it prevents a lot of errors. But this code doesn't kick in for people directly using the UI - they get the 'unknown error' yellow-screen-of-death immediately. This can happen on exports, or when opening complex groups. I dug into this and sort-of know why it's happening:
- An exception is thrown if
$GLOBALS['_PEAR_default_error_options'][1]
is set to 'exceptionHandler' - An exception is not thrown if
$GLOBALS['_PEAR_default_error_options'][1]
is set to 'handle'. $GLOBALS['_PEAR_default_error_options'][1]
is set to 'exceptionHandler' when you generate smart groups via the API, and in most other circumstances- But
$GLOBALS['_PEAR_default_error_options'][1]
is set to 'handle' in the UI in general (?) - at least, it is on exports and when using 'Manage Groups'. So in this case no Exception is raised. And if there's no exception, the try-catch blocks have nothing to work with and front-end users get 'unknown error' immediately.
I am happy to fund a fix for this, but I'm not sure what I'm getting myself into. Is this an oversight, or is it an unfortunate consequence of how error handling needs to work for end users?