Skip to content

Instantly share code, notes, and snippets.

@wzrdtales
Last active September 20, 2015 12:45
Show Gist options
  • Save wzrdtales/3f2b1ee877d689f3916b to your computer and use it in GitHub Desktop.
Save wzrdtales/3f2b1ee877d689f3916b to your computer and use it in GitHub Desktop.
test case to crash mariasql
var mariasql = require('mariasql');
var pool = [];
function create() {
var connection = new mariasql();
connection.connect({
"host": "localhost",
"port": 3306,
"user": "root",
"password": "somepassword",
"db": "somedb",
"multiStatements": true
});
connection.on('connect', function() {
connection._end = connection.end;
function end() {
if( !connection._failed ) {
pool.push(this);
query();
}
else {
//drop and continuing here is going to crash
query();
}
}
connection.end = end;
pool.push(connection);
query();
})
.on('error', function() {
connection._failed = true;
connection.end();
});
}
function query() {
var con
if( pool.length > 0 ) {
con = pool.pop();
}
else {
create();
return;
}
con.query('SELECT SLEEP(25)')
.on('result', function() {
con.end();
})
.on('error', function(err){
console.log(err)
con._failed = true;
con.end();
});
}
create();
create();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment