APE-Project/APE_Server — Issue #19: Server crashes within 5 minutes running MySQL queries every 5 seconds
Author: awysocki
Created: 2011-12-21 22:02:32+00:00
State: open

Run this script with valgrind and the APE server crashes in 5 minutes or less

valgrind --leak-check=full --track-origins=yes --show-reachable=yes -v ./aped >a.out 2>b.out

// =============Start of Script ========================
Ape.log(' =====================================>>> Start up for mysql_test.js ' );

var dbbm = new Ape.MySQL( "1.1.1.1:3306", "mysql", "mysql", "events" );

var events_Chan = false;
var events_timeoutID;

//------------------------------------------
Ape.addEvent("mkchan", function(chan) {

var cj = chan.getProperty('name');
Ape.log("New channel => " + cj );

switch( cj )
{
case '*events':
Ape.log( 'Starting EVENTS thread at 5 seconds' );
events_timeoutID = Ape.setInterval(EventsTick, 5000, chan );
break;
}

Ape.join( cj );
});

//------------------------------------------
Ape.addEvent("join", function(user, channel) {
Ape.log("New user has joined the channel (" + channel.getProperty('name') + ")");
// Do nothing this is just a crash test
});

//------------------------------------------
dbbm.onConnect = function() {
Ape.log('Connected to mysql server, Creating *events channel');
events_Chan = Ape.mkChan('*events');
}

//------------------------------------------
dbbm.onError = function(errorNo) {
Ape.log('Connection Error : ' + errorNo + ' : '+ this.errorString());
}

//------------------------------------------
function
EventsTick( _chan )
{
var SQL = 'SELECT * ' +
'FROM events '+
'LIMIT 25';

dbbm.query( SQL , function(res, errorNo) {
if (errorNo)
{
Ape.log('Request error : ' + errorNo + ' : '+ this.errorString());
}
else
{
Ape.log('Fetched => ' + res.length + ' ROWS');
Ape.log( "SQL completed" );
}

});
}

// ===================== END OF SCRIPT =================

There is a memory leak in the MYSQL code I can help and test with anything, this get this bug fixed