mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 18:02:24 +00:00
Throw an error instead of silenty ignore storage_file_read_method=mmap in server
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
0c7a4142e4
commit
a7b14f87e0
@ -205,7 +205,7 @@ std::unique_ptr<ReadBuffer> selectReadBuffer(
|
|||||||
{
|
{
|
||||||
auto read_method = context->getSettingsRef().storage_file_read_method;
|
auto read_method = context->getSettingsRef().storage_file_read_method;
|
||||||
|
|
||||||
/** But using mmap on server-side is unsafe for the following reasons:
|
/** Using mmap on server-side is unsafe for the following reasons:
|
||||||
* - concurrent modifications of a file will result in SIGBUS;
|
* - concurrent modifications of a file will result in SIGBUS;
|
||||||
* - IO error from the device will result in SIGBUS;
|
* - IO error from the device will result in SIGBUS;
|
||||||
* - recovery from this signal is not feasible even with the usage of siglongjmp,
|
* - recovery from this signal is not feasible even with the usage of siglongjmp,
|
||||||
@ -214,10 +214,10 @@ std::unique_ptr<ReadBuffer> selectReadBuffer(
|
|||||||
*
|
*
|
||||||
* But we keep this mode for clickhouse-local as it is not so bad for a command line tool.
|
* But we keep this mode for clickhouse-local as it is not so bad for a command line tool.
|
||||||
*/
|
*/
|
||||||
|
if (context->getApplicationType() == Context::ApplicationType::SERVER && read_method == LocalFSReadMethod::mmap)
|
||||||
|
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Using storage_file_read_method=mmap is not safe in server mode. Consider using pread.");
|
||||||
|
|
||||||
if (S_ISREG(file_stat.st_mode)
|
if (S_ISREG(file_stat.st_mode) && read_method == LocalFSReadMethod::mmap)
|
||||||
&& context->getApplicationType() != Context::ApplicationType::SERVER
|
|
||||||
&& read_method == LocalFSReadMethod::mmap)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -13,4 +13,6 @@ $CLICKHOUSE_LOCAL --storage_file_read_method=mmap --print-profile-events -q "SEL
|
|||||||
$CLICKHOUSE_LOCAL --storage_file_read_method=pread --print-profile-events -q "SELECT * FROM file($DATA_FILE) FORMAT Null" 2>&1 | grep -F -c "CreatedReadBufferMMap"
|
$CLICKHOUSE_LOCAL --storage_file_read_method=pread --print-profile-events -q "SELECT * FROM file($DATA_FILE) FORMAT Null" 2>&1 | grep -F -c "CreatedReadBufferMMap"
|
||||||
$CLICKHOUSE_LOCAL --storage_file_read_method=pread --print-profile-events -q "SELECT * FROM file($DATA_FILE) FORMAT Null" 2>&1 | grep -F -c "CreatedReadBufferOrdinary"
|
$CLICKHOUSE_LOCAL --storage_file_read_method=pread --print-profile-events -q "SELECT * FROM file($DATA_FILE) FORMAT Null" 2>&1 | grep -F -c "CreatedReadBufferOrdinary"
|
||||||
|
|
||||||
|
$CLICKHOUSE_CLIENT --storage_file_read_method=mmap -nq "SELECT * FROM file('/dev/null', 'LineAsString') FORMAT Null -- { serverError BAD_ARGUMENTS }"
|
||||||
|
|
||||||
rm $DATA_FILE
|
rm $DATA_FILE
|
||||||
|
Loading…
Reference in New Issue
Block a user