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

Don't crash on oidentd socket race condition #4695

Merged

Conversation

maxpoulin64
Copy link
Member

My instance just crashed on this out of nowhere. It seems like this is a condition that can happen when two or more sockets gets disconnected at the same time. Each one triggers socket close, and for each of those we remove the socket from oidentd which in turn refreshes the oidentd config file. Once we're in there refreshing the database, we trip on the other closed sockets we haven't cleaned up yet, which in turn crashes the whole server.

I have a handful of users on my instance, with at least one server in common so one server restarting would cause a handful of closed sockets on the same tick which would trigger this race condition. At last this is the only plausible explanation I can think of for this happening.

Switched it to just log and skip it instead of an exception.

/dist/server/identification.js:89
    throw new Error("Socket has no remote or local port");
                ^
Error: Socket has no remote or local port
    at /dist/server/identification.js:89:23
    at Map.forEach (<anonymous>)
    at Identification.refresh (/dist/server/identification.js:87:26)
    at Identification.removeSocket (/dist/server/identification.js:82:18)
    at IrcClient.<anonymous> (/dist/server/plugins/irc-events/connection.js:101:41)
    at IrcClient.emit (/node_modules/eventemitter3/index.js:181:35)
    at Connection.<anonymous> (/node_modules/irc-framework/src/client.js:99:29)
    at Connection.emit (/node_modules/eventemitter3/index.js:202:33)
    at Connection.socketClose (/node_modules/irc-framework/src/connection.js:111:18)
    at Connection.emit (node:events:390:28)

Copy link
Contributor

@igalic igalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

server/identification.ts Outdated Show resolved Hide resolved
server/identification.ts Outdated Show resolved Hide resolved
server/identification.ts Outdated Show resolved Hide resolved
MaxLeiter and others added 2 commits February 13, 2023 20:50
Co-authored-by: Mina Galić <me+github@igalic.co>
@MaxLeiter MaxLeiter added this to the Next milestone Feb 14, 2023
server/identification.ts Outdated Show resolved Hide resolved
@xPaw xPaw added the Type: Bug Issues that report and PRs that solve any defects that cause unexpected behaviors. label Feb 18, 2023
@brunnre8 brunnre8 added the Status: changes-requested Review happened but some changes need to be made label Feb 18, 2023
@MaxLeiter MaxLeiter removed the Status: changes-requested Review happened but some changes need to be made label Feb 25, 2023
@MaxLeiter MaxLeiter merged commit 7c9ed14 into thelounge:master Feb 25, 2023
@maxpoulin64 maxpoulin64 deleted the fix/oidentd-crash-race-condition branch April 25, 2024 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issues that report and PRs that solve any defects that cause unexpected behaviors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants