HangfireIO / Hangfire.Azure.ServiceBusQueue

ServiceBus Queue support for SQL Server job storage implementation
MIT License
58 stars 33 forks source link

LastHeartbeat SQL Issue #16

Open YodasMyDad opened 4 years ago

YodasMyDad commented 4 years ago

I apologise if I'm not understanding this add on correctly, but I thought adding this would move the polling/heartbeat away from SQL and into AzureServiceBus.

However, I have this running on my site and noticed I've been getting a SQL time out error every now and then which is attributed to "update [HangFire].Server set LastHeartbeat = @now where Id = @id". I can see Hangfire smashing the SQL db every second?

I was under the impression that this removed the need for the constant SQL heartbeat?

odinserj commented 4 years ago

You can control the heartbeat rates by using HeartbeatInterval and ServerTimeout properties in the BackgroundJobServerOptions class you can inject when creating a background job server. Ensure that multiple (at least) heartbeats are sent within the ServerTimeout timespan.

They are still required, because background job server will restart itself if heartbeat wasn't succeeded because the record from the Server table was removed. And since we need to somehow remove obsolete records even in case of unexpected termination, we need some sort of timeouts here.