heavydb icon indicating copy to clipboard operation
heavydb copied to clipboard

Exception: connect() fails after a query that needs more than available memory failed for several times

Open fleapapa opened this issue 9 years ago • 8 comments

[UPDATE] To reproduce: Submit a query on a table that needs more than available memory (so it will fail). The table spans 509 files.

Symptom: After the query fails, further query will return "Exception: connect() failed: Connection refused".

At this time, /proc/pidof mapd_server/status shows FDSize max out like below:

$ ps ax|grep mapd_server 19452 pts/9 S+ 0:20 gdb bin/mapd_server 25066 pts/9 tl 0:52 /mnt/mapd-core/bin/mapd_server --data /mnt/trip/mapd/data

$ less /proc/25066/status Name: mapd_server Umask: 0002 State: t (tracing stop) Tgid: 25066 Ngid: 0 Pid: 25066 PPid: 19452 TracerPid: 19452 Uid: 1001 1001 1001 1001 Gid: 1001 1001 1001 1001 FDSize: 1024

Though enlarged ulimit can alleviate the issue, it does not uproot the cause.

fleapapa avatar Oct 18 '17 22:10 fleapapa

As further investigated, 1024 fds were allocated but only 538 fds were in use, so the root cause is not out of file descriptors, though the reason of connection failure is on proto::connect().

Trying to reproduce it...

fleapapa avatar Oct 19 '17 02:10 fleapapa

It turns out to be a "defunct" Calcite server that caused further queries to get "Exception: connect() failed: Connection refused" error after two or three failed queries that need too much memory.

$ ps ax|grep java
23697 pts/9    Z+     0:03 [java] <defunct>

Wondering if Calcite was gone also from OOM.

fleapapa avatar Oct 19 '17 06:10 fleapapa

Possibly the Linux out of memory killer may be the culprit, on a tight memory system like yours, take a look in the system logs.

dwayneberry avatar Oct 19 '17 06:10 dwayneberry

@dwayneberry, thanks. There is no sign of OOM in syslog in last few hours. Besides, my VM has 8GB swap space; it showed no sign of being used. Unlikely Calcite would use as much as mapd_server during that period.

fleapapa avatar Oct 19 '17 06:10 fleapapa

BTW, in my thought, the scenario of running a query of 47GB table on my 14GB VM should be analogous to that of running a query of 4TB table on a system with 1TB memory.

My point is: a SELECT scanning a 47GB table is unusual, but a COPY FROM SELECT scanning on a 47GB table is very common for exporting data.

fleapapa avatar Oct 19 '17 06:10 fleapapa

Can you post the system you are using? I am trying to reproduce the situation. With CentOS, 7.5GB memory and a 55 GB CSV file the system simply freezes and the CPU Usage fall back after a while without the client responding to IO.

RedAlice64 avatar Oct 23 '17 04:10 RedAlice64

Sorry. The version of 'system' i was using when i saw this issue has been heavily changed. Will get back to reproduce this issue later. However, running mapd_server in gdb, i frequently ran into the issue after one or more failed or cancelled "heavy" queries. When that happened, mapd_server was still alive but calcite server had gone.

fleapapa avatar Oct 23 '17 04:10 fleapapa

closing as not reproducible

dwayneberry avatar Nov 19 '17 08:11 dwayneberry