-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
DuplicatedContext can cause unexpected behavior #3790
Comments
Can you explain why? This sounds like a bug to me. Am I missing something @vietj ? |
@tsegismont This is what vietj said to me on the matter
|
it is fine for duplicate context to have its own task queue because this is what most user will expect when they do schedule messages from an HTTP request. |
but indeed I'm seing that might be an issue for ppl to reason about things. |
the intent of this change is that if you use execute blocking from a scope that is a request or a message received then each is ordered according to the current activity. if that's used like in the example (which seems unlikely in practice) then it does not give the expected results because of the context duplicate. perhaps there should be a third mode that allows to have ordering for this:
|
The following code will run a bunch of blocking tasks all with
ordered=true
This is the output:
Given that
ordered=true
, the output is odd, as conventional wisdom (and the documentation) would say that for anyTask n start
the message that should always follow it isTask n done
. Of course ordering is only the case when the calls take place within the same context, and they all are called from the same context. Right?I know that's not the case, but for any person that hasn't read the implementation, they should reasonably expect that everything that I wrote above is all run from the same context. That's the core of this issue, certain handlers are called with a
DuplicatedContext
and it causes unusual behavior because it creates a view of the parent context with the blockingTaskQueue
being independant of the parent. Also, these side effects are completely undocumented.I understand why
DuplicatedContext
exists, and I also know why we made theDuplicatedContext
use its ownTaskQueue
, but I don't think the differentTaskQueue
was a good idea. It will cause issues for developers that will not be discovered immediately and in its current form make implementing the scheduler for RxJava imposible (For reasons why see: vert-x3/vertx-rx#245 (comment)) Personally I think it should be removed, and jdbc-client should revert back to the old solution (it appears to be the only thing that should useTaskQueue
, but it doesn't look like it was properly implemented, see: vert-x3/vertx-jdbc-client#203 (comment)). Even though that is what I think, I don't think that is something that is going to happen, so I have a simpler solution. Do not create a seperateTaskQueue
unless explicitly specified. This way theDuplicatedContext
behaves exactly like its parent for all actions (though of course thelocalData
map is not preserved between the two)I'm already busy on a PR to make a couple of changes around
DuplicatedContext
The text was updated successfully, but these errors were encountered: