IoTSharp / SilkierQuartz

SilkierQuartz can host jobs using HostService and Provide a web management tools for Quartz !
http://sq.iotsharp.io/
MIT License
357 stars 71 forks source link

Second run of Quartz fails when using persistent store #111

Closed Grammarian closed 2 years ago

Grammarian commented 3 years ago

If I modify the SilkierQuartz.Example to use job persistence, it runs fine the first time.

But when I run it the second time, it throws this exception:

Unhandled exception. Quartz.JobPersistenceException: Couldn't store job: Unable to store Job: 'DEFAULT.HelloJobAuto', because one already exists with this identification.
 ---> Quartz.ObjectAlreadyExistsException: Unable to store Job: 'DEFAULT.HelloJobAuto', because one already exists with this identification.
   at Quartz.Impl.AdoJobStore.JobStoreSupport.StoreJob(ConnectionAndTransactionHolder conn, IJobDetail newJob, Boolean replaceExisting, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Quartz.Impl.AdoJobStore.JobStoreSupport.StoreJob(ConnectionAndTransactionHolder conn, IJobDetail newJob, Boolean replaceExisting, CancellationToken cancellationToken)
   at Quartz.Impl.AdoJobStore.JobStoreSupport.<>c__DisplayClass152_0.<<StoreJobAndTrigger>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Quartz.Impl.AdoJobStore.JobStoreSupport.ExecuteInNonManagedTXLock[T](String lockName, Func`2 txCallback, Func`3 txValidator, Nullable`1 requestorId, CancellationToken cancellationToken)
   at Quartz.Impl.AdoJobStore.JobStoreSupport.ExecuteInNonManagedTXLock[T](String lockName, Func`2 txCallback, Func`3 txValidator, Nullable`1 requestorId, CancellationToken cancellationToken)
   at Quartz.Impl.AdoJobStore.JobStoreSupport.StoreJobAndTrigger(IJobDetail newJob, IOperableTrigger newTrigger, CancellationToken cancellationToken)
   at Quartz.Core.QuartzScheduler.ScheduleJob(IJobDetail jobDetail, ITrigger trigger, CancellationToken cancellationToken)
   at SilkierQuartz.HostedService.QuartzHostedService.StartAsync(CancellationToken cancellationToken) in C:\src\GitHub\SilkierQuartz\src\SilkierQuartz\HostedService\QuartzHostedService.cs:line 50

This is the quartz section after I modified app.config:

  <quartz>
    <add key="quartz.plugin.recentHistory.type" value="Quartz.Plugins.RecentHistory.ExecutionHistoryPlugin, Quartz.Plugins.RecentHistory" />
    <add key="quartz.plugin.recentHistory.storeType" value="Quartz.Plugins.RecentHistory.Impl.InProcExecutionHistoryStore, Quartz.Plugins.RecentHistory" />

    <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
    <add key="quartz.jobStore.useProperties" value="true" />
    <add key="quartz.jobStore.dataSource" value="default" />
    <add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
    <add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
    <add key="quartz.dataSource.default.connectionString" value="Server=localhost; Database=MyTestDb;Integrated Security=true;"/>
    <add key="quartz.dataSource.default.provider" value="SqlServer" />
    <add key="quartz.serializer.type" value="json" />
  </quartz>

I'd like to be able to run Quartz more than once :)

maikebing commented 2 years ago

Well, it's a mistake.