Prevent Quartz job recovery from starting on long-runnng tasks - quartz-scheduler

I'm building Quartz jobs with the RequestRecovery flag set, because I have multiple server instances running and if one fails while running a job, I'd like another instance to pick up that job and restart it.
IJobDetail job = JobBuilder.Create<SystemMaintenance>()
.WithIdentity("SystemMaintenance", "SystemMaintenance")
.RequestRecovery(true)
.WithDescription("System task that runs every 6 hours")
.Build();
However, what I've noticed is that if the job is running for a very long time (say over 10 minutes), the other instances will start running the job because they assume that it has failed, even though it is running fine.
Is there any way that I can periodically ping Quartz, perhaps through JobExecutionContext, to let it know that a specific instance is still running and processing a job, to prevent others from assuming failure and starting it?
EDIT:
My configuration looks like this:
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "Scheduler";
properties["quartz.scheduler.instanceId"] = "AUTO";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "5";
properties["quartz.threadPool.threadPriority"] = "Normal";
properties["quartz.jobStore.misfireThreshold"] = "60000";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "true";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
properties["quartz.jobStore.clustered"] = "true";
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";
properties["quartz.dataSource.default.connectionString"] = ConnectionStringService.DatabaseConnectionString;
properties["quartz.dataSource.default.provider"] = "SqlServer-20";

Related

"consecutive SC failures" on gem5 simple config script

I am new to gem5 and I ran into a problem while trying to write a simple multi-core system configuration script. my script is based on the example scripts given on: http://learning.gem5.org/book/part1/cache_config.html
When i try to add more than one dcache to the system (for each different core) im getting an infinite loop of this warning message:
warn: 186707000: context 0: 10000 consecutive SC failures.
incremented by 10000 each time.
I tried looking in gem5's given configuration scripts se.py and CacheConfig.py but I still cant understand what im missing here. I know that I can just simulate this configuration using se.py but I tried to do this by myself as practice and to get a deeper understanding of the gem5 simulator.
some additional info: im running gem5 in se mode and trying to simulate a simple multicore system using riscv cores.
this is my code:
import m5
from m5.objects import *
from Caches import *
#system config
system = System(cpu = [TimingSimpleCPU(cpu_id=i) for i in xrange(4)])
system.clk_domain = SrcClockDomain()
system.clk_domain.clock = '1GHz'
system.clk_domain.voltage_domain = VoltageDomain()
system.mem_mode = 'timing'
system.mem_ranges = [AddrRange('512MB')]
system.cpu_voltage_domain = VoltageDomain()
system.cpu_clk_domain = SrcClockDomain(clock = '1GHz',voltage_domain= system.cpu_voltage_domain)
system.membus = SystemXBar()
system.l2bus = L2XBar()
multiprocess =[Process(cmd = 'tests/test-progs/hello/bin/riscv/linux/hello', pid = 100 + i) for i in xrange(4)]
#cpu config
for i in xrange(4):
system.cpu[i].icache = L1ICache()
system.cpu[i].dcache = L1DCache()
system.cpu[i].icache_port = system.cpu[i].icache.cpu_side
system.cpu[i].dcache_port = system.cpu[i].dcache.cpu_side
system.cpu[i].icache.mem_side = system.l2bus.slave
system.cpu[i].dcache.mem_side = system.l2bus.slave
system.cpu[i].createInterruptController()
system.cpu[i].workload = multiprocess[i]
system.cpu[i].createThreads()
system.l2cache = L2Cache()
system.l2cache.cpu_side = system.l2bus.master
system.l2cache.mem_side = system.membus.slave
system.system_port = system.membus.slave
system.mem_ctrl = DDR3_1600_8x8()
system.mem_ctrl.range = system.mem_ranges[0]
system.mem_ctrl.port = system.membus.master
root = Root(full_system = False , system = system)
m5.instantiate()
print ("Begining Simulation!")
exit_event = m5.simulate()
print ('Exiting # tick {} because {}' .format(m5.curTick() , exit_event.getCause()))

C# and Powershell Runspaces creating massive unmanaged memory leak

I have a strange issue with a windows service that I'm developing in .Net 4. After an hour of running the service the memory usage is at 274MB.
I have tried to find the cause of the leak by removing the functions one by one to find out where the leak occurs and at the moment because of this all the service does is run a PowerShell command Get-WBSummary every 10 seconds and capture the output to a string.
I am trying to track down what is hogging all the memory using Red Gate .Net Profiler 10. When I look at the biggest hog of memory after an hour the only thing that sticks out is
Namespace Class name Live size (bytes) Unmanaged size (bytes)
System.Reflection RuntimeAssembly 1,400 1,462,189
Which cant be right as that comes out to 1.462189mb.
Here is the code I am using which runs every time the service timer hits 10 seconds (For testing I set it to a low value)
var Config = RunspaceConfiguration.Create();
PSSnapInException Warning;
if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)
{
Config.AddPSSnapIn("Windows.ServerBackup", out Warning);
}
using (var Runspace = RunspaceFactory.CreateRunspace(Config))
{
Runspace.Open();
PowerShell Ps;
using (Ps = PowerShell.Create())
{
Ps.Runspace = Runspace;
Ps.AddCommand("Get-WBSummary");
var Output = Ps.Invoke();
var Sb = new StringBuilder();
foreach (var PsObject in Output)
{
foreach (var PsPropertyInfo in PsObject.Properties)
{
Sb.AppendLine(PsPropertyInfo.Name + " " + PsPropertyInfo.Value);
}
}
PowershellOutput = Sb.ToString();
}
Runspace.Close();
Runspace.Dispose();
Ps.Dispose();
Config = null;
PowerShellSession.Stop();
PowerShellSession.Dispose();
GC.Collect();
Can anyone suggest what I might be doing wrong?
Edit:
The problem here has nothing to do with the C# code but the way I was using PowerShell. The solution is instead of using one PowerShell runspace and entering the same command again and again in it (Which causes the PowerShell memory to increase to infinity) but to create a new PowerShell process every time and then close it when you are done
using (PowerShellProcessInstance ExternalPowerShellProccess = new PowerShellProcessInstance())
{
ExternalPowerShellProccess.Process.Start();
var Config = RunspaceConfiguration.Create();
if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)
{
Config.AddPSSnapIn("Windows.ServerBackup", out PSSnapInException Warning);
}
Runspace Runspace = RunspaceFactory.CreateOutOfProcessRunspace(TypeTable.LoadDefaultTypeFiles(), ExternalPowerShellProccess);
Runspace.Open();
using (PowerShell Ps = PowerShell.Create())
{
Ps.Runspace = Runspace;
Ps.AddCommand("Get-WBSummary");
var Output = Ps.Invoke();
var Sb = new StringBuilder();
foreach (var PsObject in Output)
{
foreach (var PsPropertyInfo in PsObject.Properties)
{
Sb.AppendLine(PsPropertyInfo.Name + " " + PsPropertyInfo.Value);
}
}
PowershellOutput = Sb.ToString();
Ps.Dispose();
Runspace.Close();
Runspace.Dispose();
}

PostgreSQL strange UPDATE time 2?

As I reported in my previous post, I'm faced with a problem running my VB.NET application with POSTGRESQL 9.6 and Npgsql 3.2.6 on WIN10. The problem is a strange long time required to perform some DML statements on a table with 250 rows (normally few ms but sometime 0.8s!).
As Laurenz Albe suggested in response to my previous post, I activated the log on PostgreSQL but no statements are logged when the strange behavior occurs.
The PostgreSQL DB server is connected to the main pc by a GB lan.
In my application I have a separate thread in which I perform my tasks (including activities on DB).
In this thread i call the update this way:
Dim vT As DateTime = Now
'apertura lavorazione
vRet = mMaster.DB.apriLavorazione(vPallet)
Dim vS As String = (Now - vT).Seconds.ToString + ":" + (Now - vT).Milliseconds.ToString
The update function is something like this:
Function apriLavorazione(ByRef pPallet As clsPallet) As clsCallRes
Dim vObjRet As clsCallRes = New clsCallRes
Dim vConn As NpgsqlConnection = Nothing
Dim vCommand As NpgsqlCommand = Nothing
Dim vPar As NpgsqlParameter
Try
'creo la connessione
vConn = New NpgsqlConnection(mConnectionString)
vConn.Open()
pPallet.intermedio1 = Now
'creo il comando dalla connessione ed associo la transazione
vCommand = vConn.CreateCommand()
pPallet.WPAL_DATA_INI = DateTime.Now()
vCommand.CommandText = "UPDATE work.wip_pallets SET WPAL_DATA_INI = #dataini" +
" ,STAZ_ID = #stazid, WPAL_PRESENZA_CEPA = #presenzacepa, WPAL_SCARTO = #scarto" +
" WHERE CEPA_CODICE = #cepacodice;"
vPar = New NpgsqlParameter
vPar.ParameterName = "dataini"
vPar.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Timestamp
vPar.Value = pPallet.WPAL_DATA_INI.ToString("yyyy-MM-dd HH:mm:ss.fff")
vCommand.Parameters.Add(vPar)
vPar = New NpgsqlParameter
vPar.ParameterName = "stazid"
vPar.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer
vPar.Value = pPallet.STAZ_ID
vCommand.Parameters.Add(vPar)
vPar = New NpgsqlParameter
vPar.ParameterName = "presenzacepa"
vPar.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer
vPar.Value = pPallet.WPAL_PRESENZA_CEPA
vCommand.Parameters.Add(vPar)
vPar = New NpgsqlParameter
vPar.ParameterName = "scarto"
vPar.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer
vPar.Value = pPallet.WPAL_SCARTO
vCommand.Parameters.Add(vPar)
vPar = New NpgsqlParameter
vPar.ParameterName = "cepacodice"
vPar.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar
vPar.Value = pPallet.CEPA_CODICE
vCommand.Parameters.Add(vPar)
vCommand.Prepare()
vCommand.ExecuteNonQuery()
Catch ex As Exception
vObjRet.err = True
vObjRet.message = String.Concat("apriLavorazione:", ex.Message)
Finally
vConn.Close()
End Try
Return vObjRet
End Function
I don't think is a code that can require about one second!
Do you have any idea what the problem might be?
1) npgsql on thread?
2) network latency?
3) bad code for multithreaded application?
4) ????
I've moved the DB on the same machine as the application that use it. At this time (and i hope for the future) the strange update time never occurred again. I suspect something related to network latency.
Thanks for your time reading this post.

Quartz .Net resume after application restart

I have quartz working with MS SQL, it stores all the job detail in sql but I don't know how to set it up to resume all the jobs after application restart.
can anyone please let me know how setup quartz to resume jobs after application restart.
This is what I do to schedule a job on api call
File.AppendAllText(#"C:\Temp\test.txt",$"Starting sechd at {DateTime.Now.ToString("ddMMyyyyHHmmss")}");
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sc = sf.GetScheduler();
sc.Start();
IJobDetail emailJob = JobBuilder.Create<EmailJob>()
.WithIdentity("reportemail", "reportgroup")
.Build();
string dom = js.DayOfMonth.ToString();
if (js.DayOfWeek > 0)
dom = "?";
string dow = (js.DayOfWeek < 1) ? "*" : js.DayOfWeek.ToString();
string y = (js.Year > 0) ? js.Year.ToString() : "*";
string m = (js.Month > 0) ? js.Month.ToString() : "*";
string crn = $"{js.Second.ToString()} {js.Minute.ToString()} {js.Hour.ToString()} {dom} {m} {dow} {y}";
ITrigger trigger = TriggerBuilder.Create()
.ForJob(emailJob)
.WithIdentity("reporttrigger","reportgroup")
.WithCronSchedule("0 0/3 * ? * *")
.StartNow()
.Build();
sc.ScheduleJob(emailJob, trigger);
Thanks
Im currently using Quartz.Net in my MVC application, and what I have done is in my JobScheducler.cs I have a method called "Start" where I have placed all the code, for the schedules I want to be run on application start.
In Global.asax I have instantiated the JobScheduler and I then call the start method, which in turn. Starts all of the schedules I've set up to be run.

How to set up Slave Database configuration in vBulletin?

How to set up Slave Database configuration in vBulletin ? I set up like this:
$config['Database']['dbtype'] = 'mysql';
$config['Database']['dbname'] = 'xyz';
$config['Database']['tableprefix'] = 'vbulletin1_';
$config['Database']['technicalemail'] = 'xyz#abc.com';
$config['Database']['force_sql_mode'] = false;
$config['MasterServer']['servername'] = 'xyz';
$config['MasterServer']['port'] = 3306;
$config['MasterServer']['username'] = 'x';
$config['MasterServer']['password'] = 'xxxx';
$config['MasterServer']['usepconnect'] = 0;
$config['SlaveServer']['servername'] = 'abc';
$config['SlaveServer']['port'] = 3306;
$config['SlaveServer']['username'] = 'a';
$config['SlaveServer']['password'] = 'xxxx';
$config['SlaveServer']['usepconnect'] = 0;
This is depends from your slave DB credentials only. And "Slave DB" means that you have replicated DB on your host (vBulletin can't make this, it should be done automatically by your web server). So, if you have not a replicated DB, you should not setup Slave DB.
A Master-Slave setup is for performance. You send write queries to the master server, and most read queries to the slave server. It helps improve performance because write queries lock tables/rows depending on the database table type, and reads do not.
vBulletin forum