[go: up one dir, main page]

Page MenuHomePhabricator

Expected to find one Contact record, but there were zero
Closed, ResolvedPublic

Description

When doing donation queue consume, found a deleted/merged contact_id will result this error:

civi1002:
/var/log/process-control/donations_queue_consume_sleepy/donations_queue_consume_sleepy-20241205-190201.log
/var/log/process-control/donations_queue_consume/donations_queue_consume-20241206-011701.log
2024-12-06 01:17:42,586 ERROR civicrm.wmf.INFO: DonationQueueConsumer array{"gateway_txn_id":"D5Q3STCBQK2LS3B9","response":false,"gateway_account":"WikimediaDonations","fee":0,"gross":"52.00","contribution_tracking_id":"224275786","country":"US","currency":"USD","email":"xxx@xxx.xxx","first_name":"xxx","gateway":"adyen","language":"en","last_name":"xxx","order_id":"224275786.1","payment_method":"cc","payment_submethod":"visa","postal_code":"xxxxx","recurring":"","street_address":"xxxxxx","user_ip":"67.182.249.254","utm_campaign":"SEC2024_Email1","utm_medium":"endowment","utm_source":"sp74149257.default~default~JimmyQuote~default~control.cc","date":1733447845,"contact_id":"61493355","contact_hash":"b7339f77a30c2573d56aa75a6ff64954","source_name":"DonationInterface","source_type":"payments","source_host":"payments1005","source_run_id":1300362,"source_version":"ab7e70ec7202ef879bc9873c48b9b533c9fc029f","source_enqueued_time":1733447845} {"class_name":"DonationQueueConsumer","message":{"gateway_txn_id":"D5Q3STCBQK2LS3B9","response":false,"gateway_account":"WikimediaDonations","fee":0,"gross":"52.00","contribution_tracking_id":"224275786","country":"US","currency":"USD","email":"xx@xx.xx","first_name":"Jolene","gateway":"adyen","language":"en","last_name":"xx","order_id":"224275786.1","payment_method":"cc","payment_submethod":"visa","postal_code":"xxxxx","recurring":"","street_address":"xxxxxxx","user_ip":"67.182.249.254","utm_campaign":"SEC2024_Email1","utm_medium":"endowment","utm_source":"sp74149257.default~default~JimmyQuote~default~control.cc","date":1733447845,"contact_id":"61493355","contact_hash":"b7339f77a30c2573d56aa75a6ff64954","source_name":"DonationInterface","source_type":"payments","source_host":"payments1005","source_run_id":1300362,"source_version":"ab7e70ec7202ef879bc9873c48b9b533c9fc029f","source_enqueued_time":1733447845}}
2024-12-06 01:17:42,586 ERROR civicrm.wmf.INFO: Beginning DB transaction
2024-12-06 01:17:42,611 ERROR civicrm.wmf.INFO: wmf_common: Aborting DB transaction.
2024-12-06 01:17:42,611 ERROR civicrm.wmf.ERROR: wmf_common: UNHANDLED ERROR. Halting dequeue loop. Exception: Expected to find one Contact record, but there were zero.

https://civicrm.wikimedia.org/civicrm/contact/view?reset=1&cid=61493355&selectedChild=contribute which got merged back to Sep 12, 2024, but when we doing DonationQueueConsumer, we used the deleted contact id instead of the merged one 25478814

Event Timeline

Change #1101088 had a related patch set uploaded (by Wfan; author: Wfan):

[wikimedia/fundraising/crm@master] wip: update contact id if been merged

https://gerrit.wikimedia.org/r/1101088

AKanji-WMF moved this task from Triage to DRI Backlog on the Fundraising-Backlog board.

Change #1101590 had a related patch set uploaded (by Eileen; author: Eileen):

[wikimedia/fundraising/crm@master] Port apiv4 getMergedTo

https://gerrit.wikimedia.org/r/1101590

Change #1101869 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/crm@master] Add test to confirm 'Expected to find one Contact record, but there were zero' bug

https://gerrit.wikimedia.org/r/1101869

Change #1101961 had a related patch set uploaded (by Eileen; author: Eileen):

[wikimedia/fundraising/crm@master] Recover queue when the email is not found

https://gerrit.wikimedia.org/r/1101961

Change #1101961 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Recover queue when the email is not found

https://gerrit.wikimedia.org/r/1101961

jgleeson subscribed.

@Wfan @Eileenmcnaughton I added a test here to confirm the suspected cause of the bug; however, no exception is thrown, or failmail triggered when we try to import a merge/deleted contact ID. I thought this was due to the exception being caught earlier on, but after debugging through the test, we never hit the Expected to find one Contact record, but there were zero. exception, so I don't think the explanation in the ticket is our root cause unless I'm missing something?

Change #1101590 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Port apiv4 getMergedTo

https://gerrit.wikimedia.org/r/1101590

@Eileenmcnaughton @Cstone @Wfan I haven't seen any of these failures over the weekend. Did we fix this one?

I'm still scratching my head as to why we can't simulate the scenario in a test via https://gerrit.wikimedia.org/r/c/wikimedia/fundraising/crm/+/1101869

No failmail due to this patch https://gerrit.wikimedia.org/r/c/wikimedia/fundraising/crm/+/1101961, which we are not sending failmail and recover queue when the email is not found.

XenoRyet set Final Story Points to 4.