Batch Continuation Stuck

Tags: #<Tag:0x00007fb0053d5380> #<Tag:0x00007fb0053d52b8>

Hangfire : 1.6.12 (using SQL Server Store)
Hangfire.Pro: 1.4.8

We have email batch jobs which are always in 3 parts:
1 - Initialize and start email batch - Completes with Success
2 - Send the Email(s) - Sometimes it never starts even when Batch 1 is successful
3 - End batch by marking complete - Never starts if 2 is in Awaiting…

The batch jobs get created very close together and we had lots of problems initially during development when using Hangfire.Pro 1.4.7 but we upgraded to 1.4.8 and seemed to have the issues fixed. Now that we are doing bulk testing of about 100 emails being processed the bug is showing up again.


This appears to be a problem where Job 1 in Batch 1 starts at the exact same time that Job 2 in Batch 2 is created. See the records below:
From the Hangfire.State table:
Jobid Name CreatedAt Data
10883106 Enqueued 2017-03-24 22:55:04.983 {“EnqueuedAt”:“2017-03-24T22:55:04.8576274Z”,“Queue”:“default”}
10883106 Processing 2017-03-24 22:55:05.030 {“StartedAt”:“2017-03-24T22:55:04.9982014Z”,“ServerId”:“p10ssuatapp01~server1:5680:48b5d760-b25a-402c-98c5-977ccdea4fef”,“WorkerId”:“09dd3fdf-334e-4232-844d-73a82df9027d”}
10883106 Succeeded 2017-03-24 22:55:05.107 {“SucceededAt”:“2017-03-24T22:55:05.0451503Z”,“PerformanceDuration”:“2”,“Latency”:“172”}

From the Hangfire.List table:
Key Value
batch:e7f2b583-e1c7-4081-a480-c885102f8a67:states {"$type":“Hangfire.Batches.States.BatchAwaitingState, Hangfire.Pro”,“ParentBatchId”:“f716c944-2745-491e-9f81-5bfbb399c533”,“CreatedAt”:“2017-03-24T22:55:04.9982014Z”}
batch:f716c944-2745-491e-9f81-5bfbb399c533:states {"$type":“Hangfire.Batches.States.BatchStartedState, Hangfire.Pro”,“CreatedAt”:“2017-03-24T22:55:04.8732783Z”}