After updating to the latest Voting API version, I was getting the following SQL errors upon voting using the Vote Up Down Thumbs widget.
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'vote:484' for key 'PRIMARY': INSERT INTO {cachetags} (invalidations, tag) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => vote:484 ) in Drupal\Core\Database\Connection->handleQueryException() (line 683 of /app/core/lib/Drupal/Core/Database/Connection.php).
and
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO {cache_bootstrap} (cid, expire, created, tags, checksum, data, serialized) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6) ON DUPLICATE KEY UPDATE cid = VALUES(cid), expire = VALUES(expire), created = VALUES(created), tags = VALUES(tags), checksum = VALUES(checksum), data = VALUES(data), serialized = VALUES(serialized); Array ( [:db_insert_placeholder_0] => last_write_timestamp_cache_bootstrap [:db_insert_placeholder_1] => -1 [:db_insert_placeholder_2] => 1519736162.62 [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => d:1519736162.621; [:db_insert_placeholder_6] => 1 ) in Drupal\Core\Cache\ChainedFastBackend->markAsOutdated() (line 306 of /app/core/lib/Drupal/Core/Cache/ChainedFastBackend.php).
The issue is that Ajax runs too many times and instructs Voting API to create multiple cachetags.
This is happening in: https://cgit.drupalcode.org/vote_up_down/tree/js/VoteUpDown.js?h=8.x-1.x
Comments
Comment #2
mwebaze commented@andileco,
use the following patch to resolve this particular issue. Let us know if it works for you.
Comment #3
andileco commentedI manually applied the patch and it worked for me! Thanks, @mwebaze
Comment #5
marvil07 commented@mwebaze, thanks for the patch!
Now added to 8.x-1.x.