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
Asynchronous loading of tables #49351
Conversation
|
@serxa, something interesting around |
I'm still trying to figure out what went wrong. I found a backtrace with variables in gdb.log of the stress test and according to table_id in one of the frames the table in question is
This test is very good at checking issues with dependencies. It had already found a deadlock (fixed) in this PR. More logs:
|
Looks like detach/attach database cycle in The detach was started before previous attach is finished:
|
After fix materialized mysql database became broken: |
Just in case, MaterializedMySQL is a second-class feature - if needed, you can make a shortcut so that it is loaded non-lazily. |
MaterializedMySQL is inherited from AtomicDatabase, which is now reworked to be async only. So it might be even harder than figure out what when wrong... Checking... |
The problem is here: clickhouse_node.query(f"ALTER NAMED COLLECTION {db} SET port=9999")
clickhouse_node.query_with_retry(f"DETACH DATABASE {db} SYNC")
mysql_node.query(f"INSERT INTO {db}.t1 VALUES (3, 'c', 3)")
assert "ConnectionFailed:" in clickhouse_node.query_and_get_error(
f"ATTACH DATABASE {db}"
)
clickhouse_node.query(f"ALTER NAMED COLLECTION {db} SET port=3306")
clickhouse_node.query(f"ATTACH DATABASE {db}")
UPD. It turned out to be a deeper problem. I added |
CI is green now. |
This doesn’t actually speed up start to query time for those tables though right? Just for getting a sql session/health checks? |
No. If the server has a lot of tables to load at startup, this feature will also improve the time for queries due to prioritization. Prioritization means loading of tables that are being waited for by queries is done first. |
Should be merged after #48923
Fixes #43424
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Added server setting
async_load_databases
for asynchronous loading of databases and tables. Speeds up the server start time. Applies to databases with Ordinary, Atomic and Replicated engines. Their tables load metadata asynchronously. Query to a table increases the priority of the load job and waits for it to be done. Added tablesystem.async_loader
.Documentation entry for user-facing changes