How to ensure that process Id is unique
User requires to know how to ensure that processEngine is generating a unique Id for every process.
Steps to Reproduce
How to question on PID generation.
PID is calculated as shown below:
- newPid = staticPidBaseSeqNum * 1000L + staticPidCntNum;
- staticPidCntNum += 1L;
- newPid *= -1L;
When SEEDNUMSEQ is less than 2147483:
In any point of time , staticPidBaseSeqNum holds the current SEEDNUMSEQ sequence value. On the first call to getNextStaticPID(), after the server restart, SEEDNUMSEQ will be incremented.
Starting from zero, staticPidCntNum will be incremented by 1 for every invocation of getNextStaticPID(). Once it reaches 999, SEEDNUMSEQ will be incremented and staticPidCntNum will reset to zero.
When SEEDNUMSEQ reaches 2147483:
- staticPidBaseSeqNum will be rolled over to zero and will not hold the current SEEDNUMSEQ sequence value.
- Then on, the first call to getNextStaticPID() after the server restart or staticPidCntNum reaches 999, staticPidBaseSeqNum will be incremented.
Note: SEEDNUMSEQ will be incremented too.
- Starting from zero, staticPidCntNum will be incremented by 1 for every invocation of getNextStaticPID().
- staticPidBaseSeqNum will be rolled over to zero again, once it reaches 2147483L.
User can see duplicate PIDs once SEEDNUMSEQ exceeds 2147483 and triplicate PIDS once SEEDNUMSEQ exceeds 4294966(2147483*2).