Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running daemon in custom environment #3612

Merged
merged 1 commit into from
Nov 22, 2018
Merged

Running daemon in custom environment #3612

merged 1 commit into from
Nov 22, 2018

Conversation

levonet
Copy link
Contributor

@levonet levonet commented Nov 19, 2018

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

It's need to connect dictionaries from oracle with using cyrillic support (set env for odbc-bridge NLS_LANG=AMERICAN_AMERICA.AL32UTF8 and LANG=en_US.UTF-8).
And I fix terminating clickhouse odbc-bridge where main process was stoped.

@@ -36,6 +36,11 @@ command -v flock >/dev/null && FLOCK=flock
# Override defaults from optional config file
test -f /etc/default/clickhouse && . /etc/default/clickhouse

# Environment for run daemon
if [ -f /etc/sysconfig/$PROGRAM ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we should support /etc/default for debian based systems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can transfer PROGRAM_ENV to /etc/default/clickhouse.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proller also suggested that we can simply source (.) this file instead of manual parsing.

@alexey-milovidov
Copy link
Member

We cannot find the reason why the child process is not terminated with parent.
Could you please provide more details: a process tree before and after terminating clickhouse-server and details about what is sh in your system.

@levonet
Copy link
Contributor Author

levonet commented Nov 20, 2018

With original initscript:

[root@reporting-dev1 init.d]# ./clickhouse-server start
Start clickhouse-server service: Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/
DONE
[root@reporting-dev1 init.d]# ps axw | grep clickhouse
18665 ?        Ssl    0:00 clickhouse-server --daemon --pid-file=/var/run/clickhouse-server/clickhouse-server.pid --config-file=/etc/clickhouse-server/config.xml
18672 ?        Sl     0:03 /bin/clickhouse odbc-bridge --http-port 9018 --listen-host localhost --http-timeout 1800000000
18719 pts/3    S+     0:00 grep --color=auto clickhouse
[root@reporting-dev1 init.d]# ps e --forest -g 18665
  PID TTY      STAT   TIME COMMAND
18672 ?        Sl     0:03 /bin/clickhouse odbc-bridge --http-port 9018 --listen-host localhost --http-timeout 1800000000 XDG_SESSION_ID=133 HOSTNAME=reporting-dev1 TERM=xterm-256color SHELL=/bin/bash H
18665 ?        Ssl    0:00 clickhouse-server --daemon --pid-file=/var/run/clickhouse-server/clickhouse-server.pid --config-file=/etc/clickhouse-server/config.xml XDG_SESSION_ID=133 HOSTNAME=reporting-de
[root@reporting-dev1 init.d]# ./clickhouse-server stop
Stop clickhouse-server service: DONE
[root@reporting-dev1 init.d]# ps axw | grep clickhouse
18672 ?        Sl     0:03 /bin/clickhouse odbc-bridge --http-port 9018 --listen-host localhost --http-timeout 1800000000
18772 pts/3    S+     0:00 grep --color=auto clickhouse

in log:

2018.11.20 19:37:52.357407 [ 1 ] {} <Information> : Starting ClickHouse 18.14.13 with revision 54409
2018.11.20 19:37:52.361674 [ 1 ] {} <Information> Application: starting up
2018.11.20 19:37:52.367658 [ 1 ] {} <Debug> Application: rlimit on number of file descriptors is 262144
2018.11.20 19:37:52.367683 [ 1 ] {} <Debug> Application: Initializing DateLUT.
2018.11.20 19:37:52.367692 [ 1 ] {} <Trace> Application: Initialized DateLUT with time zone `Europe/Kiev'.
2018.11.20 19:37:52.369428 [ 1 ] {} <Debug> Application: Configuration parameter 'interserver_http_host' doesn't exist or exists and empty. Will use 'reporting-dev1.c.xxxxxxx-demo.internal' as replica host.
2018.11.20 19:37:52.371298 [ 1 ] {} <Debug> ConfigReloader: Loading config `/etc/clickhouse-server/users.xml'
2018.11.20 19:37:52.372392 [ 1 ] {} <Information> Application: Loading metadata.
2018.11.20 19:37:52.372669 [ 1 ] {} <Information> DatabaseOrdinary (system): Total 0 tables.
2018.11.20 19:37:52.372675 [ 1 ] {} <Information> DatabaseOrdinary (system): Starting up tables.
2018.11.20 19:37:52.376539 [ 1 ] {} <Information> DatabaseOrdinary (busfor_report): Total 8 tables.
2018.11.20 19:37:52.385974 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.387521 [ 3 ] {} <Trace> ODBCBridgeHelper: clickhouse-odbc-bridge is not running, will try to start it
2018.11.20 19:37:52.387585 [ 3 ] {} <Trace> ODBCBridgeHelper: Starting clickhouse-odbc-bridge with command: /bin/clickhouse odbc-bridge --http-port 9018 --listen-host localhost --http-timeout 1800000000 &
2018.11.20 19:37:52.389558 [ 3 ] {} <Trace> ODBCBridgeHelper: Checking clickhouse-odbc-bridge is running, try 1
2018.11.20 19:37:52.389595 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.399888 [ 3 ] {} <Trace> ODBCBridgeHelper: Checking clickhouse-odbc-bridge is running, try 2
2018.11.20 19:37:52.399962 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.412266 [ 3 ] {} <Trace> ODBCBridgeHelper: Checking clickhouse-odbc-bridge is running, try 3
2018.11.20 19:37:52.412367 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.422751 [ 3 ] {} <Trace> ODBCBridgeHelper: Checking clickhouse-odbc-bridge is running, try 4
2018.11.20 19:37:52.422815 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.430808 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/identifier_quote?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG
2018.11.20 19:37:52.526107 [ 3 ] {} <Trace> ODBCDictionarySource: SELECT "ID", "NAME" FROM "VW_REPORT_RESOURCE";
2018.11.20 19:37:52.526163 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.526615 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG&columns=columns%20format%20version%3A%201%0A2%20columns%3A%0A%60ID%60%20Int64%0A%60NAME%60%20String%0A&max_block_size=8192
2018.11.20 19:37:52.618308 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.618691 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/identifier_quote?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG
2018.11.20 19:37:52.657845 [ 3 ] {} <Trace> ODBCDictionarySource: SELECT "ID", "CODE", "NAME" FROM "VW_REPORT_CURRENCY";
2018.11.20 19:37:52.657901 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.658321 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG&columns=columns%20format%20version%3A%201%0A3%20columns%3A%0A%60ID%60%20UInt64%0A%60CODE%60%20String%0A%60NAME%60%20String%0A&max_block_size=8192
2018.11.20 19:37:52.664179 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.664547 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/identifier_quote?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG
2018.11.20 19:37:52.703757 [ 3 ] {} <Trace> ODBCDictionarySource: SELECT "ID_FROM", "ID_TO", "DATE_START", "DATE_END", "GUID_ORGANISATION", "VALUE" FROM "VW_REPORT_CURRENCY_EXCHANGE";
2018.11.20 19:37:52.703819 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:52.704240 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG&columns=columns%20format%20version%3A%201%0A6%20columns%3A%0A%60ID_FROM%60%20UInt16%0A%60ID_TO%60%20UInt16%0A%60DATE_START%60%20DateTime%0A%60DATE_END%60%20DateTime%0A%60GUID_ORGANISATION%60%20String%0A%60VALUE%60%20String%0A&max_block_size=8192
2018.11.20 19:37:53.261975 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:53.262387 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/identifier_quote?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG
2018.11.20 19:37:53.304316 [ 3 ] {} <Trace> ODBCDictionarySource: SELECT "ID_FROM", "ID_TO", "DATE_START", "DATE_END", "GUID_ORGANISATION", "VALUE" FROM "VW_REPORT_CURRENCY_MARGIN";
2018.11.20 19:37:53.304379 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:53.304803 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG&columns=columns%20format%20version%3A%201%0A6%20columns%3A%0A%60ID_FROM%60%20UInt16%0A%60ID_TO%60%20UInt16%0A%60DATE_START%60%20DateTime%0A%60DATE_END%60%20DateTime%0A%60GUID_ORGANISATION%60%20String%0A%60VALUE%60%20String%0A&max_block_size=8192
2018.11.20 19:37:53.310819 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:53.311180 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/identifier_quote?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG
2018.11.20 19:37:53.353669 [ 3 ] {} <Trace> ODBCDictionarySource: SELECT "GUID", "LANG", "NAME", "NAME_FULL", "NAME_SHORT" FROM "VW_REPORT_GEOGRAPHY";
2018.11.20 19:37:53.353735 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:37:53.354121 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG&columns=columns%20format%20version%3A%201%0A5%20columns%3A%0A%60GUID%60%20String%0A%60LANG%60%20String%0A%60NAME%60%20String%0A%60NAME_FULL%60%20String%0A%60NAME_SHORT%60%20String%0A&max_block_size=8192
2018.11.20 19:38:06.351569 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:38:06.352166 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/identifier_quote?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG
2018.11.20 19:38:06.401071 [ 3 ] {} <Trace> ODBCDictionarySource: SELECT "GUID", "LANG", "ID", "NAME", "NAME_FULL", "NAME_SHORT" FROM "VW_REPORT_ORGANISATION";
2018.11.20 19:38:06.401137 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/ping
2018.11.20 19:38:06.401506 [ 3 ] {} <Trace> ReadWriteBufferFromHTTP: Sending request to http://localhost:9018/?connection_string=DSN%3Dora%3BUID%3Dxxxxxxx%3BPWD%3Dxxxxxxx_md_test%3BHOST%3Dmd10.dev.xxxxxxx.com%3BPORT%3D1521%3BSID%3DGBSTG&columns=columns%20format%20version%3A%201%0A6%20columns%3A%0A%60GUID%60%20String%0A%60LANG%60%20String%0A%60ID%60%20Int64%0A%60NAME%60%20String%0A%60NAME_FULL%60%20String%0A%60NAME_SHORT%60%20String%0A&max_block_size=8192
2018.11.20 19:38:06.876030 [ 3 ] {} <Information> DatabaseOrdinary (busfor_report): 25.00%
2018.11.20 19:38:06.878630 [ 3 ] {} <Information> BackgroundProcessingPool: Create BackgroundProcessingPool with 16 threads
2018.11.20 19:38:06.883312 [ 3 ] {} <Debug> busfor_report.pc_ticket_data_commissions (Data): Loading data parts
2018.11.20 19:38:06.890376 [ 3 ] {} <Debug> busfor_report.pc_ticket_data_commissions (Data): Loaded data parts (1 items)
2018.11.20 19:38:06.893041 [ 3 ] {} <Debug> busfor_report.pc_ticket_data_commissions2 (Data): Loading data parts
2018.11.20 19:38:06.904207 [ 3 ] {} <Debug> busfor_report.pc_ticket_data_commissions2 (Data): Loaded data parts (1 items)
2018.11.20 19:38:06.904473 [ 1 ] {} <Information> DatabaseOrdinary (busfor_report): Starting up tables.
2018.11.20 19:38:06.904703 [ 1 ] {} <Information> DatabaseOrdinary (default): Total 1 tables.
2018.11.20 19:38:06.905059 [ 3 ] {} <Debug> default.test_table (Data): Loading data parts
2018.11.20 19:38:06.905089 [ 3 ] {} <Debug> default.test_table (Data): Loaded data parts (0 items)
2018.11.20 19:38:06.905139 [ 1 ] {} <Information> DatabaseOrdinary (default): Starting up tables.
2018.11.20 19:38:06.905371 [ 1 ] {} <Debug> Application: Loaded metadata.
2018.11.20 19:38:06.905404 [ 1 ] {} <Information> Application: It looks like the process has no CAP_NET_ADMIN capability, 'taskstats' performance statistics will be disabled. It could happen due to incorrect ClickHouse package installation. You could resolve the problem manually with 'sudo setcap cap_net_admin=+ep /usr/bin/clickhouse'. Note that it will not work on 'nosuid' mounted filesystems. It also doesn't work if you run clickhouse-server inside network namespace as it happens in some containers.
2018.11.20 19:38:06.908830 [ 1 ] {} <Information> Application: Listening http://[::]:8123
2018.11.20 19:38:06.909075 [ 1 ] {} <Information> Application: Listening tcp: [::]:9000
2018.11.20 19:38:06.909153 [ 1 ] {} <Information> Application: Listening interserver http: [::]:9009
2018.11.20 19:38:06.909699 [ 1 ] {} <Information> Application: Available RAM = 9.61 GiB; physical cores = 1; threads = 2.
2018.11.20 19:38:06.909712 [ 1 ] {} <Information> Application: Ready for connections.
2018.11.20 19:38:08.912598 [ 21 ] {} <Debug> ConfigReloader: Loading config `/etc/clickhouse-server/config.xml'
2018.11.20 19:41:18.845969 [ 2 ] {} <Information> Application: Received termination signal (Terminated)
2018.11.20 19:41:18.846319 [ 1 ] {} <Debug> Application: Received termination signal.
2018.11.20 19:41:18.846340 [ 1 ] {} <Debug> Application: Waiting for current connections to close.
2018.11.20 19:41:19.432724 [ 1 ] {} <Debug> Application: Closed all listening sockets.
2018.11.20 19:41:19.432765 [ 1 ] {} <Debug> Application: Closed connections.
2018.11.20 19:41:19.433606 [ 1 ] {} <Information> Application: Shutting down storages.
2018.11.20 19:41:19.436027 [ 1 ] {} <Debug> Application: Shutted down storages.
2018.11.20 19:41:19.436834 [ 14 ] {} <Trace> ThreadStatus: Thread 14 exited
2018.11.20 19:41:19.436834 [ 16 ] {} <Trace> ThreadStatus: Thread 16 exited
2018.11.20 19:41:19.436888 [ 8 ] {} <Trace> ThreadStatus: Thread 8 exited
2018.11.20 19:41:19.436973 [ 11 ] {} <Trace> ThreadStatus: Thread 11 exited
2018.11.20 19:41:19.436996 [ 18 ] {} <Trace> ThreadStatus: Thread 18 exited
2018.11.20 19:41:19.437039 [ 13 ] {} <Trace> ThreadStatus: Thread 13 exited
2018.11.20 19:41:19.437059 [ 10 ] {} <Trace> ThreadStatus: Thread 10 exited
2018.11.20 19:41:19.437105 [ 4 ] {} <Trace> ThreadStatus: Thread 4 exited
2018.11.20 19:41:19.437120 [ 9 ] {} <Trace> ThreadStatus: Thread 9 exited
2018.11.20 19:41:19.437181 [ 7 ] {} <Trace> ThreadStatus: Thread 7 exited
2018.11.20 19:41:19.437204 [ 12 ] {} <Trace> ThreadStatus: Thread 12 exited
2018.11.20 19:41:19.437644 [ 17 ] {} <Trace> ThreadStatus: Thread 17 exited
2018.11.20 19:41:19.437649 [ 6 ] {} <Trace> ThreadStatus: Thread 6 exited
2018.11.20 19:41:19.437705 [ 15 ] {} <Trace> ThreadStatus: Thread 15 exited
2018.11.20 19:41:19.437761 [ 5 ] {} <Trace> ThreadStatus: Thread 5 exited
2018.11.20 19:41:19.437832 [ 19 ] {} <Trace> ThreadStatus: Thread 19 exited
2018.11.20 19:41:19.439075 [ 1 ] {} <Debug> Application: Destroyed global context.
2018.11.20 19:41:19.439867 [ 1 ] {} <Information> Application: shutting down
2018.11.20 19:41:19.439878 [ 1 ] {} <Debug> Application: Uninitializing subsystem: Logging Subsystem
2018.11.20 19:41:19.439926 [ 2 ] {} <Information> BaseDaemon: Stop SignalListener thread

@alexey-milovidov
Copy link
Member

Yes, we have confirmed that it is not terminated by default. We will try to find the reason.

@levonet
Copy link
Contributor Author

levonet commented Nov 20, 2018

Ok, I remove this code.

@levonet
Copy link
Contributor Author

levonet commented Nov 22, 2018

@proller @alexey-milovidov @alesapin
И таки шо мне делать с PR?
Тут 2 строчки кода осталось, может посмотрите?

@alexey-milovidov
Copy link
Member

Если сейчас помержить, по получится, что одна из изначальных задач данного PR не решена (остановка odbc-bridge при завершении clickhouse-server). Последние два дня выясняли, почему он не останавливается сам. И в результате, есть такой PR: #3642

@alexey-milovidov
Copy link
Member

Впрочем, так как это было дополнительным пунктом, то просто мержим.

@alexey-milovidov alexey-milovidov merged commit 44034a8 into ClickHouse:master Nov 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants