Merge pull request #35050 from CurtizJ/fix-async-inserts-system-table

Fix reading from `system.asynchronous_inserts` table
This commit is contained in:
alexey-milovidov 2022-03-06 02:25:53 +03:00 committed by GitHub
commit f9b7df6ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -62,8 +62,19 @@ void StorageSystemAsynchronousInserts::fillData(MutableColumns & res_columns, Co
size_t i = 0;
res_columns[i++]->insert(queryToString(insert_query));
res_columns[i++]->insert(insert_query.table_id.getDatabaseName());
res_columns[i++]->insert(insert_query.table_id.getTableName());
/// If query is "INSERT INTO FUNCTION" then table_id is empty.
if (insert_query.table_id)
{
res_columns[i++]->insert(insert_query.table_id.getDatabaseName());
res_columns[i++]->insert(insert_query.table_id.getTableName());
}
else
{
res_columns[i++]->insertDefault();
res_columns[i++]->insertDefault();
}
res_columns[i++]->insert(insert_query.format);
res_columns[i++]->insert(time_in_microseconds(elem->data->first_update));
res_columns[i++]->insert(time_in_microseconds(elem->data->last_update));

View File

@ -24,6 +24,14 @@ function insert2()
done
}
function insert3()
{
url="${CLICKHOUSE_URL}&async_insert=1&wait_for_async_insert=0"
while true; do
${CLICKHOUSE_CURL} -sS "$url" -d "INSERT INTO FUNCTION remote('127.0.0.1', $CLICKHOUSE_DATABASE, async_inserts) VALUES (7, 'g') (8, 'h')"
done
}
function select1()
{
while true; do
@ -53,6 +61,7 @@ TIMEOUT=10
export -f insert1
export -f insert2
export -f insert3
export -f select1
export -f select2
export -f truncate1
@ -60,6 +69,7 @@ export -f truncate1
for _ in {1..5}; do
timeout $TIMEOUT bash -c insert1 &
timeout $TIMEOUT bash -c insert2 &
timeout $TIMEOUT bash -c insert3 &
done
timeout $TIMEOUT bash -c select1 &