?MODULE, [Host]).
init([Host]) ->
- PoolSize = ejabberd_config:get_option(
- {sql_pool_size, Host},
- fun(I) when is_integer(I), I>0 -> I end,
- ?DEFAULT_POOL_SIZE),
StartInterval = ejabberd_config:get_option(
{sql_start_interval, Host},
fun(I) when is_integer(I), I>0 -> I end,
(mssql) -> mssql;
(odbc) -> odbc
end, odbc),
+ PoolSize = get_pool_size(Type, Host),
case Type of
sqlite ->
check_sqlite_db(Host);
end,
mnesia:ets(F).
+-spec get_pool_size(atom(), binary()) -> pos_integer().
+get_pool_size(SQLType, Host) ->
+ PoolSize = ejabberd_config:get_option(
+ {sql_pool_size, Host},
+ fun(I) when is_integer(I), I>0 -> I end,
+ case SQLType of
+ sqlite -> 1;
+ _ -> ?DEFAULT_POOL_SIZE
+ end),
+ if PoolSize > 1 andalso SQLType == sqlite ->
+ ?WARNING_MSG("it's not recommended to set sql_pool_size > 1 for "
+ "sqlite, because it may cause race conditions", []);
+ true ->
+ ok
+ end,
+ PoolSize.
+
transform_options(Opts) ->
lists:foldl(fun transform_options/2, [], Opts).