我工作的应用程序在AWS Redshift上运行一系列查询。由于数据量的原因,一些查询需要更长的执行时间。
当我检查服务器上的执行细节时,Redshift上的查询似乎完成了。然而,java应用程序似乎无限期地挂起,没有抛出任何异常,甚至没有终止。
下面是执行查询的代码。
private void execSQLStrings(String[] queries, String dataset, String dbType) throws Exception {
    Connection conn = null;
    if (dbType.equals("redshift")) {
        conn=getRedshiftConnection();
    } else if (dbType.equals("rds")){
        conn=getMySQLConnection();
    }
    Statement stmt=conn.createStatement();
    String qry=null;
    debug("Query Length: " + queries.length);
    for (int ii=0;ii<queries.length;++ii) {
        qry=queries[ii];
        if (dataset != null) {
            qry=qry.replaceAll("DATASET",dataset);
        }
        debug(qry);
        stmt.execute(qry);
    }
    stmt.close();
    conn.close();
}我不能发布我正在运行的查询,但它有多个表连接和group by条件,并且它有一个800m的行表。在服务器上完成查询大约需要7~8分钟。
发布于 2015-12-14 19:06:23
您需要更新DSN超时和/或KeepAlive设置,以确保连接保持活动状态。参考:http://docs.aws.amazon.com/redshift/latest/mgmt/connecting-firewall-guidance.html
https://stackoverflow.com/questions/34213701
复制相似问题