mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Add nested exception when handle Disk S3 metadata file read error.
This commit is contained in:
parent
72a55c192e
commit
25df6bae78
@ -34,9 +34,9 @@ namespace ErrorCodes
|
|||||||
extern const int CANNOT_MREMAP;
|
extern const int CANNOT_MREMAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Aborts the process if error code is LOGICAL_ERROR.
|
||||||
Exception::Exception(const std::string & msg, int code)
|
/// Increments error codes statistics.
|
||||||
: Poco::Exception(msg, code)
|
void handle_error_code(const std::string & msg, int code) // NOLINT
|
||||||
{
|
{
|
||||||
// In debug builds and builds with sanitizers, treat LOGICAL_ERROR as an assertion failure.
|
// In debug builds and builds with sanitizers, treat LOGICAL_ERROR as an assertion failure.
|
||||||
// Log the message before we fail.
|
// Log the message before we fail.
|
||||||
@ -50,6 +50,18 @@ Exception::Exception(const std::string & msg, int code)
|
|||||||
ErrorCodes::increment(code);
|
ErrorCodes::increment(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Exception::Exception(const std::string & msg, int code)
|
||||||
|
: Poco::Exception(msg, code)
|
||||||
|
{
|
||||||
|
handle_error_code(msg, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
Exception::Exception(const std::string & msg, const Exception & nested, int code)
|
||||||
|
: Poco::Exception(msg, nested, code)
|
||||||
|
{
|
||||||
|
handle_error_code(msg, code);
|
||||||
|
}
|
||||||
|
|
||||||
Exception::Exception(CreateFromPocoTag, const Poco::Exception & exc)
|
Exception::Exception(CreateFromPocoTag, const Poco::Exception & exc)
|
||||||
: Poco::Exception(exc.displayText(), ErrorCodes::POCO_EXCEPTION)
|
: Poco::Exception(exc.displayText(), ErrorCodes::POCO_EXCEPTION)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@ class Exception : public Poco::Exception
|
|||||||
public:
|
public:
|
||||||
Exception() = default;
|
Exception() = default;
|
||||||
Exception(const std::string & msg, int code);
|
Exception(const std::string & msg, int code);
|
||||||
|
Exception(const std::string & msg, const Exception & nested, int code);
|
||||||
|
|
||||||
Exception(int code, const std::string & message)
|
Exception(int code, const std::string & message)
|
||||||
: Exception(message, code)
|
: Exception(message, code)
|
||||||
|
@ -175,7 +175,7 @@ struct DiskS3::Metadata
|
|||||||
if (e.code() == ErrorCodes::UNKNOWN_FORMAT)
|
if (e.code() == ErrorCodes::UNKNOWN_FORMAT)
|
||||||
throw;
|
throw;
|
||||||
|
|
||||||
throw Exception("Failed to read metadata file: " + e.message(), ErrorCodes::UNKNOWN_FORMAT);
|
throw Exception("Failed to read metadata file", e, ErrorCodes::UNKNOWN_FORMAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,7 +729,7 @@ void DiskS3::removeMeta(const String & path, AwsS3KeyKeeper & keys)
|
|||||||
file.remove();
|
file.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception & e)
|
catch (const Exception & e)
|
||||||
{
|
{
|
||||||
/// If it's impossible to read meta - just remove it from FS.
|
/// If it's impossible to read meta - just remove it from FS.
|
||||||
if (e.code() == ErrorCodes::UNKNOWN_FORMAT)
|
if (e.code() == ErrorCodes::UNKNOWN_FORMAT)
|
||||||
@ -738,7 +738,7 @@ void DiskS3::removeMeta(const String & path, AwsS3KeyKeeper & keys)
|
|||||||
&Poco::Logger::get("DiskS3"),
|
&Poco::Logger::get("DiskS3"),
|
||||||
"Metadata file {} can't be read by reason: {}. Removing it forcibly.",
|
"Metadata file {} can't be read by reason: {}. Removing it forcibly.",
|
||||||
backQuote(path),
|
backQuote(path),
|
||||||
e.message());
|
e.nested() ? e.nested()->message() : e.message());
|
||||||
|
|
||||||
file.remove();
|
file.remove();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user