Skip to content

Commit

Permalink
Add option update_sql_schema_timeout to allow schema update use longe…
Browse files Browse the repository at this point in the history
…r timeouts

This also makes batch of schema updates to single table use transaction,
which should help in not leaving table in inconsistent state if some update
steps fails (unless you use mysql where you can't rollback changes to
table schemas).
  • Loading branch information
prefiks committed Jul 16, 2024
1 parent f56739f commit ead87e3
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 237 deletions.
8 changes: 8 additions & 0 deletions src/ejabberd_option.erl
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
-export([sql_username/0, sql_username/1]).
-export([trusted_proxies/0]).
-export([update_sql_schema/0]).
-export([update_sql_schema_timeout/0, update_sql_schema_timeout/1]).
-export([use_cache/0, use_cache/1]).
-export([validate_stream/0]).
-export([version/0]).
Expand Down Expand Up @@ -1109,6 +1110,13 @@ trusted_proxies() ->
update_sql_schema() ->
ejabberd_config:get_option({update_sql_schema, global}).

-spec update_sql_schema_timeout() -> 'infinity' | pos_integer().
update_sql_schema_timeout() ->
update_sql_schema_timeout(global).
-spec update_sql_schema_timeout(global | binary()) -> 'infinity' | pos_integer().
update_sql_schema_timeout(Host) ->
ejabberd_config:get_option({update_sql_schema_timeout, Host}).

-spec use_cache() -> boolean().
use_cache() ->
use_cache(global).
Expand Down
3 changes: 3 additions & 0 deletions src/ejabberd_options.erl
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ opt_type(new_sql_schema) ->
econf:bool();
opt_type(update_sql_schema) ->
econf:bool();
opt_type(update_sql_schema_timeout) ->
econf:timeout(second, infinity);
opt_type(oauth_access) ->
econf:acl();
opt_type(oauth_cache_life_time) ->
Expand Down Expand Up @@ -613,6 +615,7 @@ options() ->
{net_ticktime, timer:seconds(60)},
{new_sql_schema, ?USE_NEW_SQL_SCHEMA_DEFAULT},
{update_sql_schema, true},
{update_sql_schema_timeout, timer:minutes(5)},
{oauth_access, none},
{oauth_cache_life_time,
fun(Host) -> ejabberd_config:get_option({cache_life_time, Host}) end},
Expand Down
6 changes: 6 additions & 0 deletions src/ejabberd_options_doc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,12 @@ doc() ->
"This option was added in ejabberd 23.10, "
"and enabled by default since 24.06. "
"The default value is 'true'.")}},
{update_sql_schema_timeout,
#{value => "timeout()",
note => "added in 24.07",
desc =>
?T("Time allocated to SQL schema update queries. "
"The default value is set to 5 minutes.")}},
{oauth_access,
#{value => ?T("AccessName"),
desc => ?T("By default creating OAuth tokens is not allowed. "
Expand Down
Loading

0 comments on commit ead87e3

Please sign in to comment.