Projects tigase _server tigase-muc Issues #153
Improve handling for MAM:1 queries with old IDs (#153)
wojciech.kapcia@tigase.net opened 2 years ago

After introducing MAM:2 queries to archive with old IDs fail. We should handle them more gracefully.

[2023-03-17 17:26:05:309] [SEVERE  ] [              in_1-muc ] StanzaProcessor.processPacket()  : Error retrieving messages from database when processing from=s2s@ip-172-31-2-168.us-west-2.compute.internal, to=null, serverAuthorisedStanzaFrom=Optional.empty, DATA=<iq id="…" from="…@….…/…." xmlns="jabber:client" type="set" to="tigase@muc.tigase.org" xml:lang="en"><query xmlns="urn:xmpp:mam:2" queryid="…"><x xmlns="jabber:x:data" type="submit"><field var="FORM_TYPE" type="hidden"><value>urn:xmpp:mam:2</value></field></x><set xmlns="http://jabber.org/protocol/rsm"><after>1678726153400</after><max>50</max></set></query></iq>, SIZE=408, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=REMOTE, TYPE=set, STABLE_ID=null
java.lang.RuntimeException: Error retrieving messages from database
	at tigase.xmpp.mam.modules.QueryModule.process(QueryModule.java:86)
	at tigase.muc.modules.MAMQueryModule.process(MAMQueryModule.java:65)
	at tigase.component.modules.StanzaProcessor.execute(StanzaProcessor.java:219)
	at tigase.component.modules.StanzaProcessor.process(StanzaProcessor.java:206)
	at tigase.component.modules.StanzaProcessor.processPacket(StanzaProcessor.java:103)
	at tigase.component.AbstractKernelBasedComponent.processPacket(AbstractKernelBasedComponent.java:81)
	at tigase.muc.MUCComponent.processPacket(MUCComponent.java:122)
	at tigase.muc.cluster.MUCComponentClustered.processPacket(SourceFile:87)
	at tigase.server.AbstractMessageReceiver$QueueListener.run(AbstractMessageReceiver.java:1398)
Caused by: tigase.db.TigaseDBException: Can't find position for message with id 1678726153400 in archive for room tigase@muc.tigase.org
	at tigase.muc.history.JDBCHistoryProvider.getItemPosition(JDBCHistoryProvider.java:473)
	at tigase.muc.history.JDBCHistoryProvider.queryItems(JDBCHistoryProvider.java:279)
	at jdk.internal.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at tigase.stats.StatisticsInvocationHandler.invoke(StatisticsInvocationHandler.java:91)
	at jdk.proxy2/jdk.proxy2.$Proxy53.queryItems(Unknown Source)
	at tigase.muc.history.HistoryProviderMDBean.queryItems(HistoryProviderMDBean.java:151)
	at tigase.xmpp.mam.modules.QueryModule.process(QueryModule.java:84)
	... 8 more
Caused by: org.postgresql.util.PSQLException: ERROR: invalid input syntax for type uuid: "1678726153400"
  Where: SQL statement "select count(1) from tig_muc_room_history h where lower(h.room_jid) = lower(_roomJid) and (_since is null or h.ts >= _since) and (_to is null or h.ts <= _to) and (_nickname is null or h.sender_nickname = _nickname) and h.ts < ( select ts from tig_muc_room_history h1 where lower(h1.room_jid) = lower( _roomJid ) and h1.stable_id = uuid(_stableId) )"
PL/pgSQL function tig_muc_mam_getmessageposition(character varying,timestamp with time zone,timestamp with time zone,character varying,character varying) line 1 at RETURN QUERY
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2365)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:355)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:490)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:408)
	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:167)
	at org.postgresql.jdbc.PgCallableStatement.executeWithFlags(PgCallableStatement.java:83)
	at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:119)
	at jdk.internal.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at tigase.db.jdbc.PreparedStatementInvocationHandler.invoke(PreparedStatementInvocationHandler.java:38)
	at jdk.proxy2/jdk.proxy2.$Proxy35.executeQuery(Unknown Source)
	at tigase.muc.history.JDBCHistoryProvider.getItemPosition(JDBCHistoryProvider.java:459)
	... 16 more
Andrzej Wójcik (Tigase) commented 2 years ago

Actually, queries were made using MAM:2 but the client had only identifiers from MAM:1, so those ids were not UUIDs. I've made a workaround to handle those cases in MUC and added test cases in unit tests and in TTS-NG. Those changes may not be 100% compatible (as they change RSM results, etc.) but should work in most cases.

wojciech.kapcia@tigase.net added to iteration "tigase-server-8.4.0" 7 months ago
issue 1 of 1
Type
Bug
Priority
Normal
Assignee
Version
tigase-server-8.4.0
Iterations
Issue Votes (0)
Watchers (2)
Reference
tigase/_server/tigase-muc#153
Please wait...
Page is in error, reload to recover