Adamw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/94464
Change subject: WIP wrap each processing call in a db transaction
......................................................................
WIP wrap each processing call in a db transaction
TODO: determine whether the donations db === default db reuses the
connection. Start a transaction on the donations db, either way.
Change-Id: I87f075f6914e4384d16649ca26e1556ea5f4efc2
---
M sites/all/modules/wmf_common/Queue.php
1 file changed, 31 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/64/94464/1
diff --git a/sites/all/modules/wmf_common/Queue.php
b/sites/all/modules/wmf_common/Queue.php
index e694207..0e11e2f 100644
--- a/sites/all/modules/wmf_common/Queue.php
+++ b/sites/all/modules/wmf_common/Queue.php
@@ -74,14 +74,10 @@
watchdog( 'wmf_common', t('Feeding raw queue message to %callback
: %msg', array( '%callback' => print_r($callback, TRUE), '%msg' =>
print_r($msg, TRUE) ) ), NULL, WATCHDOG_INFO );
set_time_limit( 60 );
- try {
- $callback( $msg );
- $processed++;
- }
- catch ( Exception $ex ) {
- watchdog( 'wmf_common', "Aborting dequeue loop after
successfully processing {$processed} messages.", NULL, WATCHDOG_INFO );
- throw $ex;
- }
+
+ $this->call_wrapped( $callback, $msg );
+
+ $processed++;
}
$con->unsubscribe( $queue );
@@ -90,6 +86,33 @@
return $processed;
}
+ /**
+ * Call the message processing callback and perform common error handling
+ *
+ * TODO: move the remaining error handling in here
+ */
+ protected function call_wrapped( $callback, $msg ) {
+ watchdog( 'wmf_common', "Beginning DB transaction", NULL,
WATCHDOG_DEBUG );
+ $drupal_transaction = db_transaction( 'dequeue', array( 'target' =>
'default' ) );
+ //$crm_transaction = db_transaction( 'dequeue', array( 'target' =>
'civicrm' ) );
+ $crm_transaction = new CRM_Core_Transaction();
+
+ try {
+ $callback( $msg );
+ }
+ catch ( Exception $ex ) {
+ watchdog( 'wmf_common', "Aborting DB transaction.", NULL,
WATCHDOG_INFO );
+ $drupal_transaction->rollback();
+ $crm_transaction->rollback();
+
+ throw $ex;
+ }
+
+ watchdog( 'wmf_common', "Committing DB transaction", NULL,
WATCHDOG_DEBUG );
+ $crm_transaction->commit();
+ unset( $drupal_transaction );
+ }
+
function getByCorrelationId( $queue, $correlationId ) {
$con = $this->getFreshConnection();
$properties = array(
--
To view, visit https://gerrit.wikimedia.org/r/94464
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I87f075f6914e4384d16649ca26e1556ea5f4efc2
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits