1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS, RDS(PostgreSQL), Lambda(Node.JS)の組み合わせで30秒ぐらいコネクションを使っていると落ちる

Last updated at Posted at 2018-09-05

下記のようにしていると落ちる。

'use strict'

var DBDao = require("../utils/dao").DBDao;

class Dummy {
    static async exec(i) {
        console.log("----------------")
        var sql = `select * from sometable;`

        for (var i = 0; i < 1000000; i++) {
            var dao = new DBDao();
            console.log(i);
            var results = await dao.query(sql, []);
                // .then((res) => {
                //     return new Promise(function (resolve, reject) {
                //         // dao.close();
                //         resolve();
                //     });
                // })
            console.log(results.length);
            dao.close();
        }
    }
}

module.exports.Dummy = Dummy;

下記のようなエラーで落ちる。

select * from itemtable; []
248
781
select * from itemtable; []
248
782
select * from itemtable; []
query error Connection terminated by user Error: Connection terminated by user
    at Client.end (/Users/yousan/git/test/node_modules/pg/lib/client.js:402:36)
    at Pool._remove (/Users/yousan/git/test/node_modules/pg-pool/index.js:135:12)
    at Timeout.setTimeout (/Users/yousan/test/node_modules/pg-pool/index.js:38:12)
    at ontimeout (timers.js:460:11)
    at tryOnTimeout (timers.js:298:5)
    at Timer.listOnTimeout (timers.js:261:5)
error:  Error: Connection terminated by user
    at Client.end (/Users/yousan/git/test/node_modules/pg/lib/client.js:402:36)
    at Pool._remove (/Users/yousan/git/test/node_modules/pg-pool/index.js:135:12)
    at Timeout.setTimeout (/Users/yousan/git/test/node_modules/pg-pool/index.js:38:12)
    at ontimeout (timers.js:460:11)
    at tryOnTimeout (timers.js:298:5)
    at Timer.listOnTimeout (timers.js:261:5)

時間を測ると30秒ぐらいでおちている。
引き続き調査中…。

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?