The problem seems to be -as the problems are with race conditions- speed.
It takes longer to update a state then it takes to check that state, therefore, while any process is updating a state, the other process may decide at the same time, to update that state too, resulting in 2 processes being fed the same state, whereas the desired outcome is that process 1 reads state n, and process 2 reads state n+1
In the real world now,
The current flow is (pseudo code)
while(jobs and timeleft) {
get Job (max jobs returned=1, oldest job in range is returned)
process job
if return status = too soon, update job timeout+=30
}
Perhaps you can implement your idea in the same kind of pseudo code. Abstract thinking is good, but sooner or later it will have to be worked out... right?
Main Topics
Browse All Topics





by: moorhouselondonPosted on 2007-09-16 at 14:26:58ID: 19901651
If you have a problem that two entries can simultaneously be entered into a lookup table, then one way to deal with this would be to do a double-check. i.e. put the number into the lookup table, put the message into a "pending" state. Then look in the table again to see if the same number appears again. If so, then it is removed from the queue IF IT IS NEARER THE BACK OF THE TABLE than the duplicate. If it is nearer the front of the table than any other message to the same number, or is the only entry with this number, then the message is sent.
If there is the possibility that this double-check process is unable to pick up on duplicates because it is running at a lower priority than the processes stuffing numbers into the lookup table, then there needs to be a delay built into the final sending process.