-
Notifications
You must be signed in to change notification settings - Fork 3
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
Coalesce concurrent locking when writing the session token during GRPC requests #18
Comments
MatrixAI/Polykey#290 is the issue for making changes to fd-lock |
Originally the idea was that on concurrent requests, the lock on the session token would be checked, and if it is already locked, it would drop the lock. This ensures that concurrent requests don't block each other only because they are queuing up to write the session token. Because the This turned out to be a problem later in our tests when using Upstream is now potentially fixing this so that When that happens our concurrent GRPC calls will be blocking each other. And we will need to address this by changing the way our locking works.
|
Not a bug atm, removing the label. |
The transition to JSON RPC means we need to consider how to implement middleware for the streams. Right now we have client side GRPC interceptors and also utility functions on the server side handlers. We could use transform streams for the JSON streams, and use them as middleware for the RPC client and RPC server. These middleware may need to be able to cancel the subsequent handling if for example due to authentication failure. We could make this simpler with just providing utility functions to be used. |
The RPC server has to always consume the first frame (but it can yield this to the next consumer). This is because it has to know what the method is, to know which RPC handler will handle it. At this point it can also perform middleware duties and know if the call is authenticated or now. It could then return a failure frame to the peer and close the call, or provide metadata to the end consumer. |
So the only thing we need here is to change |
Moving to Polykey-CLI. |
GRPC and its middleware design isn't relevant anymore, but the general problem of coaslescing the locking is still an issue. Because it is necessary to allow concurrent operations of the PK CLI when interacting with the PK agent due to its client to server authentication. PK-CLI still currently uses This issue should be re-specced in line with the current RPC structure, and the middleware that handles the authentication. |
@tegefaulkes can you verify this (delegate this to someone too). |
I'll have a look into this. |
The parent issue of this is actually MatrixAI/Polykey#290. While the issue title talks about GRPC, I think this is still relevant to the current js-rpc. So the spec should be updated. |
Specification
Currently requests to refresh the session token will not be dropped if another process is holding a write lock on the session file. It will wait for the other process to finish and then refresh the session token as well. This is unnecessary, since we can simply drop the request if we know the other process will refresh the session token when it completes (which we know it will).
In order to do this we need to make changes to the
fd-lock
library we're currently using (likely using C++) to allow us to see which processes currently hold a lock on the session file, as well as what type of lock it is.Additional context
Tasks
fd-lock
libraryThe text was updated successfully, but these errors were encountered: