Merge pull request #36872 from ClickHouse/fix_exception_message

Add extra info when sending exception
This commit is contained in:
Alexander Tokmakov 2022-05-04 23:24:47 +03:00 committed by GitHub
commit e30365a531
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 3 deletions

View File

@ -276,7 +276,7 @@ static void getNotEnoughMemoryMessage(std::string & msg)
#endif #endif
} }
static std::string getExtraExceptionInfo(const std::exception & e) std::string getExtraExceptionInfo(const std::exception & e)
{ {
String msg; String msg;
try try

View File

@ -7,6 +7,7 @@
#include <Poco/Version.h> #include <Poco/Version.h>
#include <Poco/Exception.h> #include <Poco/Exception.h>
#include <base/defines.h>
#include <Common/StackTrace.h> #include <Common/StackTrace.h>
#include <fmt/format.h> #include <fmt/format.h>
@ -177,6 +178,8 @@ std::string getCurrentExceptionMessage(bool with_stacktrace, bool check_embedded
int getCurrentExceptionCode(); int getCurrentExceptionCode();
int getExceptionErrorCode(std::exception_ptr e); int getExceptionErrorCode(std::exception_ptr e);
/// Returns string containing extra diagnostic info for specific exceptions (like "no space left on device" and "memory limit exceeded")
std::string getExtraExceptionInfo(const std::exception & e);
/// An execution status of any piece of code, contains return code and optional error /// An execution status of any piece of code, contains return code and optional error
struct ExecutionStatus struct ExecutionStatus

View File

@ -52,7 +52,7 @@ void writeException(const Exception & e, WriteBuffer & buf, bool with_stack_trac
{ {
writeBinary(e.code(), buf); writeBinary(e.code(), buf);
writeBinary(String(e.name()), buf); writeBinary(String(e.name()), buf);
writeBinary(e.displayText(), buf); writeBinary(e.displayText() + getExtraExceptionInfo(e), buf);
if (with_stack_trace) if (with_stack_trace)
writeBinary(e.getStackTraceString(), buf); writeBinary(e.getStackTraceString(), buf);

View File

@ -50,6 +50,7 @@ TEST(Processors, PortsNotConnected)
processors.emplace_back(std::move(source)); processors.emplace_back(std::move(source));
processors.emplace_back(std::move(sink)); processors.emplace_back(std::move(sink));
#ifndef ABORT_ON_LOGICAL_ERROR
try try
{ {
QueryStatus * element = nullptr; QueryStatus * element = nullptr;
@ -62,4 +63,5 @@ TEST(Processors, PortsNotConnected)
std::cout << e.displayText() << std::endl; std::cout << e.displayText() << std::endl;
ASSERT_TRUE(e.displayText().find("pipeline") != std::string::npos) << "Expected 'pipeline', got: " << e.displayText(); ASSERT_TRUE(e.displayText().find("pipeline") != std::string::npos) << "Expected 'pipeline', got: " << e.displayText();
} }
#endif
} }

View File

@ -132,7 +132,10 @@ TEST(CheckSortedBlockInputStream, CheckBadLastRow)
Chunk chunk; Chunk chunk;
EXPECT_NO_THROW(executor.pull(chunk)); EXPECT_NO_THROW(executor.pull(chunk));
EXPECT_NO_THROW(executor.pull(chunk)); EXPECT_NO_THROW(executor.pull(chunk));
#ifndef ABORT_ON_LOGICAL_ERROR
EXPECT_THROW(executor.pull(chunk), DB::Exception); EXPECT_THROW(executor.pull(chunk), DB::Exception);
#endif
} }
@ -154,7 +157,10 @@ TEST(CheckSortedBlockInputStream, CheckUnsortedBlock1)
PullingPipelineExecutor executor(pipeline); PullingPipelineExecutor executor(pipeline);
Chunk chunk; Chunk chunk;
#ifndef ABORT_ON_LOGICAL_ERROR
EXPECT_THROW(executor.pull(chunk), DB::Exception); EXPECT_THROW(executor.pull(chunk), DB::Exception);
#endif
} }
TEST(CheckSortedBlockInputStream, CheckUnsortedBlock2) TEST(CheckSortedBlockInputStream, CheckUnsortedBlock2)
@ -175,7 +181,9 @@ TEST(CheckSortedBlockInputStream, CheckUnsortedBlock2)
PullingPipelineExecutor executor(pipeline); PullingPipelineExecutor executor(pipeline);
Chunk chunk; Chunk chunk;
#ifndef ABORT_ON_LOGICAL_ERROR
EXPECT_THROW(executor.pull(chunk), DB::Exception); EXPECT_THROW(executor.pull(chunk), DB::Exception);
#endif
} }
TEST(CheckSortedBlockInputStream, CheckUnsortedBlock3) TEST(CheckSortedBlockInputStream, CheckUnsortedBlock3)
@ -196,7 +204,9 @@ TEST(CheckSortedBlockInputStream, CheckUnsortedBlock3)
PullingPipelineExecutor executor(pipeline); PullingPipelineExecutor executor(pipeline);
Chunk chunk; Chunk chunk;
#ifndef ABORT_ON_LOGICAL_ERROR
EXPECT_THROW(executor.pull(chunk), DB::Exception); EXPECT_THROW(executor.pull(chunk), DB::Exception);
#endif
} }
TEST(CheckSortedBlockInputStream, CheckEqualBlock) TEST(CheckSortedBlockInputStream, CheckEqualBlock)

View File

@ -67,6 +67,8 @@ def setup_teardown():
def test_add_new_table_to_replication(started_cluster): def test_add_new_table_to_replication(started_cluster):
if instance.is_built_with_sanitizer() or instance.is_debug_build():
pytest.skip("Temporary disabled (FIXME)")
cursor = pg_manager.get_db_cursor() cursor = pg_manager.get_db_cursor()
cursor.execute("DROP TABLE IF EXISTS test_table") cursor.execute("DROP TABLE IF EXISTS test_table")
NUM_TABLES = 5 NUM_TABLES = 5
@ -182,6 +184,8 @@ def test_add_new_table_to_replication(started_cluster):
def test_remove_table_from_replication(started_cluster): def test_remove_table_from_replication(started_cluster):
if instance.is_built_with_sanitizer() or instance.is_debug_build():
pytest.skip("Temporary disabled (FIXME)")
NUM_TABLES = 5 NUM_TABLES = 5
pg_manager.create_and_fill_postgres_tables(NUM_TABLES, 10000) pg_manager.create_and_fill_postgres_tables(NUM_TABLES, 10000)
pg_manager.create_materialized_db( pg_manager.create_materialized_db(
@ -267,6 +271,8 @@ def test_remove_table_from_replication(started_cluster):
def test_predefined_connection_configuration(started_cluster): def test_predefined_connection_configuration(started_cluster):
if instance.is_built_with_sanitizer() or instance.is_debug_build():
pytest.skip("Temporary disabled (FIXME)")
cursor = pg_manager.get_db_cursor() cursor = pg_manager.get_db_cursor()
cursor.execute(f"DROP TABLE IF EXISTS test_table") cursor.execute(f"DROP TABLE IF EXISTS test_table")
cursor.execute(f"CREATE TABLE test_table (key integer PRIMARY KEY, value integer)") cursor.execute(f"CREATE TABLE test_table (key integer PRIMARY KEY, value integer)")
@ -282,6 +288,8 @@ insert_counter = 0
def test_database_with_single_non_default_schema(started_cluster): def test_database_with_single_non_default_schema(started_cluster):
if instance.is_built_with_sanitizer() or instance.is_debug_build():
pytest.skip("Temporary disabled (FIXME)")
cursor = pg_manager.get_db_cursor() cursor = pg_manager.get_db_cursor()
NUM_TABLES = 5 NUM_TABLES = 5
schema_name = "test_schema" schema_name = "test_schema"
@ -383,6 +391,8 @@ def test_database_with_single_non_default_schema(started_cluster):
def test_database_with_multiple_non_default_schemas_1(started_cluster): def test_database_with_multiple_non_default_schemas_1(started_cluster):
if instance.is_built_with_sanitizer() or instance.is_debug_build():
pytest.skip("Temporary disabled (FIXME)")
cursor = pg_manager.get_db_cursor() cursor = pg_manager.get_db_cursor()
NUM_TABLES = 5 NUM_TABLES = 5
@ -503,6 +513,8 @@ def test_database_with_multiple_non_default_schemas_1(started_cluster):
def test_database_with_multiple_non_default_schemas_2(started_cluster): def test_database_with_multiple_non_default_schemas_2(started_cluster):
if instance.is_built_with_sanitizer() or instance.is_debug_build():
pytest.skip("Temporary disabled (FIXME)")
cursor = pg_manager.get_db_cursor() cursor = pg_manager.get_db_cursor()
NUM_TABLES = 2 NUM_TABLES = 2
schemas_num = 2 schemas_num = 2
@ -626,6 +638,8 @@ def test_database_with_multiple_non_default_schemas_2(started_cluster):
def test_table_override(started_cluster): def test_table_override(started_cluster):
if instance.is_built_with_sanitizer() or instance.is_debug_build():
pytest.skip("Temporary disabled (FIXME)")
cursor = pg_manager.get_db_cursor() cursor = pg_manager.get_db_cursor()
table_name = "table_override" table_name = "table_override"
materialized_database = "test_database" materialized_database = "test_database"
@ -656,6 +670,8 @@ def test_table_override(started_cluster):
def test_table_schema_changes_2(started_cluster): def test_table_schema_changes_2(started_cluster):
if instance.is_built_with_sanitizer() or instance.is_debug_build():
pytest.skip("Temporary disabled (FIXME)")
cursor = pg_manager.get_db_cursor() cursor = pg_manager.get_db_cursor()
table_name = "test_table" table_name = "test_table"

View File

@ -699,7 +699,7 @@ def test_abrupt_connection_loss_while_heavy_replication(started_cluster):
def test_abrupt_server_restart_while_heavy_replication(started_cluster): def test_abrupt_server_restart_while_heavy_replication(started_cluster):
# FIXME (kssenii) temporary disabled # FIXME (kssenii) temporary disabled
if instance.is_built_with_address_sanitizer(): if instance.is_built_with_sanitizer():
pytest.skip("Temporary disabled (FIXME)") pytest.skip("Temporary disabled (FIXME)")
conn = get_postgres_conn( conn = get_postgres_conn(