Skip to content
Snippets Groups Projects
Commit b9498160 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

improve documentation of mysql wrapper and associated tests, remove debug...

improve documentation of mysql wrapper and associated tests, remove debug console output, fail slow queries rather than retrying, and add a statsd counter for failed_query
parent ef441617
No related branches found
No related tags found
No related merge requests found
...@@ -77,7 +77,10 @@ exports.createClient = function(options) { ...@@ -77,7 +77,10 @@ exports.createClient = function(options) {
slowQueryTimer = null; slowQueryTimer = null;
} else { } else {
logger.warn("Query taking more than " + config.get('database.max_query_time_ms') + "ms! reconnecting to mysql"); logger.warn("Query taking more than " + config.get('database.max_query_time_ms') + "ms! reconnecting to mysql");
queryQueue.unshift(work); // we'll fail the long running query, because we cannot
// meaningfully know whether or not it completed in the case where
// the driver is unresponsive.
invokeCallback(work.cb, "database connection unavailable");
self._resetConnection(); self._resetConnection();
slowQueryTimer = null; slowQueryTimer = null;
self._runNextQuery(); self._runNextQuery();
...@@ -93,9 +96,13 @@ exports.createClient = function(options) { ...@@ -93,9 +96,13 @@ exports.createClient = function(options) {
slowQueryTimer = null; slowQueryTimer = null;
consecutiveFailures = 0; consecutiveFailures = 0;
// report query time for all queries via statsd
var reqTime = new Date - work.startTime; var reqTime = new Date - work.startTime;
statsd.timing('query_time', reqTime); statsd.timing('query_time', reqTime);
// report failed queries via statsd
if (err) statsd.increment('failed_query');
invokeCallback(work.cb, err, r); invokeCallback(work.cb, err, r);
self._runNextQuery(); self._runNextQuery();
}); });
......
...@@ -24,7 +24,6 @@ exports.i18n = false; ...@@ -24,7 +24,6 @@ exports.i18n = false;
exports.process = function(req, res) { exports.process = function(req, res) {
// first let's verify that the assertion is valid // first let's verify that the assertion is valid
primary.verifyAssertion(req.body.assertion, function(err, email) { primary.verifyAssertion(req.body.assertion, function(err, email) {
console.log("MOTHERFUCKER", err);
if (err) { if (err) {
return res.json({ return res.json({
success: false, success: false,
......
...@@ -46,6 +46,14 @@ function addStallDriverBatch(stall) { ...@@ -46,6 +46,14 @@ function addStallDriverBatch(stall) {
topic: function() { topic: function() {
if (stall) fs.writeFileSync(stallFile, ""); if (stall) fs.writeFileSync(stallFile, "");
else fs.unlinkSync(stallFile); else fs.unlinkSync(stallFile);
// After changing the file which indicates to child
// processes whether the driver should simulate a stalled
// state or not, we need to wait for them to detect the
// change. because we use `fs.watchFile()` on a short poll,
// this should be nearly instantaneous. 300ms is a magic number
// which is hoped to allow plenty of time even on a loaded
// machine
setTimeout(this.callback, 300); setTimeout(this.callback, 300);
}, },
"completes": function(err, r) { } "completes": function(err, r) { }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment