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

Inbox filter bug that puts unnecessary load on the auth backend #3449

Merged
merged 6 commits into from
Dec 14, 2021

Conversation

NelsonVides
Copy link
Collaborator

This fixes a bug when inbox puts a muclight room into mongoose_hooks:does_user_exist, which makes no sense and puts unnecessary load on the auth backend. I believe this was already an issue since the beginning of inbox, but only now Beekeeper reported it.

The part about the inbox owner existence is actually a condition of
inbox taking the message or not, so that could be moved into a single
filtering function. Also simplify specs by reusing types.
This needs to verify the type of the request at the moment where we need
to decide if the inbox owner exists. We can't return false because that
would drop the required markers from resetting the count. We can't
return `can_access_room` because then the message telling the user that
he has been removed from a room would arrive to the user at a time when
he's not a member of the room anymore. So we simply must return true
from here.
@codecov
Copy link

codecov bot commented Dec 13, 2021

Codecov Report

Merging #3449 (61d90d0) into master (394ec28) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3449      +/-   ##
==========================================
- Coverage   80.85%   80.82%   -0.04%     
==========================================
  Files         415      415              
  Lines       32312    32317       +5     
==========================================
- Hits        26125    26119       -6     
- Misses       6187     6198      +11     
Impacted Files Coverage Δ
src/inbox/mod_inbox.erl 88.44% <100.00%> (+0.35%) ⬆️
src/mam/mod_mam_utils.erl 86.49% <100.00%> (-0.05%) ⬇️
src/mod_roster_mnesia.erl 72.72% <0.00%> (-21.22%) ⬇️
src/cassandra/mongoose_cassandra.erl 77.77% <0.00%> (-3.71%) ⬇️
src/cassandra/mongoose_cassandra_worker.erl 65.72% <0.00%> (-2.82%) ⬇️
...bal_distrib/mod_global_distrib_hosts_refresher.erl 75.47% <0.00%> (-1.89%) ⬇️
src/logger/mongoose_log_filter.erl 78.08% <0.00%> (-1.37%) ⬇️
src/rdbms/mongoose_rdbms.erl 61.75% <0.00%> (-1.20%) ⬇️
src/mod_roster_rdbms.erl 95.38% <0.00%> (-0.77%) ⬇️
src/mod_muc_room.erl 76.97% <0.00%> (-0.29%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 394ec28...61d90d0. Read the comment docs.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Dec 13, 2021

small_tests_24 / small_tests / ed78685
Reports root / small


small_tests_23 / small_tests / ed78685
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / ed78685
Reports root/ big
OK: 2727 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / ed78685
Reports root/ big
OK: 2727 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / ed78685
Reports root/ big
OK: 2710 / Failed: 0 / User-skipped: 203 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / ed78685
Reports root/ big
OK: 2727 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / ed78685
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 386 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / ed78685
Reports root/ big
OK: 1509 / Failed: 1 / User-skipped: 386 / Auto-skipped: 0

sm_SUITE:parallel_manual_ack_freq_1:resume_session_state_send_message
{error,
  {{assertion_failed,assert_many,true,
     [#Fun<sm_SUITE.22.40422599>,#Fun<sm_SUITE.22.40422599>,
      #Fun<sm_SUITE.22.40422599>],
     [{xmlel,<<"presence">>,
        [{<<"from">>,
        <<"alicE_resume_session_state_send_message_1196@localhost/escalus-default-resource">>},
         {<<"to">>,
        <<"alice_resume_session_state_send_message_1196@localhost/escalus-default-resource">>},
         {<<"xml:lang">>,<<"en">>}],
        []},
      {xmlel,<<"message">>,
        [{<<"from">>,
        <<"bOb_resume_session_state_send_message_1189@localhost/escalus-default-resource">>},
         {<<"to">>,
        <<"alicE_resume_session_state_send_message_1196@localhost">>},
         {<<"xml:lang">>,<<"en">>},
         {<<"type">>,<<"chat">>}],
        [{xmlel,<<"body">>,[],[{xmlcdata,<<"msg-1">>}]},
         {xmlel,<<"delay">>,
           [{<<"xmlns">>,<<"urn:xmpp:delay">>},
          {<<"stamp">>,<<"2021-12-13T10:46:33.286028Z">>},
          {<<"from">>,<<"localhost">>}],
           [{xmlcdata,<<"SM Storage">>}]}]},
      {xmlel,<<"message">>,
        [{<<"from">>,
        <<"bOb_resume_session_state_send_message_1189@localhost/escalus-default-resource">>},
         {<<"to">>,
        <<"alicE_resume_session_state_send_message_1196@localhost">>},
         {<<"xml:lang">>,<<"en">>},
         {<<"type">>,<<"chat">>}],
        [{xmlel,<<"body">>,[],[{xmlcdata,<<"msg-2">>}]},
         {xmlel,<<"delay">>,
           [{<<"xmlns">>,<<"urn:xmpp:delay">>},
          {<<"stamp...

Report log


internal_mnesia_24 / internal_mnesia / ed78685
Reports root/ big
OK: 1587 / Failed: 0 / User-skipped: 301 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / ed78685
Reports root/ big
OK: 3114 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / ed78685
Reports root/ big
OK: 1880 / Failed: 0 / User-skipped: 313 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / ed78685
Reports root/ big
OK: 3114 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / ed78685
Reports root/ big
OK: 3114 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / ed78685
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 200 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / ed78685
Reports root/ big
OK: 1726 / Failed: 0 / User-skipped: 314 / Auto-skipped: 0

@@ -1031,6 +966,20 @@ groupchat_markers_all_reset_room_created(Config) ->
inbox_helper:foreach_check_inbox([Bob, Kate, Alice], 0, AliceRoomJid, Msg)
end).

inbox_does_not_trigger_does_user_exist(Config) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

what with the case, when some jid is in the room, but this jid does not exist?

Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

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

looks good

@mongoose-im
Copy link
Collaborator

mongoose-im commented Dec 14, 2021

small_tests_24 / small_tests / 61d90d0
Reports root / small


small_tests_23 / small_tests / 61d90d0
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 61d90d0
Reports root/ big
OK: 2727 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 61d90d0
Reports root/ big
OK: 2710 / Failed: 0 / User-skipped: 203 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 61d90d0
Reports root/ big
OK: 2727 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 61d90d0
Reports root/ big
OK: 2727 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 61d90d0
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 386 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 61d90d0
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 386 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 61d90d0
Reports root/ big
OK: 3114 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 61d90d0
Reports root/ big
OK: 1587 / Failed: 0 / User-skipped: 301 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 61d90d0
Reports root/ big
OK: 3114 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 61d90d0
Reports root/ big
OK: 3114 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 61d90d0
Reports root/ big
OK: 1880 / Failed: 0 / User-skipped: 313 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 61d90d0
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 200 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 61d90d0
Reports root/ big
OK: 1726 / Failed: 0 / User-skipped: 314 / Auto-skipped: 0

@arcusfelis arcusfelis merged commit 725d139 into master Dec 14, 2021
@arcusfelis arcusfelis deleted the inbox_mam_filter branch December 14, 2021 15:01
@Premwoik Premwoik added this to the 5.1.0 milestone May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants