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

Duplicate messages matrix-side (due to distributed IRCds) #27

Open
matrixbot opened this issue Apr 29, 2016 · 21 comments
Open

Duplicate messages matrix-side (due to distributed IRCds) #27

matrixbot opened this issue Apr 29, 2016 · 21 comments
Labels
needs-investigation p1 T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems.

Comments

@matrixbot
Copy link
Member

Created by @ matthew:matrix.org.

e.g. roblabla on https://vector.im/beta/#/room/!cURbafjkfsMDVwdRDQ:matrix.org/$146192559593207XoTMY:matrix.org and half-shot a few days earlier

@kegsay
Copy link
Member

kegsay commented Jun 2, 2016

The permalink says the commit sha: c3f8dbf6b5b5f33bebae09c2e92866e140e4601b

@kegsay
Copy link
Member

kegsay commented Jun 2, 2016

Probably related: https://matrix.org/jira/browse/BOTS-142

@kegsay kegsay self-assigned this Jul 14, 2016
@kegsay
Copy link
Member

kegsay commented Jul 22, 2016

This SHA is for Synapse, not the IRC bridge and is therefore useless.

@kegsay
Copy link
Member

kegsay commented Jul 22, 2016

Tried to repro this on v0.3.1 and I cannot. Used the demo federation with user IDs:

@fewd:localhost:8481
@fewd:localhost:8482

I surmise the title of this bug is wrong, or that particular issue has already been fixed. BOTS-142 still seems valid though, so clobbering this issue with that.

@kegsay kegsay changed the title IRC bridge starts looping from IRC->Matrix if user speaks with same user ID from different servers Duplicate messages matrix-side Jul 22, 2016
@kegsay
Copy link
Member

kegsay commented Jul 22, 2016

This is the important bit:

2015-11-16 17:28:39 INFO:irc-client <M-intelfx@irc.freenode.net#bion5hs2eo848> (@intelfx:matrix.org) Connecting to IRC server irc.freenode.net as M-intelfx (user=intelfxmat)
2015-11-16 17:28:41 DEBUG:client-pool Connected with nick 'M-intelfx1' instead of desired nick 'M-intelfx'
2015-11-22 03:43:38 ERROR:client-connection M-intelfx@irc.freenode.net: {"command":"ERROR","rawCommand":"ERROR","commandType":"normal","args":["Closing Link: gateway/shell/matrix.org/x-ufiwesbeopqhxsaf (Ping timeout: 244 seconds)"]}
2015-11-22 03:43:38 INFO:client-connection disconnect()ing M-intelfx@irc.freenode.net - raw_error
2015-11-22 03:43:38 DEBUG:client-pool onClientDisconnected: <bion5hs2eo848> Reconnecting M-intelfx1@irc.freenode.net in 10000ms
2015-11-22 03:43:48 INFO:irc-client <M-intelfx@irc.freenode.net#kakx3kvehj44c> (@intelfx:matrix.org) Connecting to IRC server irc.freenode.net as M-intelfx (user=intelfxmat)
2015-11-22 03:45:46 ERROR:client-connection M-intelfx@irc.freenode.net still not connected after 30000ms. Killing connection.
2015-11-22 03:45:46 INFO:client-connection disconnect()ing M-intelfx@irc.freenode.net - timeout
2015-11-22 03:46:24 DEBUG:irc-client <M-intelfx@irc.freenode.net#kakx3kvehj44c> (@intelfx:matrix.org) connected!
2015-11-22 03:46:24 DEBUG:irc-client <M-intelfx@irc.freenode.net#kakx3kvehj44c> (@intelfx:matrix.org) _keepAlive; Restarting 432000s idle timeout
2015-11-22 03:46:24 INFO:client-pool <kakx3kvehj44c> Reconnected M-intelfx@irc.freenode.net
2015-11-22 03:55:27 INFO:irc-client <M-intelfx@irc.freenode.net#kakx3kvehj44c> (@intelfx:matrix.org) NICK: Nick changed from 'M-intelfx' to '20WACI3YG'.

Netsplit and the single nick => Client mapping is wrong.

@kegsay kegsay changed the title Duplicate messages matrix-side Duplicate messages matrix-side (due to netsplits) Jul 22, 2016
@kegsay
Copy link
Member

kegsay commented Jul 22, 2016

This relates heavily to #72 - We might as well do that rather than faff with Nick => [Client] mappings (instead it'll be Username => Client which the bridge can ensure are unique 😄 )

@kegsay
Copy link
Member

kegsay commented Jul 22, 2016

Punting this to the next release as #72 is effectively a blocker and I don't feel like doing that right now.

@kegsay kegsay removed their assignment Jul 22, 2016
@kegsay
Copy link
Member

kegsay commented Apr 13, 2017

This reared its ugly head again today, though the cause isn't a netsplit. If you connect with the same nick to 2 freenode servers at the same time, the IRCds don't handshake first before accepting the connection, so there's a brief period where both servers accept the connection for the same nick. This then gets corrected less than a second later, but by this point it's too late because it has clobbered the entry in the ClientPool. The entire sequence is:

// connect to one server, which accepts the proposed nick
clientPool["Alice"] = clientAlice
// connect at the same time to a different server, which also accepts the same nick. This clobbers `clientAlice` irreparably. 
clientPool["Alice"] = clientAlice2
// bridge gets rename
clientPool["425FE25"] = clientPool["Alice"]
clientPool["Alice"] = null;

But we keep another map of user_id -> client as well, so M->I is not affected by this. This means messages to IRC go out correctly, but means we don't recognise the nick when it comes back to us, so we send it on to Matrix again.

@kegsay kegsay changed the title Duplicate messages matrix-side (due to netsplits) Duplicate messages matrix-side (due to distributed IRCds) Apr 13, 2017
@kegsay
Copy link
Member

kegsay commented Apr 13, 2017

Changed title because this is not netsplit specific anymore.

@copumpkin
Copy link

@kegsay I'm seeing some duplicate messages on Matrix's IRC bridge to freenode in the ##nix-darwin channel. Not sure if that's a different cause or related to this one. I think the whole thing started with a netsplit a couple of weeks ago and hasn't fixed itself since.

@simoniz0r
Copy link

I just managed to do this yesterday by using NickServ from freenode to IDENTIFY and then REGAIN my nick.

@Perflyst
Copy link

Seems like I currently have this bug in any room which is bridged to Freenode.
Screenshot_20190728_131632

@Half-Shot
Copy link
Contributor

For reference, we are tracking this bug at the moment. The likely short term fix next week will be a bridge restart coupled with some related bug fixes. I suspect the very least we can do is some kind of debugAPI to refresh broken rooms.

In the shorter term, you are free to ban *[m] users from your rooms as it won't interrupt the bridge.

@Mikaela
Copy link
Contributor

Mikaela commented Jul 29, 2019

In the shorter term, you are free to ban *[m] users from your rooms as it won't interrupt the bridge.

I think this comment is easy to interpret as mode +b *[m]!*@* which bans all Matrix users using the default nick from the channels. I guess you meant that Matrix-side moderators should op their IRC ghosts and then ban the *[m] users on Matrix-side.

@Half-Shot
Copy link
Contributor

In the shorter term, you are free to ban *[m] users from your rooms as it won't interrupt the bridge.

I think this comment is easy to interpret as mode +b *[m]!*@* which bans all Matrix users using the default nick from the channels. I guess you meant that Matrix-side moderators should op their IRC ghosts and then ban the *[m] users on Matrix-side.

Yes, I should be clear here. Please do NOT ban the matrix users from the IRC side -- that will break things. Ban @freenode_.*[m]:matrix.org users if they start echoing as it won't affect the bridge.

Although hopefully for the time being this is a moot point, as hopefully the restart just now fixed stuff.

@Mikaela
Copy link
Contributor

Mikaela commented Jul 10, 2021

I have reproduced this on Ergo IRCd which doesn't even support server linking.

  1. join #libcasa:liberta.casa
  2. say something to get invited to bridge admin room
  3. !storepass Mikaela-@libertacasamatrix:password
  4. say something
  5. see how everything I say is duplicated.
Reconnecting to network...
Connecting to the IRC network 'irc.liberta.casa' as mikaela{m}...
Your connection to the IRC network 'irc.liberta.casa' has been lost. 
SASL authentication successful: You are now logged in as Mikaela-
You've been connected to the IRC network 'irc.liberta.casa' as mikaela{m}.
<me> !nick Mikaela-
The nickname Mikaela- is taken on irc.liberta.casa. Please pick a different nick.
  • BridgeVersion: 0.27.0

On Matrix I am @mikaela:liberta.casa and my ghost who gets repeated is @irc_Mikaela-:liberta.casa. On IRC only messages from Mikaela- are visible.

I think this is matrix-appservice-irc not handling the integrated bouncer of Ergo which is enforcing my nickname into being my accountname (Mikaela-).

See also: https://github.com/ergochat/ergo/blob/v2.7.0/docs/USERGUIDE.md#how-ergo-is-different

In case you try to reproduce this on liberta.casa, #371 or something similar is hitting it and you cannot contact @lunatic:liberta.casa unless you are on the same homeserver.

Network IRCv3 capabilities in case they are of any help: account-notify account-tag away-notify batch cap-notify chghost draft/channel-rename draft/chathistory draft/event-playback draft/languages=1,en draft/multiline=max-bytes=4096,max-lines=100 draft/register=before-connect draft/relaymsg=/ echo-message extended-join invite-notify labeled-response message-tags multi-prefix oragono.io/nope sasl=PLAIN,EXTERNAL server-time setname userhost-in-names znc.in/playback znc.in/self-message

@Mikaela
Copy link
Contributor

Mikaela commented Jul 10, 2021

I don't know whether this is a new issue or #502 (comment), but additionally when I join the 13 missing rooms by hand, in the end I am in 14 rooms as one has duplicated and I cannot see anything sent from IRC while IRC can read me in some cases.

Possibly yet another issue is that some of the rooms have +i or +k where I am allowed to join right in due to having CS AMODE +h and being already in so not needing to enter key, but the matrixbot (lunatic) doesn't and thus cannot.

@Mikaela
Copy link
Contributor

Mikaela commented Jul 12, 2021

Update on reproducing on Ergo (#27 (comment)): I can !reconnect as much as I want and consistently reproduce this issue on every attempt.

Reconnecting to network...
Connecting to the IRC network 'irc.liberta.casa' as mikaela{m}...
Your connection to the IRC network 'irc.liberta.casa' has been lost. 
SASL authentication successful: You are now logged in as Mikaela-
You've been connected to the IRC network 'irc.liberta.casa' as mikaela{m}.

Maybe Ergo is a good IRCd to test against for fixing this bug in general if others don't allow reproducing this consistently?

@Mikaela

This comment has been minimized.

@slingamn
Copy link

The diagnosis on matrix-org/node-irc#74 looks correct to me. The issue is this: in general, an IRC server can assign a client a nickname that differs from the one the client requested with NICK. The client is expected to deduce this from the first parameter of the 001 RPL_WELCOME numeric.

To simplify reproducing the issue, I created an account on testnet.ergo.chat, account name nickchangetest, password _UqRdsxHQmbxWbUwq11APQ. Here's a sample transcript:

C: CAP REQ sasl
S: :testnet.ergo.chat CAP * ACK sasl
C: AUTHENTICATE PLAIN
S: AUTHENTICATE +
C: AUTHENTICATE bmlja2NoYW5nZXRlc3QAbmlja2NoYW5nZXRlc3QAX1VxUmRzeEhRbWJ4V2JVd3ExMUFQUQ==
S: :testnet.ergo.chat 900 * * nickchangetest :You are now logged in as nickchangetest
S: :testnet.ergo.chat 903 * :Authentication successful
C: NICK nickchangetest_
C: USER u s e r
C: CAP END
S: :testnet.ergo.chat 001 nickchangetest :Welcome to the ErgoTestnet IRC Network nickchangetest
S: :testnet.ergo.chat 002 nickchangetest :Your host is testnet.ergo.chat, running version ergo-2.7.0
S: :testnet.ergo.chat 003 nickchangetest :This server was created Tue, 08 Jun 2021 05:08:05 UTC

@Mikaela
Copy link
Contributor

Mikaela commented Jul 29, 2021

This issue is fixed in 0.29.0-rc2, thank you.

It does introduce a new issue I am opening soon.

@justinbot justinbot added T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems. and removed bug labels May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-investigation p1 T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems.
Projects
None yet
Development

No branches or pull requests

9 participants