3
votes

I use amazon redshift and sometimes the query execution hangs without any error messages e.g. this query will execute:

select extract(year from date), extract(week from date),count(*) from some_table  where date>'2015-01-01 00:00:00' and date<'2015-12-31 23:59:59' group by extract(year from date), extract(week from date)

and this not:

select extract(year from date), extract(week from date),count(*) from some_table  where date>'2014-01-01 00:00:00' and date<'2014-12-27 23:59:59' group by extract(year from date), extract(week from date)

But it happens only when I deploy project to server and on my local machine all queries executed without any problems.

I already set in my code autoCommit=true for connection. Also all things listed above I do with grails using this library

        compile 'com.amazonaws:aws-java-sdk-redshift:1.9.39'

Any ideas?

2

2 Answers

5
votes

This might not be an exact answer, but it's too long for a comment.

You may want to check mtu setting on the server where you performing the execution.

Redshift want's to operate on 1500 bytes frame and all EC2 instances are set with jumbo frame by default (9000)

In order for you to run queries without problems you need to have the same mtu setting.

To check what you currently have, run this command:

ip addr show eth0

an example output would be like this:

eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP qlen 1000

in this case mtu is 9001 so you need to change it to 1500 by running:

/sbin/ifconfig eth0 mtu 1500 up

4
votes

I was experiencing this issue when connecting to RedShift from an EC2 Instance. Adjusting the MTU didn't help, so I kept digging and found that the error is linked to TCP timeouts.

Doing the following in the instance that I was using to connect to RedShift fixed the problem:

# echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time

That will change the TCP keepalive from 7200 seconds (default) to 60 seconds.

More information can be found in: http://docs.aws.amazon.com/redshift/latest/mgmt/connecting-firewall-guidance.html