Skip to content

Commit

Permalink
Seed for simultaneos executions
Browse files Browse the repository at this point in the history
  • Loading branch information
angoca committed Oct 6, 2014
1 parent 2e1b1ef commit 26f454d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/sql-pl/04-Body.sql
Expand Up @@ -820,6 +820,7 @@ ALTER MODULE DB2UNIT publish
DECLARE IGNORED DOUBLE;
DECLARE RET ANCHOR EXECUTIONS.EXECUTION_ID;
DECLARE RETRY BOOLEAN DEFAULT TRUE;
DECLARE APP_ID BIGINT;

DECLARE LOGGER_ID SMALLINT;

Expand All @@ -828,12 +829,13 @@ ALTER MODULE DB2UNIT publish

IF (SEED IS NULL) THEN
SET TIME = CURRENT_TIMESTAMP;
SET SEED = (BIGINT(MINUTE(TIME)) * 60 + SECOND(TIME)) * 1000000
+ MICROSECOND(time);
-- Next line does not work in DB2 9.7, however this prevents the problem
-- of concurrent simultaneous execution.
--SET SEED = BIGINT(MON_GET_APPLICATION_HANDLE() * 10000000000) + SEED;
SET APP_ID = (SELECT APPLICATION_HANDLE
FROM SYSIBMADM.MON_CONNECTION_SUMMARY
WHERE APPLICATION_ID = APPLICATION_ID());
SET SEED = (BIGINT((APP_ID * 10000000000 + MINUTE(TIME)) * 60
+ SECOND(TIME) * 1000000 + MICROSECOND(time)));
SET IGNORED = RAND(INTEGER(MOD(SEED, 2147483648)));
CALL LOGGER.DEBUG(LOGGER_ID, 'seed' || SEED);
END IF;

WHILE (RETRY = TRUE) DO
Expand Down

0 comments on commit 26f454d

Please sign in to comment.