Pre-release

@odinserj odinserj released this Sep 1, 2018

Assets 3

Release Notes

The goal of this release is to incorporate important changes from recent versions 1.6.18, 1.6.19 and 1.6.20, as well as provide great improvements for Hangfire.SqlServer unlocked by schema changes introduced in 1.7.0:

  • Blocking fetch. It is possible now to avoid polling when using SQL Server. Short-lived (2 seconds) application locks are used to implement this behavior, and workers don't compete now with each other and don't perform unnecessary concurrent logical reads when queue is empty. The only requirement is to use sliding-expiration-based fetch as shown below.
  • Less CPU-consuming fetch when using sliding expiration-based fetch. When using table as a queue, the major CPU consumption is done for scanning ghost rows, since SQL Server deletes records asynchronously. Now page locks are acquired to force SQL Server to remove them in-place, instead of postponing this action. It's essential to minimize the lifetime of these locks, so improvement works only for sliding-expiration fetch method.
  • Improved parallelism for hashes, sets and lists. Instead of acquiring global, coarse-grained application locks, we now using regular SQL Server's locks. To avoid deadlocks, we are reordering writes in transactions to match clustered key sorting.

To use all the new features, consider adding the following lines to your configuration logic:

GlobalConfiguration.Configuration
    .UseSqlServerStorage(@"connection_string", new SqlServerStorageOptions
    {
        SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5), // To enable Sliding invisibility fetching
        CommandBatchMaxTimeout = TimeSpan.FromMinutes(5), // To enable command pipelining
        QueuePollInterval = TimeSpan.FromTicks(1) // To reduce processing delays to minimum
    })

Hangfire.Core

  • FixedMissingMethodException when using Newtonsoft.Json 11 in .NET Core 2.X with continuations (by @pieceofsummer).
  • Ported – Merged updates from versions 1.6.18 – 1.6.20.

Hangfire.SqlServer

  • Added – Blocking fetch support for sliding expiration-based fetch to avoid excessive polling.
  • Changed – Optimize sliding-expiration-based fetching to use even less CPU time.
  • Changed – Use write reordering and fine-grained locking scheme to improve parallelism.
  • Ported – Merged updates from versions 1.6.18 – 1.6.20.
Assets 3

Release Notes

This release contains fixes for security issues related to dashboard, so it is highly recommended to upgrade. Cross-Site Request Forgery protection was added by using existing libraries, but methods are different across application frameworks:

  • For ASP.NET Core, no additional configuration is required, since Microsoft.AspNetCore.Antiforgery package is used to generate and validate tokens. Dependency injection is used to obtain the implementation and apply it when available.
  • For other frameworks, additional configuration is required based on an abstract IOwinDashboardAntiforgery interface, because the available implementation is tightly coupled with the System.Web.Helpers assembly. Please check this gist to learn how to enable antiforgery token validation on ASP.NET and ASP.NET MVC platforms.

Other important updates include a new retry implementation for state changes in the Worker class to avoid any reads and writes whenever it is possible for a job's distributed lock to be abandoned, because it may lead to consistency issues. Transitions directly to the Failed state without applying the job filters were also disabled, because such a behavior is not a determined one.

Also, looks like waiting on CancellationToken.WaitHandle rarely leads to high CPU usage. I was unable to reveal the exact reason for this, but any other implementation, including using Task.Delay or own tandem of CancellationToken.Register with ManualResetEvent works fine without such issues.

Hangfire.Core

  • SECURITY – Add "robots" meta tag to ensure browser don't index dashboard pages.

  • SECURITY – Add support for antiforgery validation to prevent CSRF attacks (requires configuration).

  • Fixed – Perform state change retries using a fresh connection when job's distributed lock may be abandoned

  • Fixed – Disallow transitions to the Failed state on retries that bypass all the filters

  • Fixed – Remove possible rare CPU spikes due to the use of CancellationToken.WaitHandle

  • Fixed – Avoid resolving types and methods for logging in static constructors that may lead to process shutdown

  • Fixed – Prevent Recurring jobs dashboard from throwing NullReferenceException (#1203 by @mattkwiecien)

  • Fixed – Replace wall clocks with monotonic ones when calculating local timeouts

  • Fixed – Change logger initialization to be deterministic and predictable by using instance fields

  • Fixed – Make _currentLogProvider field access to use volatile reads/writes

  • Fixed – Typo in NotSupportedException's message (#1210 by @benrick)

  • Fixed – Typo on the Failed jobs page (#1207 by @gareth-evans)

Hangfire.SqlServer

  • Fixed – Remove the synthetic limitation to support Azure SQL Management instance (#1222, #1230 by @TimSQL)

Hangfire.AspNetCore

  • SECURITY – Use ASP.NET Core's built-in antiforgery validation to prevent CSRF attacks

@odinserj odinserj released this Apr 6, 2018 · 19 commits to master since this release

Assets 3

Release Notes

Hangfire.Core

  • FixedNullReferenceException in JobMethodCallRenderer regression appeared in 1.6.18.

Hangfire.SqlServer

  • Fixed – "String or binary data would be truncated" exception when state reason is too long.
  • Fixed – Command handling in batch mode now stops after the first error due to "XACT_ABORT ON".
  • Fixed – Make SqlCommandBatch disposable to dispose all the commands.

@odinserj odinserj released this Apr 5, 2018 · 25 commits to master since this release

Assets 3

Release Notes

This release contains a lot of fixes, but the most important ones are related to .NET Core and ASP.NET Core frameworks. Filters based on attributes are now working fine there, and DisplayName decoration will finally bring the human-ready name for your jobs. Other fixes are mostly related to dashboard.

Hangfire.Core

  • Added – Add on option to remove the storage connection string from the footer (PR #1079 by @sandorfr).
  • Added – Add Dashboard UI Resource zh-TW (PR #1105 by @crablin).
  • Fixed – OutOfMemoryException in dashboard when arguments are too big (#1051, PR #1153).
  • Fixed – DisplayNameAttribute doesn't work when using dashboard in .NET Core (PR #1154).
  • Fixed – Update rickshaw css to match the js version (PR #1018 by @pieceofsummer).
  • Fixed – Bad exception when Job.FromExpression fails to resolve method for explicit interface implementations (#1050, PR #1056 by @f00).
  • Fixed – Missing intValue-values in "/stats" endpoint (PR #1152 by @pieceofsummer).
  • Fixed – Logging doesn't work with log4net integration in .NET Core (#1095, PR #1134 by @evollu).
  • Fixed – Fix nuspec pointing to version of Newtonsoft.Json that does not exist (#947, #973, PR #1083 by @mvestergaard)
  • Fixed – Server start time has a bad tooltip position (PR #1029 by @pieceofsummer).
  • Fixed – Prevent connection string from blowing mobile page layout (PR #1030 by @pieceofsummer).
  • Fixed – Number of recurring jobs per page is now correct (PR #1006 by @pieceofsummer).
  • Project – Get rid of all the compile-time warnings (PR #1058 by @liakamp).
  • Project – More details for build instructions for the project (PR #1055 by @kristofferjalen).
  • Project – Unable to build project with space in folder path (#809, PR #1057 by @stefanviberg).

Hangfire.AspNetCore

  • Added – More Hangfire-related services are now registered in an IoC container (PR #800 by @pieceofsummer).
  • Fixed – Queue parameter is ignored in .NET Core when creating a job (#799, PR #800 by @pieceofsummer).
  • Fixed – Fix issue with configuration block not called on .NET Core (PR #800 by @pieceofsummer).

Hangfire.SqlServer

  • Fixed – Rare deadlocks in SQL Server caused by the SetRangeInHash command (#1124, PR #1139).
Pre-release

@odinserj odinserj released this Mar 2, 2018 · 74 commits to dev since this release

Assets 3

Release Notes

This is a preview of the next release that contains important changes in a lot of subsystems. A completely new background processing engine introduced with support for both synchronous and asynchronous processes while using the same model. While processing is still not asynchronous, because storage methods aren't (see #1116 planning for 1.8.0), it's a great step forward.

After dealing with a lot of daylight saving time transition issues, we've decided to build a completely new library to work with cron expression. So the Cronos project was born contains first-class support for time zones and knows about all the subtleties.

And last but not least, it contains major upgrades to the Hangfire.SqlServer package with the new optimized schema with much fewer indexes, and identity columns upgraded to the bigint type for those, who processed 2,147,483,647 background jobs.

Hangfire.Core

  • Added – Entry point for custom job naming strategies available for dashboard (PR #660 by @pieceofsummer).
  • AddedJobDisplayNameAttribute class for displaying jobs in dashboard, available on .NET Core (PR #993 by @pieceofsummer).
  • Added – Support async jobs returning ValueTask<T> and other await-compatible types (PR #974 by @pieceofsummer).
  • Added – Support for asynchronous background processes, opens the road toward async storage (PR #1082, #150).
  • Added – Circuit breaker pattern for background processes to reduce the logging pressure (PR #1082).
  • Added – Processing server is now able to detect it was expired, and restart itself with the new id (PR #1082).
  • Added – Ability to use custom delays for automatic retries of a background job (PR #931).
  • AddedThreadAbortException and ThreadInterruptedException handling to keep the background process running (PR #1082).
  • Added – Support for complex Cron expressions, including the L, W, # characters (PR #853, #494).
  • AddedJobActivator.BeginScope method overload with the full PerformContext (PR #995 by @jeroenvervaeke, #828).
  • Added – Support for read-only view for dashboard (PR #934 by @mikechamberlain, #423, #758).
  • Added – Storage property to control the job expiration time (PR #913 by @rsilvanet).
  • Changed – Decrease the size of serialized payloads and remove version information (PR #891).
  • Fixed – Server disappears from the list, but still performing the background processing (#796, #1123).
  • Fixed – Logging is too aggressive on transient errors (#542).
  • Fixed – Daylight saving time transitions now handled perfectly in recurring jobs thanks to Cronos (#567).
  • Fixed – Confusing Cron scheduling, when both day-of-week and day-of-month fields set (#979).

Hangfire.SqlServer

  • Added – Callback method to allow to open the database with impersonation (PR #907 by @BjoernHund).
  • Changed – Identity columns either converted to the bigint type, or entirely removed (PR #898).
  • Changed – Clustered indexes were organized according to the access patterns of their tables (PR #898).
  • Changed – Most of secondary indexes were either removed or made filtered (PR #898).
  • Fixed – Background processing stops when identity columns exceed the Int32.MaxValue (#749).
  • Fixed – Slowdown of scheduled jobs due to the missing index on the Set table (#844).

@odinserj odinserj released this Sep 19, 2017 · 74 commits to master since this release

Assets 3

Release Notes

Hangfire.SqlServer

  • AddedSqlServerStorageOptions.CommandBatchMaxTimeout parameter to enable batching in transactions.
  • Fixed – Timeout exceptions when there are a lot of large concurrent transactions by using the new batching method.
  • Fixed – Distributed locks are safe now even in very unreliable networks and after network blips.
  • Performance – Greatly decreased the number of connections required to process background jobs.
  • Performance – Significantly decrease the number of roundtrips required to commit a transaction.

@odinserj odinserj released this Sep 2, 2017 · 80 commits to master since this release

Assets 3

Release Notes

This is yet another maintenance release that fixes a bunch of non-critical bugs in Hangfire.Core and Hangfire.SqlServer packages.

Hangfire.Core

  • Fixed – Unexpected DateTime and DateTime? serialization issues in background job arguments (#971 by @plaisted, #970, #972).
  • FixedDistributedLockTimeoutException in some background processes now logged with "DEBUG" level instead of "ERROR" (#789).
  • FixedElmahLogProvider to show errors when using SQL log (#867 by @francnuec).
  • Fixed – Last execution field isn't shown on recurring jobs page, when background job has already expired (#930).
  • FixedHangfire.SqlServer assembly doesn't include version in the netstandard target (#951).

Hangfire.SqlServer

  • Fixed – Lower the number of requests, when trying to acquire a distributed lock.
  • Fixed – Problems with continuations and batch continuations, when using existing SqlConnection instance.
  • Fixed – Distributed locks were silently released, when passing explicit closed connection to a storage.
  • FixedKeyNotFoundException errors on various dashboard pages don't appear anymore (#948 by @benjymous, #945, #946).
  • Fixed – "Cannot release the application lock because it is not currently held" exceptions, when connection was closed.
  • Fixed – Allow to use zero timeout for SQL Server-based distributed locks (#967).

@odinserj odinserj released this Aug 8, 2017 · 103 commits to master since this release

Assets 3

Release Notes

This release contains important fixes for the Hangfire.SqlServer package, which is actively using the sp_getapplock stored procedure to synchronize work between different servers. I've realized that locks shouldn't be awaited on SQL Server's side, because this may lead to SQL Server's connection pool starvation, because each blocked request will block a single worker thread.

When you are using a lot of workers, and there's a contention on few lock resources (like when using the DisableConcurrentExecutionAttribute, batches or many continuations on a single job), all worker threads can be blocked in SQL Server, causing its unresponsiveness and lead to huge amount of timeout exceptions.

Hangfire.SqlServer

  • Fixed – Timeout exceptions that's caused by SQL Server's thread pool starvation, caused by sp_getapplock (fbe756e).
  • Fixed – Antecedent background job is constantly failing, when its continuation hasn't been fully created (8bece53).

@odinserj odinserj released this Jun 16, 2017 · 106 commits to master since this release

Assets 3

Release Notes

This versions adds possibility to use non-transactional message fetching algorithm when using Hangfire.SqlServer package. This is especially helpful, if you have a lot of long-running background jobs, since they may prevent you from taking transaction log backups, leading to the Transaction log is full due to 'ACTIVE_TRANSACTION' error.

The new implementation is based on the old invisibility timeout, but workers are now periodically renewing that timeout, so you can forget about setting too high timeout just to allow your long-running background jobs to run smoothly. Non-transactional fetch is not enabled by default in this version (but will be in 1.7.0), to configure it use the SlidingInvisibilityTimeout option.

Lower values will stress your database (for example, if it is set to 5 minutes, each worker will run a keep-alive query each minute when processing a job), higher values will add a corresponding delay, when processing is terminated ungracefully.

GlobalConfiguration.Configuration.UseSqlServerStorage(
    "connection_string", 
    new SqlServerStorageOptions { SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5) });

Hangfire.SqlServer

  • AddedSqlServerStorageOptions.SlidingInvisibilityTimeout to fetch jobs without using transaction.
  • Fixed – Transaction log is full due to 'ACTIVE_TRANSACTION' by allowing to use new non-transactional fetch.
  • FixedSqlServerJobQueueMonitoringApi can't cause READ UNCOMMITTED isolation level to leak on SQL Server 2012 or earlier.
  • Fixed – Add missing SqlServerStorage(DbConnection, SqlServerStorageOptions) constructor.

@odinserj odinserj released this Jun 7, 2017 · 111 commits to master since this release

Assets 3

Release Notes

This release contains a bunch of fixes for core and integration packages. The most important updates are fix for SQL connection leaks when we failed to acquire a distributed lock, and wrong queue selection, when continuation is created after antecedent job is finished. So upgrade is recommended.

Hangfire.Core

  • Fixed – Continuation is fired on a wrong queue, when parent job is finished before the creation.
  • Fixed – Impossible to intercept failed state transition before AutomaticRetryAttribute.
  • Fixed – Fixed translation in Chinese localization on home page (by @JustinChia).
  • Fixed – Don't throw NullReferenceException, when state has changed during query on Processing page.
  • FixedCreateBatchFailedException, when batch creation takes longer than 1 hour.

Hangfire.AspNetCore

  • Fixed – Types are resolved using the GetServiceOrCreateInstance method (by @Tsabo).

Hangfire.SqlServer

  • FixedSqlServerDistributedLock leaks connections, when lock acquisition is failed.
  • Fixed – Don't hide errors occurred while running SQL migrations.
  • FixedKeyNotFoundException when accessing Deleted Jobs page in Dashboard.