From 46f844002c213e9929428356d47d06c33f4853ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Janis=20Daniel=20Da=CC=88hne?=
 <janis.daehne@informatik.uni-halle.de>
Date: Fri, 5 Mar 2021 11:21:57 +0100
Subject: [PATCH] - removed max parallel tests limitation - removed
 transactions (db access might limit resources) - removed unused functions

---
 api.php               |  12 +--
 bootstrap.php         |   1 -
 config_example.json   |   1 -
 constants.php         |   5 +-
 do_regexTest_func.php |   2 -
 helpers.php           | 226 ------------------------------------------
 readme.md             |  31 +-----
 stats/private.php     |   1 -
 transactionHelper.php | 112 ++++-----------------
 9 files changed, 25 insertions(+), 366 deletions(-)

diff --git a/api.php b/api.php
index 5aa4ae6..01d8092 100644
--- a/api.php
+++ b/api.php
@@ -188,7 +188,7 @@ if ($conn === NULL) {
     exit(1);
 }
 
-$transactionKey = startTransaction($conn, $config, $rootDirName, 'var', $requestDistinctionString);
+$tempUserWorkingSubDirName = getUniqueTempUserWorkingSubDir($requestDistinctionString);
 
 if ($isDebug) {
     $time_post = microtime(true);
@@ -200,19 +200,16 @@ if ($isDebug) {
 
 
 if (!isset($body[$s_arg_pLang])) {
-    endTransaction($conn, $config, $transactionKey, $rootDirName);
     output($status_code_ArgumentInvalidOrMissing, "argument '" . $s_arg_pLang . "' missing");
     exit(1);
 }
 
 if (!isset($body[$s_arg_pLang])) {
-    endTransaction($conn, $config, $transactionKey, $rootDirName);
     output($status_code_ArgumentInvalidOrMissing, "argument '" . $s_arg_pLang . "' missing");
     exit(1);
 }
 
 if (!isset($body[$s_arg_characterLimitProtocol])) {
-    endTransaction($conn, $config, $transactionKey, $rootDirName);
     output($status_code_ArgumentInvalidOrMissing, "argument '" . $s_arg_characterLimitProtocol . "' missing");
     exit(1);
 }
@@ -248,7 +245,6 @@ foreach ($allRows as $row) {
             if ($isDebug) {
                 fwrite(STDOUT, 'could not decode extensions row');
             }
-            endTransaction($conn, $config, $transactionKey, $rootDirName);
             output($status_code_DbIssue, "invalid extensions");
             exit(1);
         }
@@ -259,10 +255,9 @@ foreach ($allRows as $row) {
 
 # create source files
 $rootDir = $rootDirName;
-$paths = ensureDirs($rootDir, $transactionKey);
+$paths = ensureDirs($rootDir, $tempUserWorkingSubDirName);
 
 if ($paths === FALSE) {
-    endTransaction($conn, $config, $transactionKey, $rootDirName);
     output($status_code_FileSystemIssue, "could not create dir(s)");
     exit(1);
 }
@@ -270,7 +265,6 @@ if ($paths === FALSE) {
 $fullWorkingDirPath = $paths[$s_fullWorkingDirPath];
 
 if (createFiles($arg_allFiles, $fullWorkingDirPath) === FALSE) {
-    endTransaction($conn, $config, $transactionKey, $rootDirName);
     //error message is in createFiles function
     exit(1);
 }
@@ -663,8 +657,6 @@ foreach ($testCases as $test) {
 handleCleanup:
 deleteDir($fullWorkingDirPath);
 handleCleanupWithoutDir:
-# release the transaction
-endTransaction($conn, $config, $transactionKey, $rootDirName);
 
 output($status_code_Ok, '', $testResults);
 
diff --git a/bootstrap.php b/bootstrap.php
index 2af96f9..2ed9731 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -66,7 +66,6 @@ $config[$s_arg_hardMemoryLimitInKb] = $row[$s_arg_hardMemoryLimitInKb];
 $config[$s_arg_hardDiskSpaceLimitInKb] = $row[$s_arg_hardDiskSpaceLimitInKb];
 $config[$s_arg_insertTraceLogs] = $row[$s_arg_insertTraceLogs];
 
-$config['maxParallelTests'] = $row['maxParallelTests'];
 $config['maxNumberOfTestsWithOneRequest'] = $row['maxNumberOfTestsWithOneRequest'];
 $config['runner'] = $row['runner'];
 
diff --git a/config_example.json b/config_example.json
index d032edb..9e390e3 100644
--- a/config_example.json
+++ b/config_example.json
@@ -5,7 +5,6 @@
     "dbUser": "tester",
     "dbPw": "mysqlpassword2",
     "dbPLangTableName": "plangs",
-    "dbTransactionTableName": "transactions",
     "dbTraceTableName": "traceLog",
 
     "insertTraceLogs": true,
diff --git a/constants.php b/constants.php
index cd2aa7c..391dfd9 100644
--- a/constants.php
+++ b/constants.php
@@ -35,12 +35,10 @@ $s_lastRunDir = 'lastRunDir';
 
 $s_arg_dbTraceTableName = 'dbTraceTableName';
 
-$s_arg_dbTransactionTableName = 'dbTransactionTableName';
 $s_arg_hardTimeoutInMs = 'hardTimeoutInMs';
 $s_arg_hardCompileTimeoutInMs = 'hardCompileTimeoutInMs';
 $s_arg_hardMemoryLimitInKb = 'hardMemoryLimitInKb';
 $s_arg_hardDiskSpaceLimitInKb = 'hardDiskSpaceLimitInKb';
-$s_arg_maxParallelTests = 'maxParallelTests';
 $s_arg_insertTraceLogs = 'insertTraceLogs'; //true/false
 
 $s_output_test_server_version = 'testServerVersion';
@@ -68,10 +66,11 @@ $runnerNewLineString = "\\r\\n"; //starting with runner version 2.4
 
 # known error codes
 $status_code_Ok = 0;
-$status_code_MaxParallelTestsReached = 1;
+$status_code_MaxParallelTestsReached = 1; # not used anymore!
 $status_code_ArgumentInvalidOrMissing = 2;
 $status_code_DbIssue = 3;
 $status_code_FileSystemIssue = 4;
+$status_code_NoUniqueRequestIdStringProvided = 5; //null or empty
 $status_code_InternalServerError = 100;
 
 
diff --git a/do_regexTest_func.php b/do_regexTest_func.php
index c5cebca..76f1a5a 100644
--- a/do_regexTest_func.php
+++ b/do_regexTest_func.php
@@ -201,7 +201,6 @@ function do_regexTest_json_DEPRECATED($allFiles, $testContent, $showTestRunnerDe
         $s_output => $output
     );
 
-    #handleExecOutput($output, $return_var, $config, $conn, $rootDirName, $transactionKey);
 }
 
 /**
@@ -465,7 +464,6 @@ function do_regexTest_format2($allFiles, $testContent, $showTestRunnerDebugOutpu
         $s_characterLimitExceeded => $characterLimitExceeded
     );
 
-    #handleExecOutput($output, $return_var, $config, $conn, $rootDirName, $transactionKey);
 }
 
 /**
diff --git a/helpers.php b/helpers.php
index 8b58efc..e61b781 100644
--- a/helpers.php
+++ b/helpers.php
@@ -32,232 +32,6 @@ function formatOutput($output) {
     return $formattedOutput;
 }
 
-/**
- * handles the output from the test runner
- * @param $testResults array the test results (id, passed, hasCompiled, programExitCode, testResultCode, protocol)
- * @param $config object the config
- * @param $conn PDO the db connection
- * @param $rootDirName string the iteration root dir name
- * @param $transactionKey int the transaction key to end the transaction
- * @internal param string[] $output the output array from exec
- * @internal param int $return_var the return value from exec
- * @deprecated
- */
-//TODO REMOVE
-function handleExecOutput($testResults, $config, $conn, $rootDirName, $transactionKey)
-{
-
-    global $s_passed;
-    global $s_hasCompiled;
-    global $s_programExitCode;
-    global $s_testResultCode;
-    global $s_protocol;
-    global $responseNewLineString;
-    global $status_code_ArgumentInvalidOrMissing;
-    global $status_code_InternalServerError;
-    global $status_code_Ok;
-
-    # release the transaction
-    endTransaction($conn, $config, $transactionKey, $rootDirName);
-
-
-    $response = [];
-
-    //check if a test has some server error
-
-    foreach ($testResults as $testResult) {
-
-        $output = $testResult->data->content;
-        $return_var = $testResult->return_var;
-
-        if ($return_var === 101) {
-            # unknown command argument
-            # normally this can not happen because we checked the command argument
-            $output = $testResult->data->content;
-
-            if (is_array($output)) {
-                $output = join($responseNewLineString, $output);
-            }
-
-            array_push($response, array(
-                'responseCode' => $status_code_ArgumentInvalidOrMissing,
-                'message' =>  "argument '" . 'test type' . "' was invalid or invalid number of arguments:" . $output,
-                'data' => null
-            ));
-
-        } else if ($return_var === 100) {
-            # unknown error occurred, more info is in the stdout (output from exec)
-            if (is_array($output)) {
-                $output = join($responseNewLineString, $output);
-            }
-
-            array_push($response, array(
-                'responseCode' => $status_code_InternalServerError,
-                'message' => 'unknown error: ' . $output,
-                'data' => null
-            ));
-        } else { // all special return codes
-            /*
-             * 0 - all ok (conversation is in stdout)
-             * 1 - output mismatch
-             * 2 - some error (during program execution e.g. numberformat exception....)
-             * 3 - timeout hit (conversation is in stdout)
-             * 4 - memory limit hit (conversation is in stdout)
-             * 5 - disk limit hit (conversation is in stdout)
-             *
-             * 50 - compile error (error is in stdout)
-             * 60 - unknown / unsupported plang
-             */
-
-            # all are errors but the test was partly executed... and the exec out contains
-            # the conversation protocol
-
-            array_push($response, array(
-                'responseCode' => $status_code_Ok,
-                'message' => '',
-                'data' => $testResult
-            ));
-        }
-
-        outputResponse($response);
-    }
-
-
-}
-
-
-/**
- * checks if the next dir is needed (we periodically change the root dir for the tests so that we can clear the old tests)
- * the interval specified in the config file - changeDirIntervalInS
- * ensure that the changeDirIntervalInS is less than the hardTimeoutInMs (else some tests might still be running during the deletion of the old dirs)
- * @param $hardGlobalTimeoutInMs int the global timeout in ms for every p langs
- * @return string the root dir name (a string of a timestamp)
- * @deprecated no longer used because we can now run multiple test with one request so the hard timeout is not for the whole request... this might be the reason we sometimes got a cannot initialize java vm error because dir not found or something...
- */
-function checkNextDir($hardGlobalTimeoutInMs)
-{
-
-    global $s_timestampFile;
-    global $s_lastRunDate;
-    global $s_lastRunDir;
-    global $timeZone;
-    global $config;
-//    global $s_changeDirIntervalInS;
-    global $s_config_workingDirFullPath;
-//    global $default_changeDirIntervalInS;
-    global $status_code_FileSystemIssue;
-    global $s_arg_hardTimeoutInMs ;
-    global $status_code_InternalServerError;
-
-    $jsonContent = file_get_contents($s_timestampFile);
-
-    # pattern
-    /*
-     * {
-     *      "lastRun": date,
-     *      "lastDir": "dirName"
-     * }
-     */
-
-
-    $lastRunObj = json_decode($jsonContent, TRUE, 512, JSON_FORCE_OBJECT);
-
-//    $interval = intval($config[$s_changeDirIntervalInS]);
-
-//    if ($interval === NULL || $interval <= 0) {
-//        debug('change dir interval in s was null or could not be read, using default value: ' . $default_changeDirIntervalInS);
-//        $interval = $default_changeDirIntervalInS;
-//    }
-
-    date_default_timezone_set($timeZone);
-    $now = new DateTime('now');
-
-
-    $lastRunDate = NULL;
-    $lastRunDir = NULL;
-
-    if ($lastRunObj === NULL) {
-        debug('timestamp file could not be read... creating new one');
-
-        $lastRunObj[$s_lastRunDate] = $lastRunDate = clone $now; //else we would get a reference
-        $lastRunObj[$s_lastRunDir] = $lastRunDir = $now->getTimestamp();
-
-        //create file
-        if (file_put_contents($s_timestampFile, json_encode($lastRunObj, JSON_NUMERIC_CHECK | JSON_FORCE_OBJECT)) == FALSE) {
-            output($status_code_FileSystemIssue, 'could not write to iteration timestamp file');
-            return NULL;
-            //exit(1); //if we exit then the cleanup won't be done!
-        }
-
-    } else {
-        # we receive an array and no date time object so convert/create new
-        $lastRunDate = new DateTime($lastRunObj[$s_lastRunDate]['date']);
-        $lastRunDir = $lastRunObj[$s_lastRunDir];
-    }
-
-    $int = date_interval_create_from_date_string('+ ' . $interval . ' seconds');
-    $lastRunDate->add($int);
-
-    # if now is before last run date + interval = all ok
-    if ($now < $lastRunDate) {
-        # lastRunDate < now < lastRunDate + interval
-        return $lastRunDir;
-
-    } else if ($now > $lastRunDate) {
-        # lastRunDate < lastRunDate + interval < now = next iteration (next dir)
-
-        # if a test was started e.g. 1 second before the iteration was finished then we need to wait at least the hard timeout... better add 1 second
-
-        date_add($lastRunDate, date_interval_create_from_date_string(sprintf('+%d seconds %d milliseconds', $interval, $hardGlobalTimeoutInMs)));
-
-        if ($now < $lastRunDate) {
-            # lastRunDate < lastRunDate + interval < now < lastRunDate + interval + $hardTimeout(+1s)
-            # test could still be running
-        } else {
-            # lastRunDate < lastRunDate + interval < lastRunDate + interval + $hardTimeout(+1s) < now
-            # now every test has finished... use next dir
-
-            debug('finished iteration...');
-
-            $rootDirName = date_timestamp_get($now);
-
-            # write rootDirName and timestamp to the file
-            $lastRunObj[$s_lastRunDate] = $now;
-            $lastRunObj[$s_lastRunDir] = $rootDirName;
-
-            if (file_put_contents($s_timestampFile, json_encode($lastRunObj, JSON_NUMERIC_CHECK | JSON_FORCE_OBJECT)) == FALSE) {
-                output($status_code_FileSystemIssue, 'could not write to iteration timestamp file');
-                exit(1);
-            }
-
-            # this is the root path for all tests but every iteration has its own root folder in that absolute root folder
-            $config_workingDirFullPath = $config[$s_config_workingDirFullPath];
-
-            #make the path end with udir separator
-            if (!endsWith($config_workingDirFullPath, DIRECTORY_SEPARATOR)) {
-                $config_workingDirFullPath = $config_workingDirFullPath . DIRECTORY_SEPARATOR;
-            }
-
-            if (!endsWith($lastRunDir, DIRECTORY_SEPARATOR)) {
-                $lastRunDir = $lastRunDir . DIRECTORY_SEPARATOR;
-            }
-
-            $pathToDelete = $config_workingDirFullPath . $lastRunDir;
-
-            debug('... deleting path ' . $pathToDelete);
-
-            # we changed the dir ... delete old ones
-            //TODO maybe remove all old directories but do not touch the new one
-            deleteDir($pathToDelete);
-
-            return $rootDirName;
-        }
-    }
-
-    return $lastRunDir;
-}
-
-
 /**
  * creates (if not exists) the dirs used for the test
  * @param string $currentRootDirName the current root dir for this iteration
diff --git a/readme.md b/readme.md
index 0f27a47..78d5477 100644
--- a/readme.md
+++ b/readme.md
@@ -111,26 +111,6 @@ python | python -m py_compile "#5" | python "#5" | ["py"]
 **All arguments passed to the shell are wrapped by php `escapeshellarg`, Paths (and maybe other arguments) could contain spaces, wrap them inside double quotes `"a name"`**
 
 
-# Transaction table
-
-Columns
-* id - the transaction id (this is a microtime timestamp and with optional request distinction number to help separate two requests in case they arrive at the same time and microtime() returns the same time)
-* rootDirName - the current root dir name (of the current iteration) (this is a string of a timestamp)
-* testType - the test type
-
-id | rootDirName | testType
---- | --- | ---
-(string) | (string) | (string)
-
-#### Example
-id | rootDirName | testType
---- | --- | ---
-1480443681_0-04701800_1 | 1473288517 | blackBoxTest
-
-where '1480443681' ist the seconds-part if microtime() timestamp '0-04701800' is the microtime part of microtime() and
-'1' ist the request distinction number
-
-
 # Trace Log table
 
 the trace table is used as a log to trace back running/ran processes and source code in the backend
@@ -159,7 +139,6 @@ Columns (the same as in the local config except the db specific settings)
 * hardCompileTimeoutInMs
 * hardMemoryLimitInKb
 * hardMaxDiskSpaceLimitInKb
-* maxParallelTests
 * maxNumberOfTestsWithOneRequest
 * runner (in the db the `"` don't need to be escaped)
 * showTestRunnerDebugOutput (0/1), 0 = false, 1 = true
@@ -169,9 +148,9 @@ Columns (the same as in the local config except the db specific settings)
 
 #### Example
 
-id | workingDirFullPath | hardTimeoutInMs | hardCompileTimeoutInMs | hardMemoryLimitInKb | hardMaxDiskSpaceLimitInKb | maxParallelTests | maxNumberOfTestsWithOneRequest |runner | showTestRunnerDebugOutput | environmentVars
+id | workingDirFullPath | hardTimeoutInMs | hardCompileTimeoutInMs | hardMemoryLimitInKb | hardMaxDiskSpaceLimitInKb | maxNumberOfTestsWithOneRequest |runner | showTestRunnerDebugOutput | environmentVars
 --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
-1 | /Users/janis/Documents/Test/ | 4000 | 2000 | 2000 | 2000 | 10 | 15 | "/Users/janis/Misc/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java" -Dfile.encoding=UTF8 -cp "/Users/janis/Documents/Projects/yapexAll/yapex_DefaultTestRunnerFullThreaded/out" Main | 0  USER=yapextester\nHOME=/home/yapextester\nPWD=\nLANG=de_DE.UTF-8\nPATH=/usr/local/bin:/usr/bin:/bin:/ 
+1 | /Users/janis/Documents/Test/ | 4000 | 2000 | 2000 | 2000  | 15 | "/Users/janis/Misc/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java" -Dfile.encoding=UTF8 -cp "/Users/janis/Documents/Projects/yapexAll/yapex_DefaultTestRunnerFullThreaded/out" Main | 0  USER=yapextester\nHOME=/home/yapextester\nPWD=\nLANG=de_DE.UTF-8\nPATH=/usr/local/bin:/usr/bin:/bin:/ 
 
 
 **Note** that the db config overwrites values in the config file!
@@ -191,7 +170,6 @@ A json object with the following properties (order does not matter)
 * **dbPLangTableName**/**dbTableName** : (string) the table name where the commands are stored
 * **dbUser** : (string) the name of the database user to use for quering the database
 * **dbPw** : (string) the password of the database user
-* **dbTransactionTableName** : (string) the table used for the transaction (to ensure the maxParallelTests)
 * **dbTraceTableName** : (string) the trace log table name 
 
 * **useConfigFromDb**: (bool) true: use the config in the database table, false: use the local config file, the `dbConfig*` (and `dbConfigTableName`) settings are used to connect the the mysql db and read the config settings
@@ -210,7 +188,6 @@ the following settings can be set through the db ()`useConfigFromDb` and connect
 * **hardMemoryLimitInKb** - the hard memory limit in kb
 * **hardMaxDiskSpaceLimitInKb** - the hard max disk space limit in kb
 
-* **maxParallelTests**: (int) the max amount of parallel running tests, if more tests are requested they are rejected with an busy error (use this with the hard limits in the db to calculate the max ressource usage), **set this to 0 or a negative value to no limit the amount of parallel tests**
 * **maxNumberOfTestsWithOneRequest**: (int) the number of tests that can be run with one request (only the first X tests will be executed ... the other will be ignored), this is used to limit the time a user can occupy the test server
 
 * **runner** : (string) the shell/cmd command to execute in order to start the Runner (paths with whitespaces needs to be properly escaped via `"path 1"`) (you might need to use absolute paths)  
@@ -251,8 +228,6 @@ If the config table has more than 1 row, the first row is taken!
     "dbUser": "root",
     "dbPw": "admin",
     "dbPLangTableName": "plangs",
-    "dbTransactionTableName": "transactions",
-    "maxParallelTests": 50,
     "hardTimeoutInMs": 4000,
     "hardCompileTimeoutInMs": 4000,
     "hardMemoryLimitInKb": 2000,
@@ -270,14 +245,12 @@ If the config table has more than 1 row, the first row is taken!
 * Check if all required parameters are set
 * Check if max parallel tests are reached
     * true: throw error (send back error)
-* Start a transaction (create a row in the db)
 * Get the correct command to execute from the database (if needed)
 * Execute the test
     - create user test dir inside the root dir (see `constants.php > $rootDirNameToUseString`)
     * Write all required files to disk (if needed)
     * Execute the Test Runner with the command from the database and the parameters (if needed)
     * Remove written files from disk (if needed) and user test dir
-* close/end the transaction
 * Send back the result
 
 ## request object (json)
diff --git a/stats/private.php b/stats/private.php
index 9ad6022..5074c4e 100644
--- a/stats/private.php
+++ b/stats/private.php
@@ -20,7 +20,6 @@ $response = array(
     $s_arg_hardMemoryLimitInKb => $config[$s_arg_hardMemoryLimitInKb],
     $s_arg_insertTraceLogs => $config[$s_arg_insertTraceLogs],
 
-    "maxParallelTests" => $config["maxParallelTests"],
     "maxNumberOfTestsWithOneRequest" => $config["maxNumberOfTestsWithOneRequest"],
     //"runner" => $config["runner"], //maybe not needed
     "showTestRunnerDebugOutput" => $config["showTestRunnerDebugOutput"],
diff --git a/transactionHelper.php b/transactionHelper.php
index b0cd90b..afb065a 100644
--- a/transactionHelper.php
+++ b/transactionHelper.php
@@ -3,114 +3,40 @@
 include_once __DIR__ . '/constants.php';
 include_once __DIR__ . '/sqlHelper.php';
 
-/**
- * registers/starts a test run (a transaction)
- * this will create a row in the transaction table in the db using a timestamp as primary key
- * if the primary key is already used then a retry error ($status_code_MaxParallelTestsReached) is thrown
- * @param $conn PDO the db connection
- * @param $config object the config to know the transaction table
- * @param $rootDirName int the root dir of the current iteration (this could be used to remove old transactions in the future)
- * @param $testType string the test type (just as info)
- * @param $requestDistinctionString {string} unique string (MUST BE A VALID FILE NAME) to help the this server to separate two requests in case they arrive at the same time (and micro time would return the same value)
- * @return int the timestamp used (to end/close the transaction)
- */
-function startTransaction($conn, $config, $rootDirName, $testType, $requestDistinctionString)
+# from https://stackoverflow.com/questions/21671179/how-to-generate-a-new-guid
+# may not be that unique so use it with something other in combination
+function _GUID()
 {
+    if (function_exists('com_create_guid') === true)
+    {
+        return trim(com_create_guid(), '{}');
+    }
 
-    global $s_arg_dbTransactionTableName;
-    global $status_code_DbIssue;
-    global $s_arg_maxParallelTests;
-    global $status_code_InternalServerError;
-    global $status_code_MaxParallelTestsReached;
+    return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
+}
 
-    $tableName = $config[$s_arg_dbTransactionTableName];
-    $maxParallelTests = $config[$s_arg_maxParallelTests];
+/**
+ * @param $requestDistinctionString MUST BE A VALID FILE NAME
+ * @return string
+ */
+function getUniqueTempUserWorkingSubDir($requestDistinctionString) {
 
-    if ($maxParallelTests === NULL) {
-        output($status_code_InternalServerError, 'could not read maxParallelTests from config');
+    global $status_code_NoUniqueRequestIdStringProvided;
+
+    if (!isset($requestDistinctionString) || $requestDistinctionString === '') {
+        output($status_code_NoUniqueRequestIdStringProvided, 'could not get unique request id string or is empty');
         exit(1);
     }
 
-
-    //this gives as precision in s ... that's too bad...
-    //$now = new DateTime('now');
-    //date_timestamp_get($now);
-
     //use micro seconds...
     list($usec, $sec) = explode(" ", microtime());
     $timestamp = $sec . '_' . str_replace('.', '-', $usec) . '';
 
-    if ($requestDistinctionString !== NULL) {
-        $timestamp = $timestamp . '-' . $requestDistinctionString;
-    }
-
-
-    if ($maxParallelTests > 0) {
-        # only check max parallel tests if ask to
-
-        # check if the max parallel tests are running --> yes throw retry error
-
-        $sql = "SELECT * FROM `" . $tableName . "`;";
-
-        $currentTransactions = executeSqlAndReturnValue($conn, $sql, []);
-
-        if (count($currentTransactions) >= $maxParallelTests) {
-            //limit reached, throw
-
-            output($status_code_MaxParallelTestsReached, 'max parallel tests reached, retry later');
-            $date = new DateTime();
-            warn('max parallel tests reached! : ' . $date->format('Y-m-d H:i:s'));
-            exit(1);
-        }
-    }
-
-
-    # start the transaction
-
-    $sql = "INSERT INTO `" . $tableName . "` (id,rootDirName, testType) VALUES (:id, :rootDirName, :testType);";
-    $params = array(
-        ':id' => $timestamp,
-        ':rootDirName' => $rootDirName,
-        ':testType' => $testType
-    );
-
-    if (executeSql($conn, $sql, $params) === NULL) {
-        //some error
-        output($status_code_DbIssue, 'could not start transaction');
-        exit(1);
-    }
+    $timestamp = $timestamp . '-' . $requestDistinctionString . '-' . _GUID();
 
     return $timestamp;
 }
 
-/**
- * ends a transaction (removes the row in the db)
- *
- * @param $conn PDO the connection
- * @param $config object the config tp know the table name
- * @param $rootDirName int the root dir of the current iteration (this could be used to remove old transactions in the future)
- * @param $transactionKey int the primary key
- */
-function endTransaction($conn, $config, $transactionKey, $rootDirName)
-{
-
-    global $s_arg_dbTransactionTableName;
-    global $status_code_DbIssue;
-
-
-    $tableName = $config[$s_arg_dbTransactionTableName];
-    $sql = "DELETE FROM `" . $tableName . "` WHERE id = :id;";
-    $params = array(
-        ':id' => $transactionKey
-    );
-
-    if (executeSql($conn, $sql, $params) === NULL) {
-        //some error
-        output($status_code_DbIssue, 'could not end transaction');
-        exit(1);
-    }
-}
-
 /**
  * @param $conn PDO the db connection
  * @param $config
-- 
GitLab