Long story short, variable_set() is not atomic. The crawler threads can't use this function.

CommentFileSizeAuthor
#1 boost-559480.patch4.04 KBmikeytown2

Comments

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new4.04 KB

It's better but I doubt I can get this perfect, since multiple threads want to rewrite the cache variables entry; and that's outside the boost code.

mikeytown2’s picture

Example Error msg:

There are php errors on this page, preventing boost from caching. ERROR:

Array

      [type] => 512
      [message] => Duplicate entry 'variables' for key 1
query: INSERT INTO cache (cid, data, created, expire, headers, serialized) VALUES ('variables', 'a:876:{...
      [file] => /home/content/m/c/a/mcarper/html/includes/database.mysqli.inc
      [line] => 141

Core issue has to do with cache_set() being called by multiple variable_init(), from multiple threads in the bootstrap phase. The above fix tries to minimize the number of times the variable row in the cache table gets flushed.
#561990: Avoid variable_set() and variable_del() stampedes

mikeytown2’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

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

alexgreyhead’s picture

Unfortunately this thread is the first result when I Googled for this issue (and several system-cache-related variations of it, too) - I'm seeing a lot of these:

Array

      [type] => 512
      [message] => Duplicate entry 'variables' for key 'PRIMARY'
query: INSERT INTO drupal_cache (cid, data, created, expire, headers, serialized) VALUES ('variables', 'a:6290:{s:13:\"theme_default\";s:7:\"eleanor\";s:13:\"filter_html_1\";s:1:\"1\";s:18:\"node_options_forum\";a:1:{i:0;s:6:\"status\";}s:18:\"drupal_private_key\";s:64:\"07b79fdb52d390a9c8e272940b2201e4d5af6c6971368c8546140bbd0eca995c\";s:10:\"menu_masks\";a:37:{i:0;i:127;i:1;i:126;i:2;i:125;i:3;i:123;i:4;i:122;i:5;i:118;i:6;i:117;i:7;i:63;i:8;i:62;i:9;i:61;i:10;i:60;i:11;i:59;i:12;i:58;i:13;i:57;i:14;i:56;i:15;i:45;i:16;i:44;i:17;i:31;i:18;i:30;i:19;i:29;i:20;i:28;i:21;i:24;i:22;i:22;i:23;i:21;i:24;i:15;i:25;i:14;i:26;i:13;i:27;i:12;i:28;i:11;i:29;i:10;i:30;i:7;i:31;i:6;i:32;i:5;i:33;i:4;i:34;i:3;i:35;i:2;i:36;i:1;}s:12:\"install_task\";s:4:\"done\";s:13:\"menu_expanded\";a:2:{i:0;s:10:\"navigation\";
      [file] => /.../includes/database.mysqli.inc
      [line] => 128

Could Boost's cron crawler be the issue here?

I'd be happy to post up more install details if it would help. Thanks in advance for any ideas you can offer.

Al

mikeytown2’s picture

@alexharries
It's a core issue; Drupal assumes that only 1 process will be changing the variables table; if 2 processes do it then you get the duplicate entry error. The window of time for this error to occur is less then a second so it doesn't happen all the time. The more threads you run in the crawler the higher the probability that you will get this warning. It's not critical, just annoying. This is something that should be fixed in core.
Post everything in here: #561990: Avoid variable_set() and variable_del() stampedes

I've done as much as I can at the moment to make this error occur less frequently, it up to core to fix it.

alexgreyhead’s picture

Mikey: thank you. I've only just found your reply after searching agian for information on the issue having forgotten that I'd posted this request in the first place!

Thank you for taking the time to post such a detailed reply. I'm going to try setting the crawler to 1 thread instead and see how that works out for me.

Best regards,

Al

vinoth.3v’s picture

Status: Closed (fixed) » Active

same error here. I am using latest dev.
But cron crawler is disabled in my install. :(

any solutions?

bgm’s picture

Status: Active » Closed (fixed)

@ vinoth.3v : seems like a different issue. Can you post more details in a new issue? + mention this one in your request as a possible related issue. Thanks.