-
Notifications
You must be signed in to change notification settings - Fork 5
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
Updating the Nodes
domain with timedCancellable
#475
Conversation
👇 Click on the image for a new way to code review
Legend |
There is something funky happening with the context timer. I have a situation where we have a public method that is using the So what is happening is, when the first method
However when it is passed into
So I'm guessing the timer is getting cancelled for some reason? |
Be aware that the decorators are kind of "smart". There are some rules as how it sets up the ctx. If you're getting values that you don't expect, then just do a sanity check that these 2 ctxes are in fact the same ctx when you are propagating. Also see my context tests, they show how you're supposed to be propagating the ctx. |
I see the problem. The solution here is to make |
Yes, |
In that case, the higher order functions are still an issue? Since the timer it passes along can and will be cancelled early? |
I'm not sure what you mean by that. If you use async function, whether a normal function declaration or arrow function. The interpreter forces the usage of The
|
Ok early cancellation occurs due to the idea of "ownership". If the Then it will shut that down once the result is returned. Only when the I follow the principle of: "Whatever creates it, must destroy it". Unless you have an explicit "ownership passing" operation. |
Ok so if you have a higher order function that returns a lower function. And the higher order function is timed cancellable. Then yes this is what will happen. But it doesn't make sense to apply |
In that case, you may not be able to use the decorator, you have to use the HOF variant. That's why I created both |
All the nodes tests are passing again. I need to take a look and ping node again. It doesn't seem to be respecting the timeout. |
tomorrow I need to:
|
Maybe long running tasks need their own parameter. Right now I have them using the |
The When calling SO it seems that the |
The We fixed this by having the decorators copy the contexts before making changes and passing them along. This prevents the mutation and maintains the branching signal chains. We had to apply this fix to all 3 decorators. Changes can be seen in commit |
As far as the tests go. I don't think we need to add any more. The only timeouts were really updated here. The two main tests for this, ping timing out and connections timing out already exist and were updated. Anything weird that could happen that would need more testing would come from either network or GRPC at this point. I did add 1 test for if the |
The `timedCancellable` methods in `NodeManager` and `NodeConnectionManager` should take the default timeouts dynamically from the constructed parameters.
`acquireConnection` returns an arrow function for getting the connection. As a result, the timer it created is cancelled immediately. This resulted in the connection timing out early.
This was causing a peculiar bug where if a `ctx` was passed to function calls twice in a method it could cause the signal abortion chain to be broken. In essence in stead of branching the chain out with multiple call paths. The mutation flattened the tree into a chain, when one branch completed the decorator clean up broke the abortion chain.
…imeout This can still be overwritten but by default to total timeout depends on the sub methods.
a987a62
to
69c0ffe
Compare
This should be good to merge. |
[nix-shell:~/matrixCode/polykey/js-polykey]$ npm run polykey -- nodes add --node-path ./tmp/A vr7bll6lhbd0d7pajgi1db
gb35sasfu0j0ag65hr6fjquod9rc9vg 127.0.0.1 42439
> [email protected] polykey
> ts-node src/bin/polykey.ts "nodes" "add" "--node-path" "./tmp/A" "vr7bll6lhbd0d7pajgi1dbgb35sasfu0j0ag65hr6fjquod9
rc9vg" "127.0.0.1" "42439"
✔ Please enter the password … ********
[nix-shell:~/matrixCode/polykey/js-polykey]$ npm run polykey -- nodes ping --node-path ./tmp/A vr7bll6lhbd0d7pajgi1d
bgb35sasfu0j0ag65hr6fjquod9rc9vg
> [email protected] polykey
> ts-node src/bin/polykey.ts "nodes" "ping" "--node-path" "./tmp/A" "vr7bll6lhbd0d7pajgi1dbgb35sasfu0j0ag65hr6fjquod
9rc9vg"
Node is Active. After the node has shutdown [nix-shell:~/matrixCode/polykey/js-polykey]$ npm run polykey -- nodes ping --node-path ./tmp/A vr7bll6lhbd0d7pajgi1d
bgb35sasfu0j0ag65hr6fjquod9rc9vg
> [email protected] polykey
> ts-node src/bin/polykey.ts "nodes" "ping" "--node-path" "./tmp/A" "vr7bll6lhbd0d7pajgi1dbgb35sasfu0j0ag65hr6fjquod
9rc9vg"
No response received
ErrorCLINodePingFailed: Node was not online or not found. - No response received
exitCode 1
timestamp Fri Oct 07 2022 19:50:51 GMT+1100 (Australian Eastern Daylight Time) A node it doesn't know [nix-shell:~/matrixCode/polykey/js-polykey]$ npm run polykey -- nodes ping --node-path ./tmp/A vr7bll6lhbd0d7pajgi1d
bgb35sasfu0j0ag65hr6fjquod2rc9vg
> [email protected] polykey
> ts-node src/bin/polykey.ts "nodes" "ping" "--node-path" "./tmp/A" "vr7bll6lhbd0d7pajgi1dbgb35sasfu0j0ag65hr6fjquod
2rc9vg"
Failed to resolve node ID vr7bll6lhbd0d7pajgi1dbgb35sasfu0j0ag65hr6fjquod2rc9vg to an address.
ErrorCLINodePingFailed: Node was not online or not found. - Failed to resolve node ID vr7bll6lhbd0d7pajgi1dbgb35sasf
u0j0ag65hr6fjquod2rc9vg to an address.
exitCode 1
timestamp Fri Oct 07 2022 19:48:58 GMT+1100 (Australian Eastern Daylight Time)
cause: ErrorPolykeyRemote: Remote error from RPC call
command nodesPing
nodeId vrrtjta93vhe7dputjb3441t6k2hg9504gb0tpjcjl3bh9d1bdqtg
host 127.0.0.1
port 39957
timestamp Fri Oct 07 2022 19:48:58 GMT+1100 (Australian Eastern Daylight Time)
cause: ErrorNodeGraphNodeIdNotFound: Could not find NodeId
exitCode 67
timestamp Fri Oct 07 2022 19:48:58 GMT+1100 (Australian Eastern Daylight Time)
In terms of usage, I don't think it should be printing the error when it fails to ping. By design it exits with the error code of 1, but that is an expected failure. |
I'm merging this now. Next step, looking into the NAT test failures. |
Description
This PR addresses the
timedCancellable
changes for the nodes domain. Part of this work was done in #445. This is just to fully finish off the domain.Issues Fixed
Nodes
domain to usedtimedCancellable
#465Tasks
5. If possible use the transaction locking for the object maps. Object map locks should be removed in favour of transaction locks #443This was already usingLockBox
. So it has already been addressed.Final checklist