Query/Exec hangs when there are external network latency
- Dominant language
- Go
- Stars
- 190
- Forks
- 65
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 10
Description
query and exec calls hangs indefinitely when external network latency was introduced.
Steps to reproduce.
script:
```
import sql from "k6/x/sql";
// the actual database driver should be used instead of ramsql
import driver from "k6/x/sql/driver/mysql";
const db = sql.open(driver, "some-db");
export function setup() {
db.exec(`
CREATE TABLE IF NOT EXISTS roster
(
id INTEGER NOT NULL AUTOINCREMENT,
given_name VARCHAR NOT NULL,
family_name VARCHAR NOT NULL,
PRIMARY KEY (ID)
);
`);
}
export function teardown() {
db.close();
}
export default function () {
let result = db.exec(`
INSERT INTO roster_2
(given_name, family_name)
VALUES
('Peter', 'Pan'),
('Wendy', 'Darling'),
('Tinker', 'Bell'),
('James', 'Hook');
`);
console.log(`${result.rowsAffected()} rows inserted`);
let rows = db.query("SELECT * FROM roster WHERE given_name = $1;", "Peter");
for (const row of rows) {
console.log(`${row.family_name}, ${row.given_name}`);
}
}
```
- start mysql locally.
- ./k6 run --vus 10 --duration 60s ./example.js
- kill -SIGSTOP 76699
- Wait for query/vu to run indefinitely
We have a fix on our fork https://github.com/sharathjag/xk6-sql/blob/conn-options-with-timeouts/sql/module.go#L275
Happy to refine and open PR if the general direction makes sense. Please, keep me posted.
Also see: https://github.com/grafana/k6/issues/3958#issuecomment-2672882779
Contributor guide
Assessment
This issue has not been assessed yet.