Skip to content

Clustering-related fixes. #140

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

Merged

Conversation

guusdk
Copy link
Member

@guusdk guusdk commented Dec 3, 2020

No description provided.

guusdk and others added 15 commits December 1, 2020 17:33
Stopped using deprecated API of PluginManager.
Applied various IDE suggestions.
As the senior node is responsible for processing cluster events related, that node needs to have all available data to operate on. By making available the original stanza, this stanza can be persisted in the database. This in turn prevents an inpresice reproduction from being used when the corresponding message archive is used at some point later in the future.
…chivedMessage (almost) immutable

No functional changes intended.
Reduce code complexity by removing code that is not used.
…ceManager

PersistenceManager had a lot of definition that wasn't used. It either had no implementation, or the little implementation that was there, went unreferenced. This commit removes it all, reducing code complexity by a significant factor.

It appears to me that all removed code was replaced by code in the implementation of ConversationManager - although I'm not 100% sure.
Removing code that is not referenced / used anywhere. This reduces complexity, and improves maintainability.
Removing code that is not referenced / used anywhere. This reduces complexity, and improves maintainability.
This adds documentation that helps define how ArchivedMessage is to be used.
When a previously archived message is being retrieved, the optional 'stanza' database value is eventually parsed as XMPP.

This commit brings forward this process (to a place immediately after the data is obtained from the database), replacing the existing mechanism that did it just before the message was being routed to the intended recipient.

The benefit of this is that the code that it is more fail-fast, and operations that follow the database retrieval can work with a proper stanza, instead of having to work with its String representation. This brings type-safety. Lastly, there's less ambiguity around where parsing occurs (and at what point the parsing can be expected to have been completed).
…rection'

The concept of 'direction' of an ArchivedMessage is, to some, counter-intuitive. The mechanism that determines the direction of a particular stanza should be centralized to reduce confusion.
When in 2015 the XEP-0313 implementation was added to the code, this API of ConversationManager got expanded to take in the complete 'stanza' element. The ConversationEvent did not have that, which is why an empty string was used instead. Later (in 2016), the stanza was made available in ConversationEvent, but that empty string never got replaced. This commit fixes that.
When processing an archived message in MAM context, using the 'with' attribute (that would otherwise go unused) to reflect the nickname of the sender of the message allows us to avoid unneeded stanza parsing.
…tanza IDs

Code duplication (and thus complexity) is reduced by centralizing where an appropriate stanza ID is obtained.
@Fishbowler
Copy link
Member

So far:

Todo:

…cluster

It is important to assign a message ID, which is used for ordering messages in a conversation, soon
after the message arrived, as opposed to just before the message gets written to the database. In the latter
scenario, the message ID values might no longer reflect the order of the messages in a conversation, as
database writes are batched up together for performance reasons. Using these batches won't affect the
database-insertion order (as compared to the order of messages in the conversation) on a single Openfire
server, but when running in a cluster, these batches do have a good chance to mess up the order of things.
These are the new properties and their defaults:

conversation.archiver.conversation.max-work-queue-size default: 500
conversation.archiver.conversation.max-purge-interval default: 1000 (one second)
conversation.archiver.conversation.grace-period default: 50
conversation.archiver.message.max-work-queue-size default: 500
conversation.archiver.message.max-purge-interval default: 1000 (one second)
conversation.archiver.message.grace-period default: 50
conversation.archiver.participant.max-work-queue-size default: 500
conversation.archiver.participant.max-purge-interval default: 1000 (one second)
conversation.archiver.participant.grace-period default: 50
@guusdk guusdk mentioned this pull request Dec 4, 2020
@Fishbowler
Copy link
Member

MAM and RSM tests completed to the same standard as the 2.0.0 release in January (I really must automate these, or at least publish them as examples).

LGTM, but will await @guusdk to check this last change over before merging.

@@ -290,7 +290,7 @@ static Long getMessageIdForStableId( final MUCRoom room, final String value )
connection = DbConnectionManager.getConnection();
pstmt = connection.prepareStatement( "SELECT messageId, stanza FROM ofMucConversationLog WHERE messageId IS NOT NULL AND roomID=? AND stanza LIKE ? AND stanza LIKE ?" );
pstmt.setLong( 1, room.getID() );
pstmt.setString( 2, "%"+value+"%" );
pstmt.setString( 2, "%id=\""+value+"\"%" );
Copy link
Member Author

Choose a reason for hiding this comment

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

This will fail consistently when ' is used instead of ":

<bar id="foo" />

versus

<bar id='foo' />

Copy link
Member

Choose a reason for hiding this comment

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

Think I've fixed it, but it's untested.

Copy link
Member Author

Choose a reason for hiding this comment

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

We're well into territory of database optimization here, which I'm not very experienced with, but: my concern is that for most rows (that are not going to match), this would duplicate the text-based search effort. Is that something that we should be concerned of?

Copy link
Member

Choose a reason for hiding this comment

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

After chatting to @guusdk, changed this to be more defensive in false positives rather than more precise (+expensive) with the database.

@Fishbowler Fishbowler force-pushed the 137_muc-messages-as-oneonone-rebased branch from 11057c4 to a2f6bb0 Compare December 7, 2020 15:06
…lt ID

The implementation looks for a stanza-id and falls back to a database ID. The XEP-0313 says a client shouldn't rely on the stanza-id as the UID of a message in the archive, but OF is trending towards making that reliable. In the meantime, the result ID is still the database ID.

Without this change, searches for the database ID is searched as freetext within the stanza. As a short number in amongst many GUIDs, false positives are more likely than not. This change adds to the defense against false positives and ensures that a search for a stanza-id is more thoroughly checked to be the one we were looking for.
@Fishbowler Fishbowler force-pushed the 137_muc-messages-as-oneonone-rebased branch from a2f6bb0 to 5822cda Compare December 8, 2020 13:45
@guusdk guusdk merged commit 5c13f63 into igniterealtime:master Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants