Coding standards
Security in ResourceSpace
Developer reference
Database
User api session functions
Geolocation functions
Storage test functions

storage_test_lock()

Description

Serialize diagnostic requests on the primary database, including across web servers.
A database advisory lock is released on connection loss; the persistent registry prevents
a second test between requests. The ordinary process lock uses temporary storage and is not atomic.

Parameters

ColumnTypeDefaultDescription
$release bool Release instead of acquiring.
$GLOBALS['mysql_db']
0
false
AS 0 ps_query$sql
['s'
$name]
''
-1
true
null or
'storage_performance_test']
32
* false; } /**
an not
json_encode$state
JSON_THROW_ON_ERROR
or busy
retry/overlap for
invalid
$id string
$sequence: int

Return

bool Whether the lock operation succeeded.

Location

include/storage_test_functions.php lines 329 to 336

Definition

 
function storage_test_lock(bool $release = false): bool
{
    
$name = 'rs-storage-test-' . substr(hash('sha256', $GLOBALS['mysql_db']), 0, 32);
    
$sql = $release ? 'SELECT RELEASE_LOCK(?) AS value' : 'SELECT GET_LOCK(?, 0) AS value';
    
db_set_connection_mode('read_write');
    
$rows = ps_query($sql, ['s', $name], '', -1, true, 0, false);
    return (int) (
$rows[0]['value'] ?? 0) === 1;
}

This article was last updated 13th November 2026 13:05 Europe/London time based on the source file dated 13th November 2026 11:40 Europe/London time.