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

Undelivered stanzas are processed before stream closure commands #184

Open
reksi opened this issue Jan 30, 2023 · 1 comment
Open

Undelivered stanzas are processed before stream closure commands #184

reksi opened this issue Jan 30, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@reksi
Copy link

reksi commented Jan 30, 2023

Describe the bug
There is a race condition between STREAM_CLOSED, STREAM_FINISHED command stanzas and processing undelivered stanzas.

When the connection is closed tigase.server.xmppclient.StreamManagementIOProcessor#serviceStopped method is called.

tigase.server.xmppclient.StreamManagementIOProcessor#serviceStopped calls;

  • tigase.server.xmppclient.ClientConnectionManager#serviceStopped
    -> tigase.server.xmppclient.ClientConnectionManager#xmppStreamClosed to create and send STREAM_CLOSED, STREAM_FINISHED stanzas
  • tigase.server.xmppclient.StreamManagementIOProcessor#sendErrorsForQueuedPackets
    -> tigase.server.xmppclient.ClientConnectionManager#processUndeliveredPacket to process undelivered stanzas

After creatingSTREAM_CLOSED, STREAM_FINISHED stanzas, they are started to process by calling addOutPacket however undelivered stanzas are started to process by calling processOutPacket.

Somehow, the first undelivered stanza processed before STREAM_CLOSED, STREAM_FINISHED stanzas in SessionManager. The first undelivered stanza includes delivery-error element that is processed by Message forwarder tigase.xmpp.impl.Message#preProcess and then tigase/xmpp/impl/C2SDeliveryErrorProcessor#preProcess filter stanza when it finds XMPPResourceConnection.

To Reproduce
Send bulk messages to the receiver.
The receiver disconnects before not sending the acknowledgment to all of the stanzas

Impact
Undelivered stanza processing is blocked by the Message forwarder and does not go through to offline messages. It causes the message lost.

�[1;92m[2022-12-27 08:05:24:390]�[0;36m [FINEST ]�[0m [ in_20-sess-man ]�[1;34m SessionManager.processPacket() : �[0mPacket blocked by: message, packetfrom=c2s@internal/10.10.10.10_5222_192.168.255.255_61068, to=sess-man@internal, DATA=<message from="[email protected]/5964a0422a5b938a" to="[email protected]" xmlns="jabber:client" type="chat" id="gPHAlLqtwVnAoAKaFJm2o6PxbAjjbj"><group id="HY0FD" xmlns="http://kontalk.org/extensions/message#group"><nick xmlns="http://jabber.org/protocol/nick">Nick-d6ce</nick><body>Message 13</body><active xmlns="http://jabber.org/protocol/chatstates"/></group><delay xmlns="urn:xmpp:delay" stamp="2022-12-27T08:05:22.599Z" from="mydomain.com"/><delivery-error stamp="1672128322599" xmlns="http://tigase.org/delivery-error"/></message>, SIZE=623, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=chat

Expected behavior
We have to ensure STREAM_CLOSED, STREAM_FINISHED stanzas are processed before the undelivered stanza.

Screenshots
NA

Details (please complete the following information):

  • Tigase version: 8.1.0
  • JVM flavour and version : openjdk 11.0.7 2020-04-14
  • Operating system/distribution/version : Ubuntu 18.04.1 LTS
  • INTEL(R) XEON(R) PLATINUM 8259CL CPU @ 2.50GHZ
  • GNU/Linux - 1 CPU - 2 virtual CPU - 4.06G RAM

Additional context
tigase.log

@reksi reksi added the bug Something isn't working label Jan 30, 2023
@woj-tek
Copy link
Contributor

woj-tek commented Jan 30, 2023

Thank you for detailed description and analysis. We will investigate it further.

(ref: #server-1343)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants