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

Return error IQ when SQL query execution fails #4308

Merged
merged 2 commits into from
Jun 24, 2024

Conversation

jacekwegr
Copy link
Collaborator

@jacekwegr jacekwegr commented Jun 20, 2024

This PR changes the server response when a prepared SQL query fails to run. Now, it will respond with a 500 error instead of an empty result set.

The try ... catch ... block around the entire lookup function simplifies the logic for returning errors. This ensures that any error during the function's execution is caught and handled properly in one place.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Jun 20, 2024

elasticsearch_and_cassandra_26 / elasticsearch_and_cassandra_mnesia / 462890f
Reports root/ big
OK: 439 / Failed: 0 / User-skipped: 47 / Auto-skipped: 0


small_tests_25 / small_tests / 462890f
Reports root / small


small_tests_26 / small_tests / 462890f
Reports root / small


small_tests_26_arm64 / small_tests / 462890f
Reports root / small


ldap_mnesia_25 / ldap_mnesia / 462890f
Reports root/ big
OK: 2289 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


ldap_mnesia_26 / ldap_mnesia / 462890f
Reports root/ big
OK: 2289 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 462890f
Reports root/ big
OK: 4573 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


dynamic_domains_mysql_redis_26 / mysql_redis / 462890f
Reports root/ big
OK: 4540 / Failed: 0 / User-skipped: 144 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / 462890f
Reports root/ big
OK: 4570 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 462890f
Reports root/ big
OK: 4573 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


internal_mnesia_26 / internal_mnesia / 462890f
Reports root/ big
OK: 2429 / Failed: 0 / User-skipped: 765 / Auto-skipped: 0


pgsql_cets_26 / pgsql_cets / 462890f
Reports root/ big
OK: 4484 / Failed: 0 / User-skipped: 178 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 462890f
Reports root/ big
OK: 4964 / Failed: 0 / User-skipped: 118 / Auto-skipped: 0


mysql_redis_26 / mysql_redis / 462890f
Reports root/ big
OK: 4943 / Failed: 0 / User-skipped: 139 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 462890f
Reports root/ big
OK: 4963 / Failed: 1 / User-skipped: 118 / Auto-skipped: 0

carboncopy_SUITE:one2one:dropped_client_doesnt_create_duplicate_carbons
{error,
  {{badmatch,
     [{xmlel,<<"message">>,
        [{<<"from">>,
        <<"alice_dropped_client_doesnt_create_duplicate_carbons_605@localhost">>},
         {<<"to">>,
        <<"alice_dropped_client_doesnt_create_duplicate_carbons_605@localhost/res2">>},
         {<<"xmlns">>,<<"jabber:client">>},
         {<<"type">>,<<"chat">>}],
        [{xmlel,<<"sent">>,
           [{<<"xmlns">>,<<"urn:xmpp:carbons:2">>}],
           [{xmlel,<<"forwarded">>,
            [{<<"xmlns">>,<<"urn:xmpp:forward:0">>}],
            [{xmlel,<<"message">>,
               [{<<"from">>,
                 <<"alice_dropped_client_doesnt_create_duplicate_carbons_605@localhost/res1">>},
                {<<"type">>,<<"chat">>},
                {<<"to">>,
                 <<"bob_dropped_client_doesnt_create_duplicate_carbons_605@localhost/res1">>},
                {<<"xmlns">>,<<"jabber:client">>}],
               [{xmlel,<<"body">>,[],
                  [{xmlcdata,
                     <<"And pious action">>}]}]}]}]}]}]},
   [{carboncopy_SUITE,
      '-dropped_client_doesnt_create_duplicate_carbons/1-fun-0-',4,
      [{file,
         "/home/circleci/project/big_tests/tests/carboncopy_SUITE.erl"},
       {line,189}]},
    {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,1793}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_serv...

Report log


mssql_mnesia_26 / odbc_mssql_mnesia / 462890f
Reports root/ big
OK: 4961 / Failed: 0 / User-skipped: 121 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 462890f
Reports root/ big
OK: 4964 / Failed: 0 / User-skipped: 118 / Auto-skipped: 0

Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.31%. Comparing base (11c33c3) to head (35dfa47).

Files Patch % Lines
src/mam/mod_mam_rdbms_arch.erl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4308      +/-   ##
==========================================
+ Coverage   84.27%   84.31%   +0.03%     
==========================================
  Files         553      553              
  Lines       33720    33724       +4     
==========================================
+ Hits        28418    28434      +16     
+ Misses       5302     5290      -12     

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

@jacekwegr jacekwegr marked this pull request as ready for review June 20, 2024 11:32
mam_helper:wait_for_archive_size(Alice, 1),
when_archive_query_is_sent(Alice, undefined, Config),
Res = escalus:wait_for_stanza(Alice),
escalus:assert(is_iq_error, Res)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also add something like this to check the error type:

escalus:assert(is_error, [<<"cancel">>, <<"service-unavailable">>], Error)

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 ok

@mongoose-im

This comment was marked as outdated.

@jacekwegr jacekwegr force-pushed the return-error-when-sql-query-fails branch from 38a2b29 to 35dfa47 Compare June 21, 2024 10:32
@mongoose-im
Copy link
Collaborator

mongoose-im commented Jun 21, 2024

elasticsearch_and_cassandra_26 / elasticsearch_and_cassandra_mnesia / 35dfa47
Reports root/ big
OK: 439 / Failed: 0 / User-skipped: 47 / Auto-skipped: 0


small_tests_25 / small_tests / 35dfa47
Reports root / small


small_tests_26 / small_tests / 35dfa47
Reports root / small


small_tests_26_arm64 / small_tests / 35dfa47
Reports root / small


ldap_mnesia_25 / ldap_mnesia / 35dfa47
Reports root/ big
OK: 2289 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


ldap_mnesia_26 / ldap_mnesia / 35dfa47
Reports root/ big
OK: 2289 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 35dfa47
Reports root/ big
OK: 4573 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


dynamic_domains_mysql_redis_26 / mysql_redis / 35dfa47
Reports root/ big
OK: 4540 / Failed: 0 / User-skipped: 144 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 35dfa47
Reports root/ big
OK: 4573 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


pgsql_cets_26 / pgsql_cets / 35dfa47
Reports root/ big
OK: 4484 / Failed: 0 / User-skipped: 178 / Auto-skipped: 0


internal_mnesia_26 / internal_mnesia / 35dfa47
Reports root/ big
OK: 2429 / Failed: 0 / User-skipped: 765 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / 35dfa47
Reports root/ big
OK: 4570 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0


mysql_redis_26 / mysql_redis / 35dfa47
Reports root/ big
OK: 4943 / Failed: 0 / User-skipped: 139 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 35dfa47
Reports root/ big
OK: 4964 / Failed: 0 / User-skipped: 118 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 35dfa47
Reports root/ big
OK: 4964 / Failed: 0 / User-skipped: 118 / Auto-skipped: 0


mssql_mnesia_26 / odbc_mssql_mnesia / 35dfa47
Reports root/ big
OK: 4961 / Failed: 0 / User-skipped: 121 / Auto-skipped: 0

@arcusfelis arcusfelis merged commit e830b03 into master Jun 24, 2024
3 of 4 checks passed
@arcusfelis arcusfelis deleted the return-error-when-sql-query-fails branch June 24, 2024 07:25
@jacekwegr jacekwegr added this to the 6.3.0 milestone Oct 3, 2024
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