Last active
September 20, 2015 12:45
-
-
Save wzrdtales/3f2b1ee877d689f3916b to your computer and use it in GitHub Desktop.
test case to crash mariasql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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