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

andileco created an issue. See original summary.

mwebaze’s picture

@andileco,

use the following patch to resolve this particular issue. Let us know if it works for you.

andileco’s picture

Status: Active » Reviewed & tested by the community

I manually applied the patch and it worked for me! Thanks, @mwebaze

  • marvil07 committed c7bbdd4 on 8.x-1.x authored by mwebaze
    Issue #2948809 by mwebaze: Ajax called too many times, creates SQL...
marvil07’s picture

Status: Reviewed & tested by the community » Fixed

@mwebaze, thanks for the patch!
Now added to 8.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.