N°3764 - add transactions_gc_threshold in order to tune CSRF token GC load

This commit is contained in:
bruno-ds
2021-03-01 15:30:40 +01:00
parent 95a0efedcf
commit 0030d5c2b8
2 changed files with 16 additions and 0 deletions

View File

@@ -299,6 +299,14 @@ class privUITransactionFile
*/
protected static function CleanupOldTransactions($sTransactionDir = null)
{
$iThreshold = (int) MetaModel::GetConfig()->Get('transactions_gc_threshold');
$iThreshold = min(100, $iThreshold);
$iThreshold = max(1, $iThreshold);
if ((100 != $iThreshold) && (rand(1, 100) > $iThreshold)) {
return;
}
clearstatcache();
$iLimit = time() - 24*3600;
$sPattern = $sTransactionDir ? "$sTransactionDir/*" : APPROOT.'data/transactions/*';
$aTransactions = glob($sPattern);

View File

@@ -1065,6 +1065,14 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'transactions_gc_threshold' => array(
'type' => 'integer',
'description' => 'probability in percent for the garbage collector to be triggered (100 mean always)',
'default' => 10, // added in itop 2.7.4, before the GC was always called
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'log_transactions' => array(
'type' => 'bool',
'description' => 'Whether or not to enable the debug log for the transactions.',