OF-3176: Fix stanza loss during outgoing S2S session teardown#3232
Open
guusdk wants to merge 1 commit intoigniterealtime:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses OF-3176 by preventing stanza loss when an outgoing S2S session is closing: instead of immediately bouncing/dropping on a closed connection while route removal is still in-flight, it waits for teardown completion and then re-routes the stanza (with a configurable timeout).
Changes:
- Add a new dynamic system property (
xmpp.server.session.redelivery-timeout, default 30s) to bound how long to wait for outgoing-session teardown completion before abandoning re-delivery. - Update outgoing S2S stanza delivery logic to await
Connection#getCloseFuture()completion before re-routing stanzas that hit a closed connection, while avoiding “double-bounce” for error stanzas. - Add i18n strings (EN + NL) for the new system property description.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalOutgoingServerSession.java | Adds the redelivery-timeout property and re-delivery logic that waits for teardown completion before re-routing. |
| i18n/src/main/resources/openfire_i18n.properties | Adds English description for the new system property. |
| i18n/src/main/resources/openfire_i18n_nl.properties | Adds Dutch description for the new system property. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalOutgoingServerSession.java
Outdated
Show resolved
Hide resolved
xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalOutgoingServerSession.java
Show resolved
Hide resolved
xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalOutgoingServerSession.java
Show resolved
Hide resolved
xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalOutgoingServerSession.java
Show resolved
Hide resolved
When an outgoing server-to-server (S2S) connection closes, the connection is marked closed immediately, but route removal from the routing table happens asynchronously during teardown. This creates a short race window where routing can still send stanzas to a closing session, which then sees a closed connection and drops the stanza. This change fixes that behavior by waiting for teardown to fully complete before re-routing a stanza that reached a closed outgoing session. Waiting for close completion ensures stale route cleanup has finished, after which normal routing can use an existing replacement session or create a new one. A new system property, xmpp.server.session.redelivery-timeout (default: 30 seconds), controls how long Openfire waits for teardown completion before returning an error to the sender.
17ff22b to
ad77029
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an outgoing server-to-server (S2S) connection closes, the connection is marked closed immediately, but route removal from the routing table happens asynchronously during teardown. This creates a short race window where routing can still send stanzas to a closing session, which then sees a closed connection and drops the stanza.
This change fixes that behavior by waiting for teardown to fully complete before re-routing a stanza that reached a closed outgoing session. Waiting for close completion ensures stale route cleanup has finished, after which normal routing can use an existing replacement session or create a new one.
A new system property, xmpp.server.session.redelivery-timeout (default: 30 seconds), controls how long Openfire waits for teardown completion before returning an error to the sender.