As per this link https://node-postgres.com/apis/cursor , cursor will return empty result so we can stop.
But we have found that under huge load, when postgres closes connection or throws an error due to deadlock, cursor returns empty result. This happens rarely and out of 100 thousand of transactions, approx 20 to 80 transactions fail when cursor returns empty results, but results are sure there.
This occurs only under huge load. Under moderate or low load, everything works fine.
async *next(min = 100) {
const connection = await this.connection.getConnection(this.signal);
const q = toQuery(this.command);
const cursor = this.cursor = connection.query(new Cursor(q.text, q.values));
do {
const rows = await cursor.read(min);
yield *rows;
if (rows.length === 0) {
break;
}
} while (true);
}
Do I need to add error handler here as well?
Unfortunately I cannot create a stressed environment that results in similar situation.
As per this link https://node-postgres.com/apis/cursor , cursor will return empty result so we can stop.
But we have found that under huge load, when postgres closes connection or throws an error due to deadlock, cursor returns empty result. This happens rarely and out of 100 thousand of transactions, approx 20 to 80 transactions fail when cursor returns empty results, but results are sure there.
This occurs only under huge load. Under moderate or low load, everything works fine.
Do I need to add error handler here as well?
Unfortunately I cannot create a stressed environment that results in similar situation.