Skip to content
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

GUACAMOLE-1846: Synchronize new users to connections in batches to fix join race condition. #455

Conversation

jmuehlner
Copy link
Contributor

This change turned out to be pretty involved, but at their core, these changes are addressing the race condition described in GUACAMOLE-1846.

This change addresses this problem by batching up all newly connected users and synchronizing connection state to them using a newly defined join_pending_handler, at which time they'll be promoted to full users, and the broadcast socket will write to them.

This synchronization is done using a new broadcast socket that writes to all synchronized users at once, instead of once at a time.

Pending users are synchronized once every quarter second, which should result in little noticeable delay upon joining a connection.

Thanks to @mike-jumper for helping to work through the logic here and help figure out various bugs along the way.

@neandrake
Copy link
Contributor

Oh cool, this issue/fix sounds like it might be related to what I was seeing in #316 (comment)

src/terminal/terminal/terminal.h Outdated Show resolved Hide resolved
src/terminal/terminal/terminal.h Outdated Show resolved Hide resolved
src/terminal/terminal/terminal.h Outdated Show resolved Hide resolved
src/common/common/cursor.h Outdated Show resolved Hide resolved
src/libguac/local-lock.c Outdated Show resolved Hide resolved
src/libguac/guacamole/client.h Outdated Show resolved Hide resolved
src/libguac/guacamole/client.h Outdated Show resolved Hide resolved
src/libguac/guacamole/client.h Outdated Show resolved Hide resolved
src/libguac/guacamole/client-fntypes.h Outdated Show resolved Hide resolved
src/libguac/guacamole/client-fntypes.h Outdated Show resolved Hide resolved
@jmuehlner jmuehlner force-pushed the GUACAMOLE-1846-fix-user-join-race-condition-clean branch 8 times, most recently from d999f53 to 1f0dc9e Compare August 23, 2023 23:14
@jmuehlner jmuehlner marked this pull request as draft August 24, 2023 00:33
@jmuehlner
Copy link
Contributor Author

Marking as draft while I investigate an issue.

@jmuehlner jmuehlner force-pushed the GUACAMOLE-1846-fix-user-join-race-condition-clean branch 2 times, most recently from b7736e2 to eaca340 Compare August 25, 2023 23:34
@jmuehlner jmuehlner marked this pull request as ready for review August 25, 2023 23:43
@jmuehlner
Copy link
Contributor Author

jmuehlner commented Aug 25, 2023

Ok, I think this should be ready to go again. I'm still seeing the client occasionally get locked up when shutting down and fail to shut down cleanly, but at least it's guaranteed to always shut down with the new shutdown handling introduced in eaca340.

src/common/list.c Outdated Show resolved Hide resolved
src/libguac/local-lock.c Outdated Show resolved Hide resolved
@jmuehlner jmuehlner force-pushed the GUACAMOLE-1846-fix-user-join-race-condition-clean branch 2 times, most recently from 57837c0 to 83b789d Compare August 28, 2023 22:45
@jmuehlner
Copy link
Contributor Author

This was an issue with lock acquisition/release order and has been fixed.

I'm still seeing the client occasionally get locked up when shutting down and fail to shut down cleanly

src/guacd/proc-map.c Outdated Show resolved Hide resolved
src/guacd/proc.c Outdated Show resolved Hide resolved
src/common/list.c Outdated Show resolved Hide resolved
src/guacd/daemon.c Outdated Show resolved Hide resolved
src/guacd/daemon.c Outdated Show resolved Hide resolved
src/libguac/guacamole/client.h Show resolved Hide resolved
src/protocols/kubernetes/argv.h Show resolved Hide resolved
src/terminal/terminal/scrollbar.h Outdated Show resolved Hide resolved
src/terminal/terminal/display.h Outdated Show resolved Hide resolved
src/libguac/client.c Outdated Show resolved Hide resolved
@jmuehlner jmuehlner force-pushed the GUACAMOLE-1846-fix-user-join-race-condition-clean branch 5 times, most recently from f782fcc to ad180be Compare August 29, 2023 00:07
@mike-jumper
Copy link
Contributor

@jmuehlner, as a bug fix should this be against staging/1.5.4?

@jmuehlner
Copy link
Contributor Author

jmuehlner commented Aug 29, 2023

@jmuehlner, as a bug fix should this be against staging/1.5.4?

Uh, yeah, I suppose so. Let me retarget it. It's done

@jmuehlner jmuehlner force-pushed the GUACAMOLE-1846-fix-user-join-race-condition-clean branch from ad180be to eedac89 Compare August 29, 2023 16:53
@jmuehlner jmuehlner changed the base branch from master to staging/1.5.4 August 29, 2023 16:53
@jmuehlner jmuehlner marked this pull request as draft August 29, 2023 16:54
@jmuehlner jmuehlner force-pushed the GUACAMOLE-1846-fix-user-join-race-condition-clean branch from eedac89 to 826cb78 Compare August 29, 2023 16:59
@jmuehlner jmuehlner marked this pull request as ready for review August 29, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants