Thursday 4 May 2017

Redshift Connections not closed in proper way

I'm working with redshift with both Java and Node Js. Few time ago found that disconnect event not created on all close connection calls. Java (using redshift.jdbc41 ):

Connection conn = null;
Statement stmt = null;
try {
       ...
} catch (Exception ex){
    throw new Exception("Can't sync raw data from redshift");
}finally {
    try {
        if (stmt != null) {
            stmt.close();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    try {
        if (conn != null) {
            conn.close();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

and Node Js (using pg module) example:

var client = new pg.Client(conString);
client.connect(function (err) {
    if (err) throw err;
    client.query(query, function (err, result) {
        client.end(function (err) {if (err) throw err;});
        ...
    });
});

So after executing query called code to close connection, but in stl_connection_log for part of connections created only initiating session event, but no disconnecting session, so lots of connections holds as active for days, and not resets after client application was stopped.

can somebody advice how to solve this issue? May be required some configs for redshift or another way of working in client application?



via Cuzz

No comments:

Post a Comment