0

バックエンドでoracle を使用node-oracledbしており、接続プールを使用してパフォーマンスを向上させたいと考えています。

 oracledb.createPool({
            poolAlias:      'default',
            connectString:  connectString,
            user:           user,
            password:       password,
            poolMin:        poolMin,
            poolMax:        poolMax
        }).then(conpool => {
                console.log('Connection Pool created!');
            },
            err => {
                console.log('Error creating pool! Error:');
                throw err;
            });

次のような接続を使用します。

public async execute (sql: string, data: object, options: object): Promise<any[]> {
    try {
        const con = await this.getConnection();
        try {
            console.log(sql);
            const result = await con.execute(sql, data, { outFormat: oracledb.OBJECT, ...options });

            return result.rows;
        } finally {
            con.release();
        }
    } catch (ex) {
        console.log(`database.execute exception: ${ex.message}`);
        throw ex;
    }
}

現在、定期的に次のエラーが発生しています。

ORA-02396: 最大アイドル時間を超えました

IDLE_TIMEセキュリティ上の理由からおそらく に設定されていないに関係していると仮定しますUNLIMITED(正直に言うと、これはよくわかりません)。

接続を維持する他の方法はありますか? つまり、nodejs はシングル スレッドであるため、定期的にダミー クエリを単純に実行することはできませんか?

4

1 に答える 1