-
Notifications
You must be signed in to change notification settings - Fork 103
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
Upgrade connection to websocket and provision new connection #1594
Conversation
Signed-off-by: Aleksey Mikhaylov <[email protected]>
baa327a
to
eac58dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a good and accurate work, especially in the subtle server connection schedulers code! Besides the minor cleanups, there is only one place with tfw_sock_srv_connect_try()
instead of tfw_sock_srv_connect_try_later()
, which confuses me.
Signed-off-by: Aleksey Mikhaylov <[email protected]>
Signed-off-by: Aleksey Mikhaylov <[email protected]>
Signed-off-by: Aleksey Mikhaylov <[email protected]>
Signed-off-by: Aleksey Mikhaylov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we have severe race, which may lead to crashes on multi-core workload with concurrent websocket creations, and need to find a simpler solution leaving #710 for later phases.
if (unlikely(ci++ == srv->conn_n)) | ||
goto err; | ||
*conn++ = srv_conn; | ||
|
||
cl_copy->conns[ci-1] = srv_conn; | ||
} | ||
if (unlikely(ci != srv->conn_n)) | ||
goto err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems I was wrong with the proposal of the functions unification in both the schedulers.
Previously we called tfw_sock_srv_new_conn()
, which adds a new connection to the connection list, only from process context (since we have constant number of server connections and just failover TCP connections inside them). Moreover, tfw_peer_add_conn()
uses a spin lock to add a connection. I believe we have a mutex on concurrent configuraion reloads, so we rely on the fact that tfw_sched_ratio_add_srv()
always works in single context.
Now we can call this function concurrently with other websocket creation and with the configuration reload, so we definitely have races in all the places in the function. We can back to the separate functions and use the spin lock in the new function, but we'll also need to use the spin lock in all other functions iterating the connections list, which introduces lock contention.
What you're doing in the patch is almost solving #710 , which is a hard task on it's own to upgrade the schedulers data structures without locks.
Initially with #755 I assumed that you just "steal" sk
from TfwSrvConn
and initiate the existing connection failovering mechanism.
The code and the only one not-addressed comment were moved to #1595 . Please don't forget to remove the branch, when it's not needed |
Contributes to #755
Signed-off-by: Aleksey Mikhaylov [email protected]