I have a program that is running all of the time. I am getting data from another system to build a shipment.
My program checks for locks before it begins. It locks the delivery and shipment after it starts.
I am running into problems. The shipment requires that the flags be removed prior to changes. The changes from the other system can include changes to the deliveries (removing or adding them.) So I change the shipment in many different steps. And I have to commit the work on each of the steps. When I commit the work the locks are removed.
1. Lock records.
2. Remove the flags.
3. Commit the work.
4 Lock the records for the next step.
Between 3 and 4 a different process can and does lock the records that are being used. Once the records are locked the next step can not continue. The program does a loop where it waits for 20 seconds and trys again. However, I don't want to leave it in that loop forever. The total amount of retrys is 10 before it gives up and sends a message to the user.
However, that leaves the shipment in a "half processed" status.
Has anyone run into this problem before? What was your solution? This is causing issues on my production server. Due to the amount of times I update a shipment, it can have all the stages removed. If that happens no other processing can be done on the shipment.