[IMPROVED] More SQL logging on failed DB events in crons

This commit is contained in:
Sebastian Grewe 2013-11-07 15:58:12 +01:00
parent ae0f2cf082
commit 98259e786c
3 changed files with 16 additions and 16 deletions

View File

@ -175,7 +175,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
foreach ($aRoundAccountShares as $key => $aRoundData) {
if ($aRoundData['username'] == $aData['username'])
if (!$statistics->updateShareStatistics($aRoundData, $aBlock['id']))
$log->logError('Failed to update share statistics for ' . $aData['username']);
$log->logError('Failed to update share statistics for ' . $aData['username'] . ': ' . $statistics->getCronError());
}
// Add PPLNS share statistics
@ -183,25 +183,25 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
if ($aRoundData['username'] == $aData['username']){
if (@$statistics->getIdShareStatistics($aRoundData, $aBlock['id'])){
if (!$statistics->updatePPLNSShareStatistics($aRoundData, $aBlock['id']))
$log->logError('Failed to update pplns statistics for ' . $aData['username']);
$log->logError('Failed to update pplns statistics for ' . $aData['username'] . ': ' . $statistics->getCronError());
} else {
if (!$statistics->insertPPLNSShareStatistics($aRoundData, $aBlock['id']))
$log->logError('Failed to insert pplns statistics for ' . $aData['username']);
$log->logError('Failed to insert pplns statistics for ' . $aData['username'] . ': ' . $statistics->getCronError());
}
}
}
// Add new credit transaction
if (!$transaction->addTransaction($aData['id'], $aData['payout'], 'Credit', $aBlock['id']))
$log->logFatal('Failed to insert new Credit transaction to database for ' . $aData['username']);
$log->logFatal('Failed to insert new Credit transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
// Add new fee debit for this block
if ($aData['fee'] > 0 && $config['fees'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['fee'], 'Fee', $aBlock['id']))
$log->logFatal('Failed to insert new Fee transaction to database for ' . $aData['username']);
$log->logFatal('Failed to insert new Fee transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
// Add new donation debit
if ($aData['donation'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['donation'], 'Donation', $aBlock['id']))
$log->logFatal('Failed to insert new Donation transaction to database for ' . $aData['username']);
$log->logFatal('Failed to insert new Donation transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
}
// Store this blocks height as last accounted for
@ -209,7 +209,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
// Move counted shares to archive before this blockhash upstream share
if (!$share->moveArchive($iCurrentUpstreamId, $aBlock['id'], $iPreviousShareId))
$log->logError('Failed to copy shares to archive table: ' . $share->getCronError());
$log->logError('Failed to copy shares to archive table: ' . $share->getCronError() . ': ' . $share->getCronError());
// Delete all accounted shares
if (!$share->deleteAccountedShares($iCurrentUpstreamId, $iPreviousShareId)) {
$log->logFatal("Failed to delete accounted shares from $iPreviousShareId to $iCurrentUpstreamId, aborting! Error: " . $share->getCronError());

View File

@ -105,15 +105,15 @@ foreach ($aAccountShares as $aData) {
// Add new credit transaction
if (!$transaction->addTransaction($aData['id'], $aData['payout'], 'Credit_PPS'))
$log->logError('Failed to add Credit_PPS transaction in database');
$log->logError('Failed to add Credit_PPS transaction in database: ' . $transaction->getCronError());
// Add new fee debit for this block
if ($aData['fee'] > 0 && $config['fees'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['fee'], 'Fee_PPS'))
$log->logError('Failed to add Fee_PPS transaction in database');
$log->logError('Failed to add Fee_PPS transaction in database: ' . $transaction->getCronError());
// Add new donation debit
if ($aData['donation'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['donation'], 'Donation_PPS'))
$log->logError('Failed to add Donation_PPS transaction in database');
$log->logError('Failed to add Donation_PPS transaction in database: ' . $transaction->getCronError());
}
// Store our last inserted ID for the next run
@ -141,12 +141,12 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
$aAccountShares = $share->getSharesForAccounts(@$iLastBlockShare, $aBlock['share_id']);
foreach ($aAccountShares as $key => $aData) {
if (!$statistics->updateShareStatistics($aData, $aBlock['id']))
$log->logError("Failed to update stats for this block on : " . $aData['username']);
$log->logError("Failed to update stats for this block on : " . $aData['username'] . ': ' . $statistics->getCronError());
}
// Move shares to archive
if ($aBlock['share_id'] < $iLastShareId) {
if (!$share->moveArchive($aBlock['share_id'], $aBlock['id'], @$iLastBlockShare))
$log->logError("Failed to copy shares to archive: " . $share->getCronError());
$log->logError("Failed to copy shares to archive: " . $share->getCronError() . ': ' . $share->getCronError());
}
// Delete shares
if ($aBlock['share_id'] < $iLastShareId && !$share->deleteAccountedShares($aBlock['share_id'], $iLastBlockShare)) {

View File

@ -86,18 +86,18 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
// Update user share statistics
if (!$statistics->updateShareStatistics($aData, $aBlock['id']))
$log->logFatal('Failed to update share statistics for ' . $aData['username']);
$log->logFatal('Failed to update share statistics for ' . $aData['username'] . ': ' . $statistics->getCronError());
// Add new credit transaction
if (!$transaction->addTransaction($aData['id'], $aData['payout'], 'Credit', $aBlock['id']))
$log->logFatal('Failed to insert new Credit transaction to database for ' . $aData['username']);
$log->logFatal('Failed to insert new Credit transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
// Add new fee debit for this block
if ($aData['fee'] > 0 && $config['fees'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['fee'], 'Fee', $aBlock['id']))
$log->logFatal('Failed to insert new Fee transaction to database for ' . $aData['username']);
$log->logFatal('Failed to insert new Fee transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
// Add new donation debit
if ($aData['donation'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['donation'], 'Donation', $aBlock['id']))
$log->logFatal('Failed to insert new Donation transaction to database for ' . $aData['username']);
$log->logFatal('Failed to insert new Donation transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
}
// Add block as accounted for into settings table