Skip to content

Instantly share code, notes, and snippets.

@johnskopis
Created December 13, 2018 12:35
Show Gist options
  • Save johnskopis/c2f661dee3b1e5a79b636ca038d254f9 to your computer and use it in GitHub Desktop.
Save johnskopis/c2f661dee3b1e5a79b636ca038d254f9 to your computer and use it in GitHub Desktop.
root@36s412:/# lsof -np 170
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
clickhous 170 root cwd DIR 0,39 66 134283042 /
clickhous 170 root rtd DIR 0,39 66 134283042 /
clickhous 170 root txt REG 0,39 228615952 268582647 /usr/bin/clickhouse
clickhous 170 root mem REG 253,0 268582647 /usr/bin/clickhouse (path dev=0,51)
clickhous 170 root mem REG 253,0 268655184 /lib/x86_64-linux-gnu/libnss_dns-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268465 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.2 (path dev=0,51)
clickhous 170 root mem REG 253,0 268471 /usr/lib/x86_64-linux-gnu/libhogweed.so.4.3 (path dev=0,51)
clickhous 170 root mem REG 253,0 268490 /usr/lib/x86_64-linux-gnu/libnettle.so.6.3 (path dev=0,51)
clickhous 170 root mem REG 253,0 268545 /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.3 (path dev=0,51)
clickhous 170 root mem REG 253,0 268655168 /lib/x86_64-linux-gnu/libidn.so.11.6.16 (path dev=0,51)
clickhous 170 root mem REG 253,0 268496 /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.2.0 (path dev=0,51)
clickhous 170 root mem REG 253,0 2473 /lib/x86_64-linux-gnu/libz.so.1.2.8 (path dev=0,51)
clickhous 170 root mem REG 253,0 268467 /usr/lib/x86_64-linux-gnu/libgnutls.so.30.13.1 (path dev=0,51)
clickhous 170 root mem REG 253,0 268503 /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25 (path dev=0,51)
clickhous 170 root mem REG 253,0 268483 /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.7 (path dev=0,51)
clickhous 170 root mem REG 253,0 268655199 /lib/x86_64-linux-gnu/libresolv-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655170 /lib/x86_64-linux-gnu/libkeyutils.so.1.5 (path dev=0,51)
clickhous 170 root mem REG 253,0 268479 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1 (path dev=0,51)
clickhous 170 root mem REG 253,0 2366 /lib/x86_64-linux-gnu/libcom_err.so.2.1 (path dev=0,51)
clickhous 170 root mem REG 253,0 268475 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1 (path dev=0,51)
clickhous 170 root mem REG 253,0 268477 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3 (path dev=0,51)
clickhous 170 root mem REG 253,0 268651207 /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.1 (path dev=0,51)
clickhous 170 root mem REG 253,0 268486 /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.7 (path dev=0,51)
clickhous 170 root mem REG 253,0 268469 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2 (path dev=0,51)
clickhous 170 root mem REG 253,0 268453 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (path dev=0,51)
clickhous 170 root mem REG 253,0 268509 /usr/lib/x86_64-linux-gnu/libssl.so.1.1 (path dev=0,51)
clickhous 170 root mem REG 253,0 268651400 /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0 (path dev=0,51)
clickhous 170 root mem REG 253,0 268651406 /usr/lib/x86_64-linux-gnu/libpq.so.5.9 (path dev=0,51)
clickhous 170 root mem REG 253,0 402876647 /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655186 /lib/x86_64-linux-gnu/libnss_files-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655190 /lib/x86_64-linux-gnu/libnss_nis-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655180 /lib/x86_64-linux-gnu/libnsl-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655182 /lib/x86_64-linux-gnu/libnss_compat-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655152 /lib/x86_64-linux-gnu/libc-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655171 /lib/x86_64-linux-gnu/libm-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655201 /lib/x86_64-linux-gnu/librt-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655158 /lib/x86_64-linux-gnu/libdl-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268655195 /lib/x86_64-linux-gnu/libpthread-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 268461 /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4 (path dev=0,51)
clickhous 170 root mem REG 253,0 268655143 /lib/x86_64-linux-gnu/ld-2.24.so (path dev=0,51)
clickhous 170 root mem REG 253,0 402666069 /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache (path dev=0,51)
clickhous 170 root 0r FIFO 0,11 0t0 1290493806 pipe
clickhous 170 root 1w FIFO 0,11 0t0 1290493807 pipe
clickhous 170 root 2w FIFO 0,11 0t0 1290493808 pipe
clickhous 170 root 3u IPv4 1290546673 0t0 TCP 127.0.0.1:9018 (LISTEN)
clickhous 170 root 4u IPv4 1300714727 0t0 TCP 127.0.0.1:9018->127.0.0.1:40088 (CLOSE_WAIT)
clickhous 170 root 5u IPv4 1301200999 0t0 TCP 127.0.0.1:9018->127.0.0.1:62128 (ESTABLISHED)
clickhous 170 root 6w REG 0,39 50908 268680809 /170.log
clickhous 170 root 7u IPv4 1290561553 0t0 TCP 10.36.63.5:33046->10.36.22.26:5432 (ESTABLISHED)
clickhous 170 root 8r FIFO 0,11 0t0 1290546654 pipe
clickhous 170 root 9w FIFO 0,11 0t0 1290546654 pipe
clickhous 170 root 10u IPv4 1416597866 0t0 TCP 127.0.0.1:9018->127.0.0.1:49800 (CLOSE_WAIT)
clickhous 170 root 11u IPv4 1416592236 0t0 TCP 127.0.0.1:9018->127.0.0.1:50248 (CLOSE_WAIT)
clickhous 170 root 12u IPv4 1416605120 0t0 TCP 127.0.0.1:9018->127.0.0.1:50888 (CLOSE_WAIT)
clickhous 170 root 13u IPv4 1416601378 0t0 TCP 127.0.0.1:9018->127.0.0.1:51190 (CLOSE_WAIT)
clickhous 170 root 14u IPv4 1417384842 0t0 TCP 127.0.0.1:9018->127.0.0.1:42914 (CLOSE_WAIT)
clickhous 170 root 15u a_inode 0,12 0 14270 [eventpoll]
root@36s412:/# ^C
root@36s412:/# vim pmp
bash: vim: command not found
root@36s412:/# vi pmp
(failed reverse-i-search)`gba': cat /170.lo^C
(failed reverse-i-search)`BA': ^C
root@36s412:/# bash -x pmp 170 10
+ nsamples=10
+ sleeptime=0
+ pid=170
+ awk '
BEGIN { s = ""; }
/^Thread/ { print s; s = ""; }
/^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
END { print s }'
++ seq 1 10
+ sort
+ sort -r -n -k 1,1
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ uniq -c
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
60 __lll_lock_wait,pthread_mutex_lock,__gthread_mutex_lock,<Poco::ConsoleChannel::_mutex>),<Poco::ConsoleChannel::_mutex>),<Poco::ConsoleChannel::_mutex>),this=<synthetic,(),DB::OwnFormattingChannel::logExtended(DB::ExtendedLogMessage,DB::OwnSplitChannel::log(Poco::Message,Poco::Logger::log,this=<optimized,(),Poco::Net::HTTPServerConnection::run(),Poco::Net::TCPServerConnection::start(),Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
10 write,_IO_file_write,??,_IO_file_xsputn,fwrite,std::basic_streambuf<char,,>,>,std::operator<<,(),DB::OwnFormattingChannel::logExtended(DB::ExtendedLogMessage,DB::OwnSplitChannel::log(Poco::Message,Poco::Logger::log,this=0x7fe7efc0acc0),(),Poco::Net::HTTPServerConnection::run(),Poco::Net::TCPServerConnection::start(),Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
10 read,DB::ReadBufferFromFileDescriptor::nextImpl(),DB::ReadBuffer::next,at,at,Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
10 pthread_cond_wait@@GLIBC_2.3.2,__gthread_cond_wait,__lock=...),std::condition_variable::wait<Poco::Event::wait()::<lambda()>,at,Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
10 pthread_cond_wait@@GLIBC_2.3.2,__gthread_cond_wait,__lock=...),std::condition_variable::wait<BaseDaemon::waitForTerminationRequest()::<lambda()>,at,DB::ODBCBridge::main(std::vector<std::__cxx11::basic_string<char,,Poco::Util::Application::run(),Poco::Util::ServerApplication::run,(),mainEntryClickHouseODBCBridge(int,,main,__libc_start_main,_start
10 pthread_cond_timedwait@@GLIBC_2.3.2,__gthread_cond_timedwait,1000000000l>,1000000000l>,int,,std::ratio<1,,at,Poco::Event::tryWait,at,Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
10 pthread_cond_timedwait@@GLIBC_2.3.2,__gthread_cond_timedwait,1000000000l>,1000000000l>,int,,std::ratio<1,,at,Poco::Event::tryWait,at,Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
10 epoll_wait,Poco::Net::SocketImpl::poll(Poco::Timespan,Poco::Net::Socket::poll,at,Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1
root@36s412:/# bash -x pmp 170
+ nsamples=1
+ sleeptime=0
+ pid=170
+ awk '
BEGIN { s = ""; }
/^Thread/ { print s; s = ""; }
/^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
END { print s }'
+ sort
+ uniq -c
+ sort -r -n -k 1,1
++ seq 1 1
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
6 __lll_lock_wait,pthread_mutex_lock,__gthread_mutex_lock,<Poco::ConsoleChannel::_mutex>),<Poco::ConsoleChannel::_mutex>),<Poco::ConsoleChannel::_mutex>),this=<synthetic,(),DB::OwnFormattingChannel::logExtended(DB::ExtendedLogMessage,DB::OwnSplitChannel::log(Poco::Message,Poco::Logger::log,this=<optimized,(),Poco::Net::HTTPServerConnection::run(),Poco::Net::TCPServerConnection::start(),Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 write,_IO_file_write,??,_IO_file_xsputn,fwrite,std::basic_streambuf<char,,>,>,std::operator<<,(),DB::OwnFormattingChannel::logExtended(DB::ExtendedLogMessage,DB::OwnSplitChannel::log(Poco::Message,Poco::Logger::log,this=0x7fe7efc0acc0),(),Poco::Net::HTTPServerConnection::run(),Poco::Net::TCPServerConnection::start(),Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 read,DB::ReadBufferFromFileDescriptor::nextImpl(),DB::ReadBuffer::next,at,at,Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 pthread_cond_wait@@GLIBC_2.3.2,__gthread_cond_wait,__lock=...),std::condition_variable::wait<Poco::Event::wait()::<lambda()>,at,Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 pthread_cond_wait@@GLIBC_2.3.2,__gthread_cond_wait,__lock=...),std::condition_variable::wait<BaseDaemon::waitForTerminationRequest()::<lambda()>,at,DB::ODBCBridge::main(std::vector<std::__cxx11::basic_string<char,,Poco::Util::Application::run(),Poco::Util::ServerApplication::run,(),mainEntryClickHouseODBCBridge(int,,main,__libc_start_main,_start
1 pthread_cond_timedwait@@GLIBC_2.3.2,__gthread_cond_timedwait,1000000000l>,1000000000l>,int,,std::ratio<1,,at,Poco::Event::tryWait,at,Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 pthread_cond_timedwait@@GLIBC_2.3.2,__gthread_cond_timedwait,1000000000l>,1000000000l>,int,,std::ratio<1,,at,Poco::Event::tryWait,at,Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 epoll_wait,Poco::Net::SocketImpl::poll(Poco::Timespan,Poco::Net::Socket::poll,at,Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1
root@36s412:/#
root@36s412:/# bash -x pmp 170
+ nsamples=1
+ sleeptime=0
+ pid=170
+ awk '
BEGIN { s = ""; }
/^Thread/ { print s; s = ""; }
/^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
END { print s }'
+ sort
++ seq 1 1
+ uniq -c
+ sort -r -n -k 1,1
+ for x in $(seq 1 $nsamples)
+ gdb -ex 'set pagination 0' -ex 'thread apply all bt' -batch -p 170
+ sleep 0
6 __lll_lock_wait,pthread_mutex_lock,__gthread_mutex_lock,<Poco::ConsoleChannel::_mutex>),<Poco::ConsoleChannel::_mutex>),<Poco::ConsoleChannel::_mutex>),this=<synthetic,(),DB::OwnFormattingChannel::logExtended(DB::ExtendedLogMessage,DB::OwnSplitChannel::log(Poco::Message,Poco::Logger::log,this=<optimized,(),Poco::Net::HTTPServerConnection::run(),Poco::Net::TCPServerConnection::start(),Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 write,_IO_file_write,??,_IO_file_xsputn,fwrite,std::basic_streambuf<char,,>,>,std::operator<<,(),DB::OwnFormattingChannel::logExtended(DB::ExtendedLogMessage,DB::OwnSplitChannel::log(Poco::Message,Poco::Logger::log,this=0x7fe7efc0acc0),(),Poco::Net::HTTPServerConnection::run(),Poco::Net::TCPServerConnection::start(),Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 read,DB::ReadBufferFromFileDescriptor::nextImpl(),DB::ReadBuffer::next,at,at,Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 pthread_cond_wait@@GLIBC_2.3.2,__gthread_cond_wait,__lock=...),std::condition_variable::wait<Poco::Event::wait()::<lambda()>,at,Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 pthread_cond_wait@@GLIBC_2.3.2,__gthread_cond_wait,__lock=...),std::condition_variable::wait<BaseDaemon::waitForTerminationRequest()::<lambda()>,at,DB::ODBCBridge::main(std::vector<std::__cxx11::basic_string<char,,Poco::Util::Application::run(),Poco::Util::ServerApplication::run,(),mainEntryClickHouseODBCBridge(int,,main,__libc_start_main,_start
1 pthread_cond_timedwait@@GLIBC_2.3.2,__gthread_cond_timedwait,1000000000l>,1000000000l>,int,,std::ratio<1,,at,Poco::Event::tryWait,at,Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 pthread_cond_timedwait@@GLIBC_2.3.2,__gthread_cond_timedwait,1000000000l>,1000000000l>,int,,std::ratio<1,,at,Poco::Event::tryWait,at,Poco::Net::TCPServerDispatcher::run(),Poco::PooledThread::run(),Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1 epoll_wait,Poco::Net::SocketImpl::poll(Poco::Timespan,Poco::Net::Socket::poll,at,Poco::ThreadImpl::runnableEntry(void*),execute_native_thread_routine,start_thread,clone
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment