-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Wrong PersistentStore is used when creating multiple Schedulers #2218
Comments
Can you create a complete sample, this is just one configuration. You can create check what kind of configuration you have with: var pool1 = SchedulerBuilder.Create()
.WithId(Guid.NewGuid().ToString())
.WithName("pool1");
foreach (string key in pool1.Properties.Keys)
{
Console.WriteLine($"{key}: {pool1.Properties[key]}");
}
|
Sure, here is a more complete example of what I am doing. As explained earlier, I am creating a scheduler for each unique datapool. foreach (var datapool in datapools)
{
if (_datapools.ContainsKey(datapool))
{
continue;
}
var builder = SchedulerBuilder.Create()
.WithId(Guid.NewGuid().ToString())
.WithName(datapool)
.UsePersistentStore(opt => GetConStr(opt, datapool))
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Scheduler config:");
foreach(string key in builder.Properties.Keys)
{
stringBuilder.AppendLine($"{key}: {builder.Properties[key]}");
}
var config = stringBuilder.ToString();
_logger.Debug(config);
var factory = builder.Build();
var scheduler = await factory.GetScheduler();
_schedulers.Add(datapool, scheduler);
} |
So what's the output? Please hide credentials and other sensitive data from connection strings. |
The output looks like this:
|
Seems that configuration have different values so calling |
I understand that. And I expected that. But I can reliably reproduce the problem described. If I build schedulers A and B in this order, A will write with the connection from B. If I build B first and then A, I end up with the same problem, but now both are writing to A. Even though I get the correct config output for each scheduler. If I build only A, it will write to A. If I build only B, it will write to B. |
I have prepared a sample project (see attached zip) that reproduces the problem for you. For simplicity, I am trying to connect to two different Oracle instances in this case. |
Today I noticed a github notification for a post by Uwe Laas on this topic, written on 13.12.2023, which is no longer there. Or at least I cannot see it. Is this the root of the problem or does it no longer apply?
|
Sorry, I deleted my comment because I completely misunderstood the problem.
Am 15.12.23 um 09:30 schrieb Roiskia:
Today I noticed a github notification for a post by Uwe Laas on this topic, written on 13.12.2023, which is no longer there. Or at least I cannot see it. Is this the root of the problem or does it no longer apply?
Sorry to jump in here, had the same problem while writing tests - isn't it the case that the SchedulerFactory uses the static 'Instance' of SchedulerRepository? I thought it was impossible to create multiple different schedulers within the same process, at least without using dirty tricks like reflection. So, always the same scheduler => always the same store. Or am I wrong?
—
Reply to this email directly, view it on GitHub<#2218 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AG5DAI2HZGO45J3K6EMRJG3YJQDC3AVCNFSM6AAAAABARRAGKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJXGQ3TQMZRGM>.
You are receiving this because you commented.Message ID: ***@***.***>
…--
Uwe Laas
Tel 05221 1718677
Laas IT Consulting
https://www.laas-it-consulting.de
|
This is fine. I just wanted to ask because it sounded like a plausible cause of the problem.
|
Today i managed to debug the whole process and it seems that the The only problem I have here is that this is not obvious at all. Since I am creating new factories, I would not expect them to share any state. |
Describe the bug
I am trying to instantiate multiple, independent schedulers with their own persistent stores. But after creating more then one, they all seem to use the same.
I am not sure what I am doing something wrong or if I have missed something in the documentation about this and would appreciate any advice.
Version used
Quartz.Net 3.7.0
To Reproduce
I parse a list of configured datapools, make sure they are unique, and then instantiate a scheduler for each of them like this:
The
GetConStr
method determines what type of database the datapool is using and calls the appropriate extension method on the PersistantStoreOptions object with the datapool's connection string (such as UseOracle/UseSqlServer).For example, Datapool A might use SQL Server and Datapool B might use Oracle.
Using only Datapool A will write to the SQL Server connection.
Using only Datapool B will write to the Oracle connection.
Using both A and B in this order will result in both writing to the Oracle connection.
Expected behavior
Using both Datapools A and B in this order will cause the first scheduler to write to SQL Server und the second one to write to Oracle.
The text was updated successfully, but these errors were encountered: