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

Remove domain/incremental db deletes #3777

Merged
merged 5 commits into from
Sep 28, 2022

Conversation

NelsonVides
Copy link
Collaborator

The current query, looking like:

DELETE FROM mam_message WHERE user_id IN (SELECT id from mam_server_user WHERE server = ?)

is, while technically correct, surely going to fail because of timeouts, once it is actually removing any big data.

This PR introduces a configuration flag that allows to set a batch size, and then a delete work will commit only deleting that many records, and iterates until nothing more is deleted.

@NelsonVides NelsonVides force-pushed the remove_domain/incremental_db_deletes branch from 6673d7e to 4f88463 Compare September 27, 2022 23:21
@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Base: 82.81% // Head: 82.81% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (23618cb) compared to base (f875416).
Patch coverage: 76.08% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3777      +/-   ##
==========================================
- Coverage   82.81%   82.81%   -0.01%     
==========================================
  Files         531      531              
  Lines       34109    34138      +29     
==========================================
+ Hits        28246    28270      +24     
- Misses       5863     5868       +5     
Impacted Files Coverage Δ
src/mam/mod_mam_rdbms_arch.erl 45.94% <26.66%> (-2.60%) ⬇️
src/mam/mod_mam.erl 97.40% <100.00%> (ø)
src/mam/mod_mam_muc_rdbms_arch.erl 95.65% <100.00%> (+0.45%) ⬆️
src/mam/mod_mam_utils.erl 90.03% <100.00%> (+0.31%) ⬆️
...bal_distrib/mod_global_distrib_hosts_refresher.erl 66.66% <0.00%> (-2.23%) ⬇️
src/muc_light/mod_muc_light_db_mnesia.erl 91.57% <0.00%> (-1.06%) ⬇️
src/mod_muc_room.erl 78.51% <0.00%> (-0.18%) ⬇️
src/mod_muc_log.erl 62.82% <0.00%> (ø)
src/ejabberd_sm.erl 87.21% <0.00%> (+0.32%) ⬆️
src/pubsub/mod_pubsub_db_mnesia.erl 92.82% <0.00%> (+0.42%) ⬆️
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Base automatically changed from remove_domain/catch_hook_errors to master September 28, 2022 06:10
MySQL does not allow the update (in this case a delete) to refer to the
table being selected, but it allows this double nesting.
@mongoose-im
Copy link
Collaborator

mongoose-im commented Sep 28, 2022

small_tests_24 / small_tests / 23618cb
Reports root / small


small_tests_25 / small_tests / 23618cb
Reports root / small


ldap_mnesia_24 / ldap_mnesia / 23618cb
Reports root/ big
OK: 1992 / Failed: 0 / User-skipped: 745 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 23618cb
Reports root/ big
OK: 3829 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 23618cb
Reports root/ big
OK: 3829 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / 23618cb
Reports root/ big
OK: 1992 / Failed: 0 / User-skipped: 745 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / 23618cb
Reports root/ big
OK: 3803 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / 23618cb
Reports root/ big
OK: 3828 / Failed: 1 / User-skipped: 88 / Auto-skipped: 0

muc_SUITE:hibernation:hibernated_room_can_be_queried_for_archive
{error,{{assertion_failed,assert,is_groupchat_message,
              [<<"Restorable message">>],
              undefined,"undefined"},
    [{escalus_new_assert,assert_true,2,
               [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
                {line,84}]},
     {muc_SUITE,wait_for_mam_result,3,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4394}]},
     {muc_SUITE,'-hibernated_room_can_be_queried_for_archive/1-fun-0-',3,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4130}]},
     {escalus_story,story,4,
            [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
             {line,72}]},
     {muc_SUITE,hibernated_room_can_be_queried_for_archive,1,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4126}]},
     {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
     {test_server,run_test_case_eval1,6,
            [{file,"test_server.erl"},{line,1291}]},
     {test_server,run_test_case_eval,9,
            [{file,"test_server.erl"},{line,1223}]}]}}

Report log


pgsql_mnesia_24 / pgsql_mnesia / 23618cb
Reports root/ big
OK: 4203 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / 23618cb
Reports root/ big
OK: 2113 / Failed: 0 / User-skipped: 624 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / 23618cb
Reports root/ big
OK: 2453 / Failed: 0 / User-skipped: 619 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 23618cb
Reports root/ big
OK: 4214 / Failed: 1 / User-skipped: 97 / Auto-skipped: 0

pep_SUITE:pep_tests:unsubscribe_after_presence_unsubscription
{error,
  {{badmatch,
     [{xmlel,<<"message">>,
        [{<<"from">>,
        <<"alice_unsubscribe_after_presence_unsubscription_2498@localhost">>},
         {<<"to">>,
        <<"bob_unsubscribe_after_presence_unsubscription_2498@localhost/res1">>},
         {<<"type">>,<<"headline">>}],
        [{xmlel,<<"event">>,
           [{<<"xmlns">>,
           <<"http://jabber.org/protocol/pubsub#event">>}],
           [{xmlel,<<"items">>,
            [{<<"node">>,<<"YLlMPmBB6+LTVPvYK+E8kQ==">>}],
            [{xmlel,<<"item">>,
               [{<<"id">>,<<"salmon">>}],
               [{xmlel,<<"entry">>,
                  [{<<"xmlns">>,
                  <<"http://www.w3.org/2005/Atom">>}],
                  []}]}]}]},
         {xmlel,<<"headers">>,
           [{<<"xmlns">>,<<"http://jabber.org/protocol/shim">>}],
           []}]}]},
   [{pep_SUITE,'-unsubscribe_after_presence_unsubscription/1-fun-0-',2,
      [{file,"/home/circleci/project/big_tests/tests/pep_SUITE.erl"},
       {line,384}]},
    {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,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log


mysql_redis_25 / mysql_redis / 23618cb
Reports root/ big
OK: 4189 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / 23618cb
Reports root/ big
OK: 4202 / Failed: 1 / User-skipped: 97 / Auto-skipped: 0

smart_markers_SUITE:regular:one2one:marker_for_thread_can_be_fetched
{error,
  {{fetch_marker,ok,
     [{times,50,
        {error,
          {badmatch,[]},
          [{smart_markers_SUITE,'-verify_marker_fetch/4-fun-6-',3,
             [{file,
              "/home/circleci/project/big_tests/tests/smart_markers_SUITE.erl"},
            {line,405}]},
           {mongoose_helper,do_wait_until,2,
             [{file,
              "/home/circleci/project/big_tests/tests/mongoose_helper.erl"},
            {line,374}]},
           {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,1782}]},
           {test_server,run_test_case_eval1,6,
             [{file,"test_server.erl"},{line,1291}]},
           {test_server,run_test_case_eval,9,
             [{file,"test_server.erl"},{line,1223}]}]}}]},
   [{mongoose_helper,do_wait_until,2,
      [{file,"/home/circleci/project/big_tests/tests/mongoose_helper.erl"},
       {line,371}]},
    {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,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log


riak_mnesia_24 / riak_mnesia / 23618cb
Reports root/ big
OK: 2292 / Failed: 0 / User-skipped: 612 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / 23618cb
Reports root/ big
OK: 3829 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / 23618cb
Reports root/ big
OK: 4202 / Failed: 1 / User-skipped: 97 / Auto-skipped: 0

inbox_extensions_SUITE:async_pools:one_to_one:mute_muted_conv_restarts_timestamp
{error,{{badrpc,timeout},
    [{escalus_rpc,call_with_cookie_match,
            [mongooseim@localhost,ejabberd_admin,register,
             [<<"alicE_mute_muted_conv_restarts_timestamp_1423">>,
            <<"localhost">>,<<"matygrysa">>],
             3000,ejabberd],
            [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_rpc.erl"},
             {line,34}]},
     {lists,foreach_1,2,[{file,"lists.erl"},{line,1442}]},
     {escalus_ejabberd,create_users,2,
               [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_ejabberd.erl"},
              {line,211}]},
     {escalus_fresh,create_users,2,
            [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_fresh.erl"},
             {line,62}]},
     {escalus_fresh,story,3,
            [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_fresh.erl"},
             {line,27}]},
     {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
     {test_server,run_test_case_eval1,6,
            [{file,"test_server.erl"},{line,1291}]},
     {test_server,run_test_case_eval,9,
            [{file,"test_server.erl"},{line,1223}]}]}}

Report log


mssql_mnesia_25 / odbc_mssql_mnesia / 23618cb
Reports root/ big
OK: 4203 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0

@NelsonVides NelsonVides marked this pull request as ready for review September 28, 2022 10:01
Copy link
Member

@chrzaszcz chrzaszcz 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 👍

@chrzaszcz chrzaszcz merged commit 975bb21 into master Sep 28, 2022
@chrzaszcz chrzaszcz deleted the remove_domain/incremental_db_deletes branch September 28, 2022 12:52
@chrzaszcz chrzaszcz added this to the 6.0.0 milestone Dec 12, 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.

3 participants