If one request successfully writes out the agrcache variable while another request is trying to set the same variable with the same file in it, the value of the file gets turned into an array by array_merge_recursive(). Take the example here:


$a = array(
  'dcbf43e6462bd3457745969ce70a77aed363228644780f0457f992212126f91b' => 'public://js/js_xcPFtQGZ355MfHOMBpub2dvRzpcGLjku_Cr0w3wLtwU.js',
  '1e77d096f760f8e00283f36bdce62d2c6210a872b0fc03505396c33d0fe4c04c' => 'public://js/js_x6kTdqbY_yj4pGofJJKAIw1d6so4lTKH5eEZfib4Jec.js'
);


$b = array(
  '35c289ea3bff928ee87ad0ff6f798e68a77cdb67a07d8fbd3cdfded2cde0fc96' => 'public://js/js_v4Kx_zj247divDgyI-9uO91P4Roag8yzWe-1_8c6LWU.js',
  '1e77d096f760f8e00283f36bdce62d2c6210a872b0fc03505396c33d0fe4c04c' => 'public://js/js_x6kTdqbY_yj4pGofJJKAIw1d6so4lTKH5eEZfib4Jec.js'
);

$c = array_merge_recursive($a, $b);
print_r($c);

This will output:


Array
(
    [dcbf43e6462bd3457745969ce70a77aed363228644780f0457f992212126f91b] => public://js/js_xcPFtQGZ355MfHOMBpub2dvRzpcGLjku_Cr0w3wLtwU.js
    [1e77d096f760f8e00283f36bdce62d2c6210a872b0fc03505396c33d0fe4c04c] => Array
        (
            [0] => public://js/js_x6kTdqbY_yj4pGofJJKAIw1d6so4lTKH5eEZfib4Jec.js
            [1] => public://js/js_x6kTdqbY_yj4pGofJJKAIw1d6so4lTKH5eEZfib4Jec.js
        )

    [35c289ea3bff928ee87ad0ff6f798e68a77cdb67a07d8fbd3cdfded2cde0fc96] => public://js/js_v4Kx_zj247divDgyI-9uO91P4Roag8yzWe-1_8c6LWU.js
)

The file gets turned into an array, which fails to be served. I found this bug during a load test and I was only able to recreate it with a high level of concurrency after clearing the variables out.

Attached patch fixes this by just using array_merge on each element which should produce the desired result.

Comments

msonnabaum’s picture

Status: Active » Needs review
StatusFileSize
new536 bytes

Ignore the last patch.

catch’s picture

Status: Needs review » Fixed

Thanks! Committed and pushed.

msonnabaum’s picture

Status: Fixed » Needs review
StatusFileSize
new619 bytes

I apologize, that patch wasn't as well tested as I thought :)

This one works.

catch’s picture

Status: Needs review » Fixed

Committed this one too :)

rickvug’s picture

Status: Fixed » Needs review
StatusFileSize
new447 bytes

The latest code in master fixed this problem for us but only after we deleted the variables, which already contained the wrong values. I think we need an upgrade path here for anyone who may already have this problem. Simple patch attached.

rickvug’s picture

StatusFileSize
new448 bytes

For some reason git was complaining that the last patch was corrupt. Here's the same changes freshly applied to a clean checkout of master.

catch’s picture

Status: Needs review » Fixed

Thanks rickvug, committed/pushed to 7.x-1.x.

Status: Fixed » Closed (fixed)

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

kalabro’s picture

Just a note.
This issue is related to these errors in 7.x-1.1 version (and fixed in dev):

Warning: strpos() expects parameter 1 to be string, array given in file_uri_scheme() (regel 200 van /home/planum/domains/domain.nl/public_html/drupal-7/includes/file.inc).
Warning: mb_substr() expects parameter 1 to be string, array given in drupal_substr() (regel 518 van /home/planum/domains/domain.nl/public_html/drupal-7/includes/unicode.inc).
Warning: rawurlencode() expects parameter 1 to be string, array given in drupal_encode_path() (regel 640 van /home/planum/domains/domain.nl/public_html/drupal-7/includes/common.inc).

Came from here: #1837292: CSS aggregation on: Warning: mb_substr() expects parameter 1 to be string : rawurlencode() expects parameter 1 to be string.