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

Raise an error if mnesia:create_table/2 fails #4138

Merged
merged 2 commits into from
Oct 9, 2023

Conversation

arcusfelis
Copy link
Contributor

This PR addresses "Easier debugging if Mnesia is not configured, but some modules are configured with mnesia backend (or started dynamically in tests).

Proposed changes include:

  • Add mongoose_mnesia module.
  • It has mongoose_mnesia:create_table/2 function, which checks that mnesia table is created correctly.

Without it starts would "work", but we would get an error in case we wanna read/write into a table (which many modules ignore without writing to logs).

@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Oct 4, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (9bbbbe2) 84.07% compared to head (40e3f51) 84.05%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4138      +/-   ##
==========================================
- Coverage   84.07%   84.05%   -0.02%     
==========================================
  Files         559      560       +1     
  Lines       34038    34015      -23     
==========================================
- Hits        28617    28592      -25     
- Misses       5421     5423       +2     
Files Coverage Δ
src/auth/ejabberd_auth_anonymous.erl 68.33% <100.00%> (-0.52%) ⬇️
src/auth/ejabberd_auth_internal.erl 89.47% <100.00%> (-0.19%) ⬇️
src/component/mongoose_component_mnesia.erl 91.30% <100.00%> (-0.37%) ⬇️
src/ejabberd_sm_mnesia.erl 95.65% <100.00%> (-0.19%) ⬇️
src/event_pusher/mod_event_pusher_push_mnesia.erl 90.32% <100.00%> (-0.31%) ⬇️
src/jingle_sip/mod_jingle_sip_mnesia.erl 76.47% <100.00%> (ø)
src/mam/mod_mam_mnesia_prefs.erl 92.75% <100.00%> (-0.11%) ⬇️
src/mod_bosh_mnesia.erl 100.00% <100.00%> (ø)
src/mod_caps.erl 79.72% <100.00%> (-0.10%) ⬇️
src/mod_keystore_mnesia.erl 84.61% <100.00%> (-1.10%) ⬇️
... and 19 more

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mongoose-im

This comment was marked as outdated.

@arcusfelis arcusfelis marked this pull request as ready for review October 4, 2023 16:09
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.

It looks good, I like the common code being extracted to a separate module.
A few minor comments from me.

src/rebar.lock Outdated Show resolved Hide resolved
@@ -81,7 +81,6 @@
%% ------------------------ Backend start/stop ------------------------

init(HostType, Opts) ->
mod_pubsub_db_mnesia:init(HostType, Opts),
Copy link
Member

Choose a reason for hiding this comment

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

Why is it safe to delete this?
Any idea why was the mnesia backend even started here?

Note that mod_pubsub_db_mnesia:stop/2 is still called in line 254.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It passed tests, so haven't investigated too deep. Not sure why it is there in the first place :)
Maybe there is some shared logic used by both backends. I thought there was at some point.
Could check again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At least that call would do nothing, if someone tries to use mod_pubsub without mnesia configured (i.e. all errors are just ignored inside).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is safe for start. I think, it was used when someone was adding rdbms backend, but was not cleaned up after rdbms backend was finished.

Copy link
Member

Choose a reason for hiding this comment

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

I would take a look inside to ensure that the RDBMS backend is not reusing any logic of the mnesia one...

@arcusfelis arcusfelis force-pushed the mongoose-mnesia-helper branch 2 times, most recently from 875bc33 to d952abe Compare October 6, 2023 10:53
@mongoose-im

This comment was marked as outdated.

It has mongoose_mnesia:create_table/2 function, which checks that mnesia table is
created correctly.
Remove mod_pubsub_db_mnesia:stop from mod_pubsub_db_rdbms
@mongoose-im
Copy link
Collaborator

mongoose-im commented Oct 6, 2023

elasticsearch_and_cassandra_26 / elasticsearch_and_cassandra_mnesia / 40e3f51
Reports root/ big
OK: 369 / Failed: 0 / User-skipped: 38 / Auto-skipped: 0


small_tests_25 / small_tests / 40e3f51
Reports root / small


small_tests_26_arm64 / small_tests / 40e3f51
Reports root / small


small_tests_26 / small_tests / 40e3f51
Reports root / small


ldap_mnesia_25 / ldap_mnesia / 40e3f51
Reports root/ big
OK: 2302 / Failed: 1 / User-skipped: 865 / Auto-skipped: 0

dynamic_domains_SUITE:with_mod_dynamic_domains_test:packet_handling_for_subdomain
{error,
  {{badrpc,
     {'EXIT',
       {timeout,
         [{meck_proc,wait,6,
            [{file,
               "/home/circleci/project/_build/default/lib/meck/src/meck_proc.erl"},
             {line,171}]},
          {meck,wait,5,[]}]}}},
   [{distributed_helper,rpc,
      [#{node => mongooseim@localhost},
       meck,wait,
       [3,mod_dynamic_domains_test,process_packet,5,500]],
      [{file,
         "/home/circleci/project/big_tests/tests/distributed_helper.erl"},
       {line,140}]},
    {dynamic_domains_SUITE,'-packet_handling_for_subdomain/1-fun-3-',1,
      [{file,
         "/home/circleci/project/big_tests/tests/dynamic_domains_SUITE.erl"},
       {line,113}]},
    {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


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 40e3f51
Reports root/ big
OK: 4268 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


ldap_mnesia_26 / ldap_mnesia / 40e3f51
Reports root/ big
OK: 2303 / Failed: 0 / User-skipped: 865 / Auto-skipped: 0


dynamic_domains_mysql_redis_26 / mysql_redis / 40e3f51
Reports root/ big
OK: 4236 / Failed: 0 / User-skipped: 144 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / 40e3f51
Reports root/ big
OK: 4265 / Failed: 0 / User-skipped: 115 / Auto-skipped: 0


internal_mnesia_26 / internal_mnesia / 40e3f51
Reports root/ big
OK: 2453 / Failed: 0 / User-skipped: 715 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 40e3f51
Reports root/ big
OK: 4657 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


pgsql_cets_26 / pgsql_cets / 40e3f51
Reports root/ big
OK: 4655 / Failed: 0 / User-skipped: 121 / Auto-skipped: 0


mysql_redis_26 / mysql_redis / 40e3f51
Reports root/ big
OK: 4637 / Failed: 0 / User-skipped: 139 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 40e3f51
Reports root/ big
OK: 4268 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 40e3f51
Reports root/ big
OK: 4657 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


mssql_mnesia_26 / odbc_mssql_mnesia / 40e3f51
Reports root/ big
OK: 4654 / Failed: 0 / User-skipped: 122 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / 40e3f51
Reports root/ big
OK: 2303 / Failed: 0 / User-skipped: 865 / Auto-skipped: 0

@chrzaszcz chrzaszcz merged commit 507fcd5 into master Oct 9, 2023
4 checks passed
@chrzaszcz chrzaszcz deleted the mongoose-mnesia-helper branch October 9, 2023 05:48
@chrzaszcz chrzaszcz added this to the 6.2.0 milestone Dec 11, 2023
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

3 participants