-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Concurrency issues with Postgre and IContentManager #14773
Comments
The repro steps should be good enough to repro the issue and understand what is happening. |
Hi, My bad, I'll try to be more precise and clear. I need to have a background task that listens to a rabbit mq server and processes incoming messages, making bdd interactions. In accordance with the documentation, I've implemented ModularTenantEvents to start listening to rabbitMQ when the tenant is activated (I use EasyNetQ to listen). Each time I receive a message, I create a ShellScope, then dispatch the message with MediatR. A handler receives it and performs various operations. I receive about 15 messages per second. This diagram illustrates my current implementation: It's working with Sqlite. But with Postgre. I have some concurrency exceptions. (A command is already in progress). The exception comes from this line : in the "TriggerEventAsync" method of the All my DB calls with contentManager are awaited. First of all, I'm wondering if I'm doing this correctly. Is this the best way to start a background service that dispatches rabbitMQ messages using Orchard ? Anyway, Here are the reproduce steps :
I'm not using the last version of Orchard, and my issue is similar to #7449 |
@Jad-EL I didn't mean that it was not, literally it was already self-explanatory but thank you for detailing it even more. |
can you share the stack trace for when you get Note that a DefaultContentManager instance can't be shared, and each |
@Jad-EL can you reply here, please? |
It seems that this issue didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please reply. |
Closing this issue because it didn't receive further feedback from the author for very long. If you think this is still relevant, feel free to reopen it with the requested details. |
Describe the bug
Hello, I'm currently facing some issues with the content manager. OrchardCore 1.5
I'm supposed to listen to RabbitMQ messages, and to do something according to the type of the message.
I created a ModularTenantEvent who starts the listener when the tenant get activated, in the "ActivatedAsync" and I just dispatch the message with MediatR to a CommandHandler, as you can see :
In my command handlers, I use to create / update some contents in DB with IContentManager. that I inject.
Everything is working well with SQLite, But I tried to switch on PostGre and now it just doesn't work,
I have that kind of exception : A command is already in progress: insert into "Document" ("Id", "Type", "Content", "Version") values (@Id_1, @Type_1, @Content_1, @Version_1);insert into "Document" ("Id", "Type", "Content", "Version")
Firstly, I thought the problem was probably the scopes. So I decided to create an overlay to Session, making it Transient, and did the same with IContentManager.
The result is an ITransientContentManager (kind of proxy or decorator) that I can inject into my services, to ensure that connections are properly isolated.
But now there is still an exception, on WorkflowManager.I tried to analyze and realized that the problem came from the ContentHandler, which is triggered after each ContentManager update/publish.
The ContentHandler does a "TriggerEventAsync", and it throws a concurrency exception on this line
var haltedWorkflows = await _workflowStore.ListByActivityNameAsync(name, correlationId, isAlwaysCorrelated);
It seems that the problem is on the "ProduceAsync" of the YesSQL Store, but I'm not sure..
I'm also wondering if my way to create the shellscope and to handle my message is right.
I can give you more information if needed.
Thanks in advance !
To Reproduce
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: