dbms: max_open_files for server, readline in OS X. [#METR-21516]

This commit is contained in:
Vladimir Chebotarev 2016-11-03 22:59:53 +03:00
parent 3d05948c45
commit 72a533bc11
5 changed files with 30 additions and 16 deletions

View File

@ -1,10 +1,12 @@
find_library(READLINE_LIB
NAMES libreadline.a libreadline.so)
NAMES libreadline.a libreadline.so
HINTS "/usr/local/opt/readline/lib")
find_library(LIBEDIT_LIB
NAMES libedit.a libedit.so)
if(READLINE_LIB)
include_directories("/usr/local/opt/readline/include")
add_definitions(-D USE_READLINE)
set(LINE_EDITING_LIBS ${READLINE_LIB} libtermcap.a)
message(STATUS "Using line editing libraries: ${LINE_EDITING_LIBS}")

View File

@ -24,10 +24,16 @@ namespace ErrorCodes
void throwFromErrno(const std::string & s, int code, int e)
{
const size_t buf_size = 128;
#ifndef _GNU_SOURCE
const char *unknown_message = "Unknown error ";
char buf[buf_size];
if (!strerror_r(e, buf, buf_size)) {
#ifndef _GNU_SOURCE
const char * unknown_message = "Unknown error ";
int rc = strerror_r(e, buf, buf_size);
#ifdef __APPLE__
if (rc != 0 && rc != EINVAL)
#else
if (rc != 0)
#endif
{
std::string tmp = std::to_string(code);
const char* code = tmp.c_str();
strcpy(buf, unknown_message);
@ -35,7 +41,6 @@ void throwFromErrno(const std::string & s, int code, int e)
}
throw ErrnoException(s + ", errno: " + toString(e) + ", strerror: " + std::string(buf), code, e);
#else
char buf[buf_size];
throw ErrnoException(s + ", errno: " + toString(e) + ", strerror: " + std::string(strerror_r(e, buf, sizeof(buf))), code, e);
#endif
}

View File

@ -205,7 +205,7 @@ int Server::main(const std::vector<std::string> & args)
StatusFile status{path + "status"};
/// Try to increase limit on number of opened files.
/// Try to increase limit on number of open files.
{
rlimit rlim;
if (getrlimit(RLIMIT_NOFILE, &rlim))
@ -218,16 +218,13 @@ int Server::main(const std::vector<std::string> & args)
else
{
rlim_t old = rlim.rlim_cur;
rlim.rlim_cur = rlim.rlim_max;
#ifndef __APPLE__
if (setrlimit(RLIMIT_NOFILE, &rlim))
throw Poco::Exception("Cannot setrlimit");
#else
LOG_INFO(log, "Setting nofile limit is not supported on MacOS X. Please increase it manually. See MacOS.md for more information. Current limit is '" << old << "'");
throw Poco::Exception("setrlimit is not supported on MacOS X");
#endif
rlim.rlim_cur = config().getUInt("max_open_files", rlim.rlim_max);
int rc = setrlimit(RLIMIT_NOFILE, &rlim);
if (rc != 0)
//throwFromErrno(std::string("Cannot setrlimit (tried rlim_cur = ") + std::to_string(rlim.rlim_cur) + "). Try to specify max_open_files according to your system limits");
throw DB::Exception(std::string("Cannot setrlimit (tried rlim_cur = ") + std::to_string(rlim.rlim_cur) + "). Try to specify max_open_files according to your system limits. error: " + strerror(errno));
LOG_DEBUG(log, "Set rlimit on number of file descriptors to " << rlim.rlim_cur << " (was " << old << ")");
LOG_DEBUG(log, "Set rlimit on number of file descriptors to " << rlim.rlim_cur << " (was " << old << ").");
}
}

View File

@ -32,6 +32,10 @@
<!-- Maximum number of concurrent queries. -->
<max_concurrent_queries>100</max_concurrent_queries>
<!-- Set limit on number of open files (default: maximum). This setting makes sense on Mac OS X because getrlimit() fails to retrieve
correct maximum value. -->
<!-- <max_open_files>262144</max_open_files> -->
<!-- Size of cache of uncompressed blocks of data, used in tables of MergeTree family.
In bytes. Cache is single for server. Memory is allocated only on demand.
Cache is used when 'use_uncompressed_cache' user setting turned on (off by default).

View File

@ -25,12 +25,18 @@ brew install cmake gcc
brew install boost --cc=gcc-6
```
## Install required libraries from packages
## Install required libraries
```
brew install icu4c mysql openssl unixodbc
```
## Install optional libraries
```
brew install readline
```
# Checkout ClickHouse sources
```