CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • 502 on donation page submission
Pages: [1]

Author Topic: 502 on donation page submission  (Read 2068 times)

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
502 on donation page submission
June 30, 2010, 08:48:28 am
I'm using Drupal 6.16/CiviCRM 3.14 with about 120,000 contacts.

Recently I've just installed SSL and configured a contribution page (Using dummy payment processor). However, I'm getting a 502 Proxy error whenever I submit click submit on the final step. It looks like a timeout because it takes a while (probably more than 30 seconds then throws the error). No contribution is recorded.

This happens on both the http and https protocol and it seems like it is related to the amount of contacts in the database, I have another site setup exactly the same with a live payment processor but only with about 100 contacts and it is running fine.

I'm also getting the 502 error when performing other operations such as trying to merge 3 or more contacts from the contact search result screen (usually it should take me to the deduping screen)
Once again this does not happen on the installation with less contacts.


My hosting environment is as follows:

Rackspace cloud hosting:
512 MB memory
Apache 2.2/PHP 5.26

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 502 on donation page submission
July 02, 2010, 06:10:51 am

so i loaded the db on a local machine. the contribution with a dummy processor went real quick. (while i was tabbing to see the mysql query log the contribution completed, so a few seconds or so at the most)

i then tried the merge scenario and ran into the issue. here is the query and am not sure how to optimize

Code: [Select]
CREATE TEMPORARY TABLE dedupe SELECT t1.id id1, t2.id id2, 5 weight FROM civicrm_contact t1 JOIN civicrm_contact t2 USING (first_name) WHERE t1.id < t2.id AND t1.first_name IS NOT NULL AND (t1.id IN (2,3,4) OR t2.id IN (2,3,4)) UNION ALL SELECT t1.id id1, t2.id id2, 7 weight FROM civicrm_contact t1 JOIN civicrm_contact t2 USING (last_name) WHERE t1.id < t2.id AND t1.last_name IS NOT NULL AND (t1.id IN (2,3,4) OR t2.id IN (2,3,4)) UNION ALL SELECT t1.contact_id id1, t2.contact_id id2, 10 weight FROM civicrm_email t1 JOIN civicrm_email t2 USING (email) WHERE t1.contact_id < t2.contact_id AND t1.email IS NOT NULL AND (t1.contact_id IN (2,3,4) OR t2.contact_id IN (2,3,4))

basically the 3 sub selects (like the below) take forever:

Code: [Select]
SELECT t1.id id1, t2.id id2, 7 weight
FROM civicrm_contact t1 JOIN civicrm_contact t2 ON t1.last_name = t2.last_name
WHERE t1.id < t2.id AND t1.last_name IS NOT NULL AND
(t1.id IN (2,3,4) OR t2.id IN (2,3,4));

the contact db has 188K contacts. wondering if we should do the same trick as the export stuff and put those ids in a temp table and do an inner join early on to restrict the contact id set early on in the process. a bit wierd that it seems to be checking the entire table (else it should not take so long, IMO)

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
Re: 502 on donation page submission
July 02, 2010, 08:15:40 am
Hi Lobo,

Just on a side note, probably due to my own ignorance, but why is there such complicated de-duping query for creating contribution?

is it not possible to do something like

Code: [Select]
select c.id FROM civicrm_contact c JOIN civicrm_email e ON c.id = e.contact_id
where email = 'email@address.com' and first_name = First name' and last_name = 'Last name'

I guess because it is using the de-duping engine so it is consistent throughout the system?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 502 on donation page submission
July 02, 2010, 10:18:23 am

1. the problem is a wee bit complicated due to the fact that the dedupe rules are flexible and hence the abstraction. There are also the weights to be considered and coming up with a total count etc

2. an abstraction does not mean that we cannot optimize a common use case :) however as i mentioned the contribution page proceeded really quickly even with the large DB. i checked the query log and here is what i got:

Code: [Select]
CREATE TEMPORARY TABLE dedupe SELECT contact_id id, 10 weight FROM civicrm_email WHERE email = 'chints@example.com'
SELECT dedupe.id
FROM dedupe JOIN civicrm_contact USING (id)
WHERE contact_type = 'Individual'
GROUP BY dedupe.id HAVING SUM(weight) >= 10
ORDER BY SUM(weight) desc


the above does run fairly fast on my local labtop (4 year old macbook pro)

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 502 on donation page submission
July 06, 2010, 05:17:54 am
Quote from: Donald Lobo on July 02, 2010, 06:10:51 am
Code: [Select]
SELECT t1.id id1, t2.id id2, 7 weight
FROM civicrm_contact t1 JOIN civicrm_contact t2 ON t1.last_name = t2.last_name
WHERE t1.id < t2.id AND t1.last_name IS NOT NULL AND
(t1.id IN (2,3,4) OR t2.id IN (2,3,4));

The above query can be sped up significantly by rewriting it as follows:

Code: [Select]
SELECT t1.id id1, t2.id id2, 7 weight
FROM civicrm_contact t1 JOIN civicrm_contact t2 ON t1.last_name = t2.last_name
WHERE t1.id < t2.id AND t1.last_name IS NOT NULL AND
t1.id IN (2,3,4)
UNION
SELECT t1.id id1, t2.id id2, 7 weight
FROM civicrm_contact t1 JOIN civicrm_contact t2 ON t1.last_name = t2.last_name
WHERE t1.id < t2.id AND t1.last_name IS NOT NULL AND
t2.id IN (2,3,4)
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 502 on donation page submission
July 06, 2010, 06:00:53 am
Quote from: xcf33 on June 30, 2010, 08:48:28 am
I'm also getting the 502 error when performing other operations such as trying to merge 3 or more contacts from the contact search result screen (usually it should take me to the deduping screen)

Hey changx:

can you try the following attached patch and see if that fixes your issue. thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
Re: 502 on donation page submission
July 06, 2010, 07:53:27 am
Thanks lobo I'll get back to you!


Chang

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
Re: 502 on donation page submission
July 12, 2010, 03:26:21 pm
Hi Lobo,

We are still having the 502 issues despite of the SQL optimizations. :(

Chang

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
Re: 502 on donation page submission
July 22, 2010, 02:34:55 pm
The plot thickens,

So what I have done from the last time:

Cleaned out around 55,000 blank organization contacts

Created another donation page with dummy processor with test payment gateway configurations


The donation processing time in total for the dummy processor was lightning fast (within 2 seconds from confirmation page to thank you page)

So I have concluded that it must be a payment processor code right?

But no,

So I wrote the time (using date function) before each function call etc in the do_direct_payment function in the payment processor file for our custom payment processor. I consistently got 2 seconds or less for the entire process.

Using the Devel module in drupal, I logged it only takes about 60 millsecs for all the queries.


All this doesn't add up to a processing time of around 30 seconds to me.


I guess the next step is to record time from the contribution processing code itself, any idea where to insert the timestamp?




P.S. we have one person in the office with I.E 7 consistently gets the 502. In other browsers this happens from time to time.

Could it be the SSL version and incompatibility between SSL provider and our host? We purchased SSL from a third party and not directly from our hosting company.


Chang

« Last Edit: July 22, 2010, 02:38:35 pm by xcf33 »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 502 on donation page submission
July 22, 2010, 07:16:09 pm

CRM/Contribute/Form/Contribution/Confirm.php

add the time call to the beginning and end of postProcess and maybe in between too :)

there are 2 network calls in there:

a. to the payment processor
b. to the smtp server

either of them might also cause an issue with your 30 second limit, so might want to check those also

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
Re: 502 on donation page submission
July 22, 2010, 09:54:29 pm
Ha, that was very inspirational Lobo,

I actually might now know what's causing this. (But of course I'll have to confirm).


Our SMTP server has some problem with CiviCRM.

We we do our mailing, at send test mailing step, from time to time we would get the 502 (or time out after 30 seconds, even though the test mail would be sent out)
Other times we get a time out when trying to access SMTP settings page.

This also happens with send email from the activity menu.



The only difference between this installation and the other one we have (Which has the same payment gateway) is that the other one uses localhost for SMTP because we do not do bulk mailing on that one.



Let me disable thank you email and see if this problem still persist. If this is the problem I think I can nail down and diagnose why the SMTP call takes a long time



Thanks a lot


Chang

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • 502 on donation page submission

This forum was archived on 2017-11-26.