**Describe the bug**
`SELECT i FROM generateRandom('i Array(Int8)', 1048575, 10, 1048577) LIMIT 1048575`

Memory limit should be respected.
{
        tryLogCurrentException(__PRETTY_FUNCTION__);
    }
    {
        std::lock_guard lock(mutex);
        flushed_before = to_flush_end;
        is_force_prepare_tables = false;
        flush_event.notify_all();
    }
    LOG_TRACE(log, "Flushed system log");
}
template <typename LogElement>
void SystemLog<LogElement>::prepareTable()
{
    String description = table_id.getNameForLogs();
    table = DatabaseCatalog::instance().tryGetTable(table_id, context);
    if (table)
    {
        auto metadata_snapshot = table->getInMemoryMetadataPtr();
        const Block expected = LogElement::createBlock();
        const Block actual = metadata_snapshot->getSampleBlockNonMaterialized();
        if (!blocksHaveEqualStructure(actual, expected))
        {
            
            int suffix = 0;
            while (DatabaseCatalog::instance().isTableExist({table_id.database_name, table_id.table_name + "_" + toString(suffix)}, context))
                ++suffix;
            auto rename = std::make_shared<ASTRenameQuery>();
            ASTRenameQuery::Table from;
            from.database = table_id.database_name;