Error: Could not acquire lock on PrivateTempStore

Created on 12 May 2022, about 2 years ago
Updated 21 September 2023, 10 months ago

Problem/Motivation

We are seeing the following error in our log:

Drupal\Core\TempStore\TempStoreException: Couldn't acquire lock to update item 'v6eYJdQWOLthgM-P_AK6-W8yoTK-KMC89AfilunZU0Q:events' in 'tempstore.private.commerce_google_tag_manager' temporary storage. in Drupal\Core\TempStore\PrivateTempStore->set() (line 139 of /xyz/web/core/lib/Drupal/Core/TempStore/PrivateTempStore.php).

It appears in the log at random times and does not seem to be related to a particular page or host. We have noticed that it often appears sequentially for the same hostname/session. Suggesting that once the error is triggered it then occurs on subsequent pages for that session.

Any thoughts on what might be triggering this one?

Many Thanks.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom sittard

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India girijadeepu11

    HI.. I have tried the below solution, still we are getting the issue .

    1) MySQL ('READ COMMITTED') - https://www.drupal.org/node/3269885
    2) Install a cache tier like Redis

  • 🇩🇪Germany a.dmitriiev

    For my project there is already Redis and 'READ COMMITTED' mode is used for mysql, but still the error is there

  • 🇫🇷France Nicolas Bouteille

    Just wanted to give some more info
    Backtrace:
    CommerceEventsSubscriber->trackProductView()
    >> EventTrackerService->productDetailViews()
    >> EventStorageService->addEvent()
    >> PrivateTempStore->set()

    if (!$this->lockBackend->acquire($key)) {
          $this->lockBackend->wait($key);
          if (!$this->lockBackend->acquire($key)) {
            throw new TempStoreException("Couldn't acquire lock to update item '$key' in '{$this->storage->getCollectionName()}' temporary storage.");
          }
        }
    

    the database table where tempstore.private.commerce_google_tag_manager entries are stored is key_value_expired

Production build 0.69.0 2024