wojciech.kapcia@tigase.net opened 2 years ago
|
|||||||
I think this is possible only if the stanza was queued for delivery in On the other hand, a call to While I think we could move scheduling redelivery to be called after the connection is closed (and However, currently, scheduling of unacked packets (from StreamManagement queue), is now done after the connection is closed and after packets from waiting queue are resent. As messages in I think that the best way would be to reimplement this part (redelivery) to take packets from I'm not sure if we can cleanly solve this issue without API changes and a rather large reimplementation. Maybe just minor changes would work, but the order of stored messages might be incorrect. I also have mixed feeling about relying on offline storage in a multiclient environment and would suggest the usage of MAM for message syncing and dropping the usage of offline storage). @wojtek What do you think? How should we proceed? |
|||||||
I think it's OK to make API changes considering that those would be only addition (and possible removals would be deprecated first). How much time do you estimate for the proposed single queue implementation?
I think this isn't necessarily multi-client approach. Judging form the payload it's most likely kontalk with it's very non-standard groupchat (i.e. doesn't use MUC but each client broadcast the same message to all participants, hence possible "bulk messages" and most likely higher CPU usage / slower queue processing). Yes, MAM may be a solution, but in the case of "very secure" deployments they most likely don't use MAM and operate on volatile messages. |
|||||||
That is a difficult question. While I would prefer not to extend "waiting queue" as it is used frequently and may contain a lot of items (also for S2S and due to that may increase memory usage), this may be necessary to have a correct timestamp of messages in offline storage. But.. we can try to "move" redelivery to the correct place and hope it will work fine without further changes. In the worst-case scenario, we would be forced to reimplement queuing mechanism. What do you think? In Tigase 9.0, we should (as we discussed) unify MAM storage with offline storage. Then we may not need to redelivery those messages to offline storage, as they would be already there if not acked by the client (or not fully sent), so I would prefer not to spend too much time on this.
Is storing messages in MAM a lot different from storing messages in offline storage? Basically, the only change is that after delivering the message, it "should" be removed. On the other hand, it forces single-client usage to ensure that your client has a full history of messages. I think that MAM with short "expiration" would work almost the same. |
|||||||
@wojtek I've applied discussed changes and they are for now stored in a separate branch. I've also added a test case to TTS-NG to verify this fix. Please review it when you will have some time and then we will merge it and release it. |
|||||||
I checked the changes (and created PR: https://github.com/tigase/tigase-server/pull/188#pullrequestreview-1304619926) - it looks good IMHO.
Agreed.
This is reasonable. And in case of "pure offline store" messages can be removed from MAM upon offline client connecting (just like it happens right now). But yes, having MAM by default for everything would simplify a lot of back-and-forth and redelivery. (feel free to create task for 9.0 to address the change) |
|||||||
wojciech.kapcia@tigase.net batch edited 6 months ago
|
|||||||
wojciech.kapcia@tigase.net changed state to 'Closed' 6 months ago
|
Type |
Bug
|
Priority |
Normal
|
Assignee | |
Version |
tigase-server-8.4.0
|
-
tigase-server-8.4.0 Closed
(from https://github.com/tigase/tigase-server/issues/184)
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 sendSTREAM_CLOSED
,STREAM_FINISHED
stanzastigase.server.xmppclient.StreamManagementIOProcessor#sendErrorsForQueuedPackets
->tigase.server.xmppclient.ClientConnectionManager#processUndeliveredPacket
to process undelivered stanzasAfter creating
STREAM_CLOSED
,STREAM_FINISHED
stanzas, they are started to process by callingaddOutPacket
however undelivered stanzas are started to process by callingprocessOutPacket
.Somehow, the first undelivered stanza processed before
STREAM_CLOSED
,STREAM_FINISHED
stanzas in SessionManager. The first undelivered stanza includesdelivery-error
element that is processed by Message forwardertigase.xmpp.impl.Message#preProcess
and thentigase/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
<a>
acknowledgment to all of the stanzasImpact Undelivered stanza processing is blocked by the Message forwarder and does not go through to offline messages. It causes the message lost.
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):
Additional context tigase.log