I've seen this error pop up at very odd times, but it seems to happen most of all when clearing caches, I have no idea what series of steps it takes to reproduce but thought it was worth reporting. The full error is:
WD php: PDOException: SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block: SELECT 1 AS expression
FROM
{variable} variable
WHERE ( (name = :db_condition_placeholder_0) ) FOR UPDATE; Array
(
[:db_condition_placeholder_0] => rules_empty_sets
)
in variable_set() (line 972 of /var/www/drupal/ec-internet/releases/20121113-3/includes/bootstrap.inc).
Drush command terminated abnormally due to an unrecoverable error.
Any help or advice on how to get to the bottom of this would be great
Comments
Comment #1
wiifmAlso seeing this in the logs, this is causing 500's on the site every now and then
Any thoughts on this?
Comment #2
davidwhthomas commentedPerhaps some locking issue when deleting and creating that variable in a transaction when using SELECT FOR UPDATE.
See the following in rules.module ~line 336
A little odd that rules calls variable_del in hook_flush_caches, suggests a link with the issue occurring during cache clear.
Perhaps Rules should store the rules_empty_sets cache in cache_rules instead of the variables table.
Comment #3
jweowu commentedJust a note that with the "failed sql transaction ... current transaction is aborted" error, you may need to check the database's own logs to find out what actually triggered the problem, as there may well be nothing wrong with the query displayed in Drupal's error message.
Comment #4
acbramley commentedFrom the db logs:
So the error is actually the INSERT. This means that variable_set() which calls db_merge is trying to insert an existing key. This is almost certainly a race condition since db_merge would do an update if the key existed? I have a feeling this is not Rules at all but I do not know where to best move this to.
I'm also currently unable to reproduce it with a set number of steps. This however occurs mostly on our release cycles where we run a series of drush commands. This time it happened after a drush cc all, there was then a drush fr feature_name and this is where the error occured
Comment #5
acbramley commented#1555634: Improve performance of event cache by moving to a whitelist looks like it's removed the variable_set type functionality so this issue may have been mitigated by that. Moving back to rules as I think this is a rules issue.
Comment #6
davidwhthomas commentedFollow up to my note in #2
I've created a patch for a related deadlock / variable table issue to move rules_event_whitelist from the variable table to cache_rules that may well resolve this issue as well.
Please review: https://drupal.org/comment/8516509#comment-8516509
Comment #7
cmonnow commentedJust out of interest I was wondering if running update.php resolved this issue for anyone. I was facing an alternate PDOException: SQLSTATE[25P02] error with another table (cache_update) that would only occur the first time after I cleared the cache (using drush cc all), but appears to work for now following update.php.
Comment #8
acbramley commented@cmonnow I experience this error intermittently, but usually on a cache clear, however I haven't encountered it in a while
Comment #9
tr commentedHaven't had a report of this error for more than five years now. The issues cited in #5 and #6, #1555634: Improve performance of event cache by moving to a whitelist and #2190775: Misuse of variables table with rules_event_whitelist, have both been committed. For these reasons, I'm going to assume that fixed the problem.
If this continues to be a problem for you, please open a new issue.