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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take the accumulator in the room hooks #3417

Merged
merged 4 commits into from
Nov 25, 2021
Merged

Take the accumulator in the room hooks #3417

merged 4 commits into from
Nov 25, 2021

Conversation

NelsonVides
Copy link
Collaborator

This allows to have the accumulator in hooks like is_muc_room_owner and
can_access_room, so that if affiliations where already fetched, they
will be present in the accumulator, and we then move forwards in
preserving the consistency of a message processing pipeline: we want to
avoid the case when, during this pipeline, a subsystem fetches the
affiliations, take some action, and before the next subsystem acts, a
concurrent process modifies the affiliations: then the following
subsystem may find out that the user has been removed from the room and
reject the request, therefore getting into an inconsistent state.

This also helps preventing more duplicate, and usually idempotent, DB
queries.

This also gives more fine-grained control over other new handlers to this hook that I can implement, where information stored in the accumulator can provide more powerful decisions 馃槈

This allows to have the accumulator in hooks like is_muc_room_owner and
can_access_room, so that if affiliations where already fetched, they
will be present in the accumulator, and we then move forwards in
preserving the consistency of a message processing pipeline: we want to
avoid the case when, during this pipeline, a subsystem fetches the
affiliations, take some action, and before the next subsystem acts, a
concurrent process modifies the affiliations: then the following
subsystem may find out that the user has been removed from the room and
reject the request, therefore getting into an inconsistent state.

This also helps preventing more duplicate, and usually idempotent, DB
queries.
@codecov
Copy link

codecov bot commented Nov 24, 2021

Codecov Report

Merging #3417 (6e620d0) into master (f7e0f9d) will increase coverage by 2.72%.
The diff coverage is 70.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3417      +/-   ##
==========================================
+ Coverage   78.15%   80.87%   +2.72%     
==========================================
  Files         414      414              
  Lines       32298    32298              
==========================================
+ Hits        25241    26122     +881     
+ Misses       7057     6176     -881     
Impacted Files Coverage 螖
src/mod_muc.erl 74.77% <50.00%> (+1.00%) 猬嗭笍
src/mam/mod_mam_muc.erl 74.01% <57.14%> (酶)
src/mongoose_hooks.erl 95.10% <66.66%> (+1.08%) 猬嗭笍
src/muc_light/mod_muc_light.erl 84.96% <72.72%> (+0.43%) 猬嗭笍
src/muc_light/mod_muc_light_room.erl 93.90% <100.00%> (+0.07%) 猬嗭笍
src/smart_markers/mod_smart_markers.erl 91.89% <100.00%> (酶)
...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/mod_roster.erl 78.52% <0.00%> (-0.24%) 猬囷笍
src/mod_muc_log.erl 78.11% <0.00%> (酶)
... and 23 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 f7e0f9d...6e620d0. Read the comment docs.

@mongoose-im

This comment has been minimized.

@NelsonVides NelsonVides marked this pull request as ready for review November 24, 2021 21:03
@mongoose-im

This comment has been minimized.

@mongoose-im

This comment has been minimized.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Nov 25, 2021

small_tests_24 / small_tests / 968c20f
Reports root / small


small_tests_23 / small_tests / 968c20f
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 968c20f
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 968c20f
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 968c20f
Reports root/ big
OK: 2705 / Failed: 0 / User-skipped: 203 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 968c20f
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 968c20f
Reports root/ big
OK: 1501 / Failed: 1 / User-skipped: 382 / Auto-skipped: 0

amp_big_SUITE:basic:notify_deliver_to_online_user_recipient_privacy_test
{error,
  {{assertion_failed,assert,is_presence,
     {xmlel,<<"stream:error">>,[],
       [{xmlel,<<"conflict">>,
          [{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-streams">>}],
          []},
        {xmlel,<<"text">>,
          [{<<"xml:lang">>,<<"en">>},
           {<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-streams">>}],
          [{xmlcdata,<<"Replaced by new connection">>}]}]},
     "<stream:error><conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>Replaced by new connection</text></stream:error>"},
   [{escalus_new_assert,assert_true,2,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
       {line,84}]},
    {escalus_story,'-drop_presences/2-lc$^0/1-0-',1,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,190}]},
    {escalus_story,drop_presences,2,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,190}]},
    {escalus_story,'-start_ready_clients/2-fun-0-',3,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,135}]},
    {lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
    {escalus_story,start_ready_clients,2,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
    ...

Report log


ldap_mnesia_23 / ldap_mnesia / 968c20f
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 382 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 968c20f
Reports root/ big
OK: 1587 / Failed: 0 / User-skipped: 297 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 968c20f
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 968c20f
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 968c20f
Reports root/ big
OK: 1880 / Failed: 0 / User-skipped: 309 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 968c20f
Reports root/ big
OK: 3104 / Failed: 0 / User-skipped: 200 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 968c20f
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 968c20f
Reports root/ big
OK: 1726 / Failed: 0 / User-skipped: 310 / Auto-skipped: 0

@mongoose-im
Copy link
Collaborator

mongoose-im commented Nov 25, 2021

small_tests_24 / small_tests / 7f59f2a
Reports root / small


small_tests_23 / small_tests / 7f59f2a
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 7f59f2a
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 7f59f2a
Reports root/ big
OK: 2705 / Failed: 0 / User-skipped: 203 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 7f59f2a
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 7f59f2a
Reports root/ big
OK: 2721 / Failed: 1 / User-skipped: 186 / Auto-skipped: 0

domain_removal_SUITE:last_removal:last_removal
{error,{{assertion_failed,assert,is_last_result,
              {xmlel,<<"presence">>,
                 [{<<"from">>,
                   <<"bOb_last_removal_44.897159@domain.example.com/friendly">>},
                  {<<"to">>,
                   <<"alice_last_removal_44.897159@domain.example.com/res1">>},
                  {<<"type">>,<<"unavailable">>}],
                 []},
              "<presence from='bOb_last_removal_44.897159@domain.example.com/friendly' to='alice_last_removal_44.897159@domain.example.com/res1' type='unavailable'/>"},
    [{escalus_new_assert,assert_true,2,
               [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
                {line,84}]},
     {domain_removal_SUITE,'-last_removal/1-fun-0-',2,
                 [{file,"/home/circleci/project/big_tests/tests/domain_removal_SUITE.erl"},
                {line,376}]},
     {escalus_story,story,4,
            [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
             {line,72}]},
     {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
     {test_server,run_test_case_eval1,6,
            [{file,"test_server.erl"},{line,1292}]},
     {test_server,run_test_case_eval,9,
            [{file,"test_server.erl"},{line,1224}]}]}}

Report log


ldap_mnesia_24 / ldap_mnesia / 7f59f2a
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 382 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 7f59f2a
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 382 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 7f59f2a
Reports root/ big
OK: 1587 / Failed: 0 / User-skipped: 297 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 7f59f2a
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 7f59f2a
Reports root/ big
OK: 1880 / Failed: 0 / User-skipped: 309 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 7f59f2a
Reports root/ big
OK: 3103 / Failed: 1 / User-skipped: 200 / Auto-skipped: 0

amp_big_SUITE:offline:offline_failure:notify_deliver_to_online_user_recipient_privacy_test
{error,
  {{assertion_failed,assert,is_presence,
     {xmlel,<<"stream:error">>,[],
       [{xmlel,<<"conflict">>,
          [{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-streams">>}],
          []},
        {xmlel,<<"text">>,
          [{<<"xml:lang">>,<<"en">>},
           {<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-streams">>}],
          [{xmlcdata,<<"Replaced by new connection">>}]}]},
     "<stream:error><conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>Replaced by new connection</text></stream:error>"},
   [{escalus_new_assert,assert_true,2,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
       {line,84}]},
    {escalus_story,'-drop_presences/2-lc$^0/1-0-',1,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,190}]},
    {escalus_story,drop_presences,2,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,190}]},
    {escalus_story,'-start_ready_clients/2-fun-0-',3,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,135}]},
    {lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
    {escalus_story,start_ready_clients,2,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
    ...

Report log


pgsql_mnesia_23 / pgsql_mnesia / 7f59f2a
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 7f59f2a
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 7f59f2a
Reports root/ big
OK: 1726 / Failed: 0 / User-skipped: 310 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 7f59f2a
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 7f59f2a
Reports root/ big
OK: 3110 / Failed: 1 / User-skipped: 200 / Auto-skipped: 0

mam_SUITE:rdbms_simple_prefs_cases:messages_filtered_when_prefs_default_policy_is_roster
{error,{test_case_failed,"ASSERT EQUAL\n\tExpected []\n\tValue [ok]\n"}}

Report log

@mongoose-im
Copy link
Collaborator

mongoose-im commented Nov 25, 2021

small_tests_24 / small_tests / 1e736cc
Reports root / small


small_tests_23 / small_tests / 1e736cc
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 1e736cc
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 1e736cc
Reports root/ big
OK: 2711 / Failed: 1 / User-skipped: 203 / Auto-skipped: 0

mam_SUITE:rdbms_prefs_cases:prefs_set_cdata_request
{error,{test_case_failed,"ASSERT EQUAL\n\tExpected {prefs_result_iq,<<\"roster\">>,\n                  [<<\"montague@montague.net\">>,\n                   <<\"romeo@montague.net\">>],\n                  []}\n\tValue {prefs_result_iq,<<\"always\">>,\n                 [<<\"montague@montague.net\">>,\n                <<\"romeo@montague.net\">>],\n                 []}\n"}}

Report log


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 1e736cc
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 1e736cc
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 1e736cc
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 382 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 1e736cc
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 382 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 1e736cc
Reports root/ big
OK: 1587 / Failed: 0 / User-skipped: 297 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 1e736cc
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 1e736cc
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 1e736cc
Reports root/ big
OK: 1880 / Failed: 0 / User-skipped: 309 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 1e736cc
Reports root/ big
OK: 3104 / Failed: 0 / User-skipped: 200 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 1e736cc
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 1e736cc
Reports root/ big
OK: 1726 / Failed: 0 / User-skipped: 310 / Auto-skipped: 0

On broadcast to connected users, there's a chance to build a copy of a
potentially long list of affiliations, to potentially many connected
users, which would make broadcast for this c2s process too slow.
Risk of an inconsistency for the recipients is too small to be worth the
trouble, they might as well fetch their own affiliations.
@mongoose-im
Copy link
Collaborator

mongoose-im commented Nov 25, 2021

small_tests_24 / small_tests / 6e620d0
Reports root / small


small_tests_23 / small_tests / 6e620d0
Reports root / small


dynamic_domains_mysql_redis_24 / mysql_redis / 6e620d0
Reports root/ big
OK: 2705 / Failed: 0 / User-skipped: 203 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 6e620d0
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 6e620d0
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 6e620d0
Reports root/ big
OK: 2722 / Failed: 0 / User-skipped: 186 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 6e620d0
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 382 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 6e620d0
Reports root/ big
OK: 1502 / Failed: 0 / User-skipped: 382 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 6e620d0
Reports root/ big
OK: 1587 / Failed: 0 / User-skipped: 297 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 6e620d0
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 6e620d0
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 6e620d0
Reports root/ big
OK: 3104 / Failed: 0 / User-skipped: 200 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 6e620d0
Reports root/ big
OK: 1882 / Failed: 1 / User-skipped: 309 / Auto-skipped: 0

sm_SUITE:unacknowledged_message_hook:unacknowledged_message_hook_offline
{error,{{badmatch,false},
    [{escalus_session,stream_resumption,2,
              [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_session.erl"},
               {line,259}]},
     {escalus_connection,connection_step,2,
               [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
                {line,160}]},
     {lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
     {escalus_connection,start,2,
               [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
                {line,144}]},
     {sm_SUITE,unacknowledged_message_hook_offline,4,
           [{file,"/home/circleci/project/big_tests/tests/sm_SUITE.erl"},
          {line,826}]},
     {sm_SUITE,unacknowledged_message_hook_common,2,
           [{file,"/home/circleci/project/big_tests/tests/sm_SUITE.erl"},
          {line,878}]},
     {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
     {test_server,run_test_case_eval1,6,
            [{file,"test_server.erl"},{line,1292}]}]}}

Report log


mssql_mnesia_24 / odbc_mssql_mnesia / 6e620d0
Reports root/ big
OK: 3109 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 6e620d0
Reports root/ big
OK: 1726 / Failed: 0 / User-skipped: 310 / Auto-skipped: 0

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.

ok

@arcusfelis arcusfelis merged commit 10bc4ad into master Nov 25, 2021
@arcusfelis arcusfelis deleted the campaigns branch November 25, 2021 14:21
@Premwoik Premwoik modified the milestone: 5.1.0 May 25, 2022
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.

None yet

4 participants