Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I found that the most resource hogger for our sql server is the sp_ge… #1506

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Hangfire.SqlServer/SqlServerJobQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private SqlServerTimeoutJob DequeueUsingSlidingInvisibilityTimeout(string[] queu
if (queues.Length == 0) throw new ArgumentException("Queue array must be non-empty.", nameof(queues));

var lockResource = $"{_storage.SchemaName}_FetchLockLock_{String.Join("_", queues.OrderBy(x => x))}";
var isBlocking = false;
var isBlocking = _options.NonBlockingFetchSql;

var pollingDelayMs = Math.Min(
Math.Max((int)_options.QueuePollInterval.TotalMilliseconds, MinPollingDelayMs),
Expand Down Expand Up @@ -144,7 +144,7 @@ private SqlServerTimeoutJob DequeueUsingSlidingInvisibilityTimeout(string[] queu
throw new InvalidOperationException($"A call to sp_getapplock returned unexpected result '{lockResult.Value}' while fetching a job. Please report this problem to Hangfire developers and don't use sub-second values for the QueuePollInterval option.");
}

if (_options.QueuePollInterval < LongPollingThreshold)
if (_options.QueuePollInterval < LongPollingThreshold && !_options.NonBlockingFetchSql)
{
isBlocking = true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Hangfire.SqlServer/SqlServerStorageOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public SqlServerStorageOptions()
TransactionTimeout = TimeSpan.FromMinutes(1);
DisableGlobalLocks = false;
UsePageLocksOnDequeue = false;
NonBlockingFetchSql = true;
}

[Obsolete("TransactionIsolationLevel option is deprecated, please set UseRecommendedIsolationLevel instead. Will be removed in 2.0.0.")]
Expand Down Expand Up @@ -122,5 +123,7 @@ public string SchemaName
public bool UsePageLocksOnDequeue { get; set; }
public bool UseRecommendedIsolationLevel { get; set; }
public bool EnableHeavyMigrations { get; set; }

public bool NonBlockingFetchSql { get; set; }
}
}