Vor
Vor

Reputation: 35139

psycopg2 hangs when "SELECT" statement executed against information_schema on CentOS vs python 2.6

I have a python script that executes query against postgresql database (RedShift. It runs perfectly fine on my local machine:

Ubuntu 12.10,
python 2.7
psycog.__version__ = '2.5.3 (dt dec pq3 ext)'

But it hangs when I'm executing SOME queries from my prod machine on AWS

CentOS 6.5
Python 2.6
psycog.__version__ = '2.5.3 (dt dec pq3 ext)'

Here is the code:

import psycopg2
con = psycopg2.connect(**{<my_connection_params>}})
curs = con.cursor()

# This works perfectly fine on both machines !!!
curs.execute("""SELECT table_name FROM information_schema.tables
              WHERE table_schema='public' AND table_type='BASE TABLE'""")

# This one hangs on AWS, but works fine from my laptop
curs.execute('select column_name from information_schema.columns')

When I connect to db and run query to see running processes I can see this:

select pid, trim(user_name), starttime, substring(query,1,20)
from stv_recents
where status='Running';

I can see this query.

here is an strace -p:

ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x3aaa00f710}, {0x3ab1027010, [], SA_RESTORER|SA_RESTART, 0x3aaa00f710}, 8) = 0
gettimeofday({1403280035, 826010}, NULL) = 0
rt_sigprocmask(SIG_BLOCK, [PIPE], [], 8) = 0
write(3, "\27\3\1\0 5\351Br$\331\30\00563\v\211f\325\367\210\331\331\253\300\310\240"..., 122) = 122
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
poll([{fd=3, events=POLLIN|POLLERR}], 1, -1) =

Upvotes: 2

Views: 899

Answers (1)

Vor
Vor

Reputation: 35139

It turns out that :

Amazon EC2-Classic instances can handle up to 1500 bytes of data per frame, while Amazon EC2-VPC instances can handle up to 9000 bytes of data per frame. In a mixed environment, we recommend disabling TCP/IP jumbo frames by setting the MTU to 1500 in the Amazon EC2-VPC instance; this way, both instances use 1500 bytes maximum. This is not necessary if both the client and cluster instances use Amazon EC2-VPC.

http://docs.aws.amazon.com/redshift/latest/mgmt/connecting-drop-issues.html

SO this line will solve it:

ip link set dev eth0 mtu 1500

Upvotes: 2

Related Questions