Comments (8)
The problem here is that DailyCalendar.GetNextIncludedTimeUtc()
iterates checking every next millisecond whether it would fit the range. Increments could be larger / start position could be calculated more precisely when we know that there's no need for millisecond or even second precision.
from quartznet.
The following calendar configuration crashes on GetNextIncludedTimeUtc
: System.ArgumentOutOfRangeException : The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')
[Test]
public void GetNextIncludedTimeUtc()
{
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var weeklyCalendar = new WeeklyCalendar()
{
TimeZone = timeZone,
};
var dailyCalendar = new DailyCalendar(weeklyCalendar, "06:00", "22:00")
{
TimeZone = timeZone,
InvertTimeRange = true,
};
var holidayCalendar = new HolidayCalendar(dailyCalendar)
{
TimeZone = timeZone,
};
holidayCalendar.AddExcludedDate(new DateTime(2024, 2, 19));
holidayCalendar.AddExcludedDate(new DateTime(2024, 5, 27));
holidayCalendar.AddExcludedDate(new DateTime(2024, 6, 19));
holidayCalendar.AddExcludedDate(new DateTime(2024, 7, 4));
holidayCalendar.AddExcludedDate(new DateTime(2024, 9, 2));
holidayCalendar.AddExcludedDate(new DateTime(2024, 10, 14));
holidayCalendar.AddExcludedDate(new DateTime(2024, 11, 11));
holidayCalendar.AddExcludedDate(new DateTime(2024, 11, 28));
holidayCalendar.AddExcludedDate(new DateTime(2024, 12, 25));
var time = new DateTime(2024, 2, 5, 10, 6, 0, DateTimeKind.Utc);
var expected = new DateTime(2024, 2, 5, 14, 0, 0, DateTimeKind.Utc);
var d = holidayCalendar.GetNextIncludedTimeUtc(time); // throws System.ArgumentOutOfRangeException : The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')
d.Should().Be(expected);
}
from quartznet.
Possibly related dotnet/runtime#25075
One hotspot is the calls to TimeZoneInfo.ConvertTime
in a tight loop.
from quartznet.
@al007 Please check if latest 3.x / master branches in repo resolves your issue.
from quartznet.
No, unfortunately, it does not. The example from the 1st post in this thread works even slower now: 20 seconds for .net8 and 50 seconds for net472. However, it does fix the crash for the 2nd example.
from quartznet.
The example you provided should be in the repo, it executes here in about 43ms.
This is from 3.x branch.
Can you please try running.?
dotnet test --filter GetNextIncludedTimeUtc_CrashOriginal2270
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 43 ms - Quartz.Tests.Unit.dll (net8.0)
from quartznet.
@jafin , this method has two issues: poor performance and a crash. I reported them together because I thought they were related and re-working the algorithm would fix both.
Performance issue happens for the following calendar configuration HolidayCalendar->WeeklyCalendar->DailyCalendar
, see 1st post here. It is not fixed in the 3.x branch. It takes from 20 to 50 seconds as described above.
The crash happens for calendar WeeklyCalendar->DailyCalendar->HolidayCalendar
, see 2nd post here. It is fixed in the 3.x branch and runs fast.
from quartznet.
@al007 Perhaps I am missing something I copied the example, ran the below against 3.x branch, completed in ~20ms
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 11 ms - Quartz.Tests.Unit.dll (net8.0)
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 22 ms - Quartz.Tests.Unit.dll (net472)
[Test]
public void GetNextIncludedTimeUtcFirstIssue()
{
TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
var holidayCalendar = new HolidayCalendar()
{
TimeZone = timeZone,
};
holidayCalendar.AddExcludedDate(new DateTime(2024, 2, 19));
holidayCalendar.AddExcludedDate(new DateTime(2024, 5, 27));
holidayCalendar.AddExcludedDate(new DateTime(2024, 6, 19));
holidayCalendar.AddExcludedDate(new DateTime(2024, 7, 4));
holidayCalendar.AddExcludedDate(new DateTime(2024, 9, 2));
holidayCalendar.AddExcludedDate(new DateTime(2024, 10, 14));
holidayCalendar.AddExcludedDate(new DateTime(2024, 11, 11));
holidayCalendar.AddExcludedDate(new DateTime(2024, 11, 28));
holidayCalendar.AddExcludedDate(new DateTime(2024, 12, 25));
var weeklyCalendar = new WeeklyCalendar(holidayCalendar)
{
TimeZone = timeZone,
};
var calendar = new DailyCalendar(weeklyCalendar, "06:00", "22:00")
{
TimeZone = timeZone,
InvertTimeRange = true,
};
var time = new DateTime(2024, 2, 5, 10, 6, 0, DateTimeKind.Utc);
var expected = new DateTime(2024, 2, 5, 14, 0, 0, DateTimeKind.Utc);
var d = calendar.GetNextIncludedTimeUtc(time); // takes 13 seconds to execute!
d.Should().Be(expected);
}
from quartznet.
Related Issues (20)
- Error managing cluster: Failure updating scheduler state when checking-in: Exception while reading from stream HOT 4
- Recover scheduler
- How to handle critical code HOT 1
- Persian calendar to compute NextFireTime in triggers
- Getting SQLite 'database is locked.' Errors. It's a Design Issue
- BinaryFormatter removal HOT 1
- Add possibility on AdoJobStore to clear on startup HOT 5
- CronExpresion.GetTimeAfter caught exception HOT 2
- CronExpresion monthly and weekdayonly skips the month when on day of Saturday HOT 1
- Jobs with injected services that implement IAsyncDisposable are not disposed HOT 2
- Initialization fails when Window's TCP/IP Media Sense is disabled ("Cannot run without an instance id" exception) HOT 1
- Trigger doesn't fire job in Docker container of IHostedService
- Website not rendering (quartz-scheduler.net) HOT 1
- Jobs running multiples times after each deployment to the azure services
- CalendarIntervalSchedule is firing non-stop for 10 mins on the day that DST begins (and we lose an hour).
- Scheduler is frozen after one month of running. HOT 1
- XMLSchedulingDataProcessorPlugin: Issues with BinarySerializer HOT 1
- asynchronous method 'Quartz.Core.QuartzSchedulerThread.Run()', is waiting on a synchronous call to method 'System.Threading.Monitor.Wait(object, int)' HOT 2
- Upgrading from 3.3.3 to 3.8.1 resulted in error: communicating with remote scheduler HOT 2
- I have a common logic which is needed in all jobs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quartznet.