|
1 | 1 | %%-------------------------------------------------------------------- |
2 | | -%% Copyright (c) 2021-2023 EMQ Technologies Co., Ltd. All Rights Reserved. |
| 2 | +%% Copyright (c) 2021-2026 EMQ Technologies Co., Ltd. All Rights Reserved. |
3 | 3 | %% |
4 | 4 | %% Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | %% you may not use this file except in compliance with the License. |
@@ -343,9 +343,9 @@ bootstrap() -> |
343 | 343 | %% Ensure replicas are available before starting copy: |
344 | 344 | %% If we've managed to sync only mnesia schema up to this point, `copy_table/2` may |
345 | 345 | %% fail if other nodes suddenly become unavailable. |
346 | | - ok = mria_mnesia:wait_for_tables([?rlog_sync]), |
347 | 346 | ok = mria_mnesia:copy_table(?rlog_sync, null_copies), |
348 | | - mria_mnesia:wait_for_tables([?schema, ?rlog_sync]), |
| 347 | + %% Contents of this table are irrelevant, so force load: |
| 348 | + force_load(?rlog_sync), |
349 | 349 | %% Seed the table with the metadata: |
350 | 350 | {atomic, _} = mnesia:transaction(fun mnesia:write/3, [?schema, MetaSpec, write], infinity), |
351 | 351 | {atomic, _} = mnesia:transaction(fun mnesia:write/3, [?schema, RlogSyncSpec, write], infinity), |
@@ -386,3 +386,12 @@ notify_change(Shard, Entry, Subscribers) -> |
386 | 386 | -spec create_table(entry()) -> ok | _. |
387 | 387 | create_table(#?schema{mnesia_table = Table, storage = Storage, config = Config}) -> |
388 | 388 | mria_lib:ensure_tab(mnesia:create_table(Table, [{Storage, [node()]} | Config])). |
| 389 | + |
| 390 | +%% @doc Force load a table. Note: mnesia waits for table implicitly. |
| 391 | +force_load(Table) -> |
| 392 | + case mnesia:force_load_table(Table) of |
| 393 | + yes -> |
| 394 | + ok; |
| 395 | + Other -> |
| 396 | + logger:error("Failed to force loading table ~p: ~p", [Table, Other]) |
| 397 | + end. |
0 commit comments