-
Notifications
You must be signed in to change notification settings - Fork 100
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
[Enhancement] Async tasks should work 100% #89
Conversation
By "interfere", I'm not perfectly sure what you mean, IMO, subtasks should share the same context as the one where it is spawned, is there other reason to duplicate the Also, I didn't succeed to make up a FAILED test case that "a single entry point executing multiple async exit requests simultaneously" (as you mentioned in #88), can you provide a snippet of code so that I can compliment the tests by adding a negative test case. Other changes look good enough to me, thanks |
They do share the same context but the
With LocalSpan1 as parent to LocalSpan2, even though LocalSpan1 and LocalSpan2 should both have EntrySpan as the parent. Or worse, with ExitSpan the second would overwrite the first if I understand the code correctly and you would wind up with only one ExitSpan where two outgoing requests were made. With this change each new async task gets its own isolated copy of a
for the first sibling task and:
for the second, with correct parents for everyone.
That kind of thing should no longer fail with this PR (which is the whole point of it) but should fail with #88 and below. If you were not successful in getting a fail case for #88 then that is different and I will look into it tomorrow so do let me know if you are referring to this PR with respect to not being able to make a fail case or #88. |
The explanation of "interfere" totally makes sense to me.
That is what I meant, this kind of cases may be hard to reproduce stably but it would be nice if we can add a test case to possibly cover it as our best effort, so I need your help to reproduce it under #88, feel free to do it when you got some time. I'm merging this for now. Thanks again |
Compare #88 with this PR. P.S. If you have a moment could you have a look at my question #5875 on the main skywalking issues board? I will be moving on to the NodeJS agent so would be nice to be able to test it as I work :) |
Thanks.
I will check it soon |
Out of curiosity, what purpose do Context.capture() and Context.continue() functions serve? Is it to preserve state across possibly asynchronous operation? If so then with this PR they may no longer be necessary. |
Let me give an example. Yes, those things designed for across threads, originally from Java agent core. Each language agent has its own choice whether it needs to adopt all modules in the java agent implementation. |
Yes
Seems like that's the case, feel free to open a pull request |
I will return to this after the NodeJS agent stuff. |
This PR is made of two tightly coupled parts: * Total rewrite of agent startup logic from module functions -> singleton class. (some other logic was changed in meter to fix wrong forking behavior) * Provide experimental support for os.fork(), exposed as an option. * A demo directory to provide easier access to oap/kafka/demoservices (for contributors). Minor changes: * Docs: fixed some missed ones over time. * Fixed a redis bug.
These changes should address all remaining async-related problems not handled in #88. The
spans
list has been moved from an instance variable inSpanContext
to a global task-local variable which allows "forking" it for new subtasks so that multiple concurrent async subtasks don't interfere with one another.spans
is now a top-level module var because Python stipulates thatContextVar
should be such and only one context exists at any given time so it is essentially a singleton anyway.