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 »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • DB Errors after "successful" upgrade to 4.5.2
Pages: [1] 2

Author Topic: DB Errors after "successful" upgrade to 4.5.2  (Read 1761 times)

Rob Hills

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.3
  • MySQL version: 5.6
  • PHP version: 3.0
DB Errors after "successful" upgrade to 4.5.2
November 15, 2014, 07:33:27 pm
Hi All,

I'm very new to CiviCRM so please be gentle!  I have recently taken over management of our organisation's website including CiviCRM and my first admin task was to upgrade CiviCRM to 4.5.2 (from 4.5.1).

I followed the instructions here and everything seemed to go through without a problem.  In particular, running the DB upgrade reported that it had completed successfully.

Our site runs on Drupal and we have separate DBs for Drupal and CiviCRM.

However, since the upgrade we are getting some weird DB errors.  The most obvious one is after logging in to our site, when we get this error message:
Code: [Select]
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'aevaasna_maindrupal.civicrm_group' doesn't exist: SELECT cgr.group_id AS group_id FROM {civicrm_group_roles_rules} cgr INNER JOIN {civicrm_group} cg ON cg.id = cgr.group_id WHERE (cgr.role_id = :db_condition_placeholder_0) AND (cg.saved_search_id IS NULL ) ; Array ( [:db_condition_placeholder_0] => 3 ) in civicrm_group_roles_add_remove_groups() (line 664 of /home/aevaasna/public_html/sites/all/modules/civicrm/drupal/modules/civicrm_group_roles/civicrm_group_roles.module).
Strangely, if I go back to our site home page, I find that I'm logged in.

I've tried googling this error but haven't found anything obviously relevant.  I've also hunted through this forum.  Is there an upgrade log file I can check to ensure there wasn't some error I somehow missed during the upgrade process?  Where else should I look for to try and work out what the problem is?

TIA,

Rob Hills
Waikiki, Western Australia
Rob Hills
Waikiki, Western Australia

sushant

  • I post frequently
  • ***
  • Posts: 126
  • Karma: 8
  • CiviCRM version: v3.2.x,v3.3.x v4.0.x, v4.x,trunk
  • CMS version: Drupal 6/7 ,joomla 1.5,1.6
  • MySQL version: 5.1.51
  • PHP version: 5.3.3
Re: DB Errors after "successful" upgrade to 4.5.2
November 15, 2014, 09:34:58 pm
Similar post : http://forum.civicrm.org/index.php?topic=34734.0

S.
CiviCRM Priority Support
http://support.civigardens.com/
http://osseed.com

Rob Hills

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.3
  • MySQL version: 5.6
  • PHP version: 3.0
Re: DB Errors after "successful" upgrade to 4.5.2
November 16, 2014, 05:34:14 am
Thanks for pointing out that thread, you're correct that it seems to be a very similar problem.

However, as I pointed out in my original post, I have CiviCRM in a separate DB from Drupal (unlike the poster you referred to) and the table concerned does indeed exist where it is supposed to (ie in the CiviCRM DB) but CiviCRM is trying to find it in the wrong DB at this point in the code anyway.

This doesn't seem to be a global DB problem as we've had someone complete a registration online today and their contact details etc have made their way into the CiviCRM DB OK.

Cheers,

Rob Hills
Waikiki, Western Australia
Rob Hills
Waikiki, Western Australia

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: DB Errors after "successful" upgrade to 4.5.2
November 16, 2014, 07:55:38 am

that error is coming from the drupal db layer which is being used by the civicrm_group_roles module.

seems like that module is not aware that civi is in a different db. I'd focous my debugging efforts to that module

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

Rob Hills

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.3
  • MySQL version: 5.6
  • PHP version: 3.0
Re: DB Errors after "successful" upgrade to 4.5.2
November 17, 2014, 10:17:18 am
Thanks for your reply Donald,

OK, so as you've said it seems that the civicrm_group_roles module is not aware that CiviCRM is in a different DB.  I've developed in a number of languages, but never php.  I've hunted through the source code for this module but I've not been able to work out how a module "learns" about the database.  Where do I look for this?

I suspect I should move this discussion over to the civicrm-drupal forum, is that right?

Cheers,

Rob Hills
Waikiki, Western Australia
Rob Hills
Waikiki, Western Australia

Rob Hills

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.3
  • MySQL version: 5.6
  • PHP version: 3.0
Re: DB Errors after "successful" upgrade to 4.5.2
November 17, 2014, 10:58:47 am
OK, delving further into the code turns up civitest.module.sample which I'm guessing should show the "approved" way to execute queries against the DB.  In that example module, starting at line 94 is a function named "civitest_civicrm_aclWhereClause" that calls the "CRM_Core_DAO::executeQuery" function to query the DB.

AFAICT, the "CRM_Core_DAO::executeQuery" function is aware of the database that CiviCRM inhabits.

OTOH, in the code just before where my error occurs, line 659 in civicrm_group_roles.module uses the "db_select" function instead to execute the query.  I've not been able to track down where that function lives, but I'm guessing it's not aware of the DB that CiviCRM lives in.

Am I on the right track?  Should I file a bug report for this?

Cheers,
Rob Hills
Waikiki, Western Australia

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: DB Errors after "successful" upgrade to 4.5.2
November 18, 2014, 03:37:55 am
I would definitely file a bug report, and I would keep on bug hunting since you are doing a good job so far!

db_select is a drupal function for selecting from MySQL - CRM_Core_DAO::executeQuery is the CivICRM way.  Which seems to me to be consistent with what you are saying.

I had a look at the history for the module and it looks like civicrm_group_roles/civicrm_group_roles.module was changed by davejenx to better handle smart groups https://issues.civicrm.org/jira/browse/CRM-11161. 

If you look here https://github.com/civicrm/civicrm-drupal/commit/f0a43f0662f2e17da4f6b34786b7014a3eec9a29#diff-2211682bb469d77fc28523d608c4564cR660, you'll see that it is trying to join to a civicrm table which for whatever reason it can't find (before it was just querying drupal tables).  So sounds like we might have identified the problem - just not sure what the solution is yet :)
 
I've let Dave know so he can comment.
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: DB Errors after "successful" upgrade to 4.5.2
November 18, 2014, 06:08:59 am
Hi Rob / Michael,

Ah yes, that does seem to have my sticky fingerprints all over it. :-[ The installations where I tested that code also have Civi & Drupal in separate dbs but the reason it worked OK there is that in Drupal settings.php, they have the proper prefixes set up for the Civi tables, so that Drupal knows how to access Civi tables. The procedure for that is described here: http://wiki.civicrm.org/confluence/display/CRMDOC/Views3+Integration

I'm not sure what best practice is for queries that span the Civi & Drupal databases, can anyone from the core team comment? Do we have examples elsewhere in the code base?

A first step would be to document that with the current code, when using the civicrm_group_roles module, it is necessary to set up the table prefixes as described above. This seems not an unreasonable requirement when using a Civi - Drupal integration module but users need to be informed about it.

Apologies,

Dave J

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: DB Errors after "successful" upgrade to 4.5.2
November 19, 2014, 06:21:02 am
The problem with the approach suggested in the Views3 integration is that it doesn't take account of the situation where the drupal and civicrm databases have different user/password combinations. Or are not even stored within the same database server. Drupal these days has a very nice database connection array approach in the settings.php file which civicrm presumably already makes use of. Why can't the Views3 module (and the groups integration, which is causing us a problem right now) make use of it in the same way:


db_set_active(CIVI_DB_NAME AS DEFINED IN SETTINGS.PHP);
 CODE DOING STUFF WITH CIVI DATABASE TABLES GOES HERE
db_set_active();
 CODE DOING STUFF WITH DEFAULT DATABASE GOES AFTER A NULL CALL TO db_set_active();

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: DB Errors after "successful" upgrade to 4.5.2
November 19, 2014, 08:36:25 am
Hi Rob,

Could you see if the attached patch resolves the issue?

Nick - the problem that this topic deals with is a query involving tables from both the Drupal and Civi databases. If we can't get that working consistently then it may need refactoring to do separate queries or perhaps an API call within the loop to check the saved_search_id field of each group.

Dave J

EDIT 26 Nov: please see later patch instead.
« Last Edit: November 26, 2014, 05:03:45 am by davej »

Rob Hills

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.3
  • MySQL version: 5.6
  • PHP version: 3.0
Re: DB Errors after "successful" upgrade to 4.5.2
November 22, 2014, 06:58:40 pm
Hi Dave,

Thanks for the patch and sorry for the delay, I've been away at a conference.  I'll apply your patch during today and report back on the outcome.

Later tonight (Western Australian time, UTC +8H), I plan to upgrade Drupal (7.31 -> 7.34) and CiviCRM (4.5.3->4.5.4) so I will reapply the patch after that and report back again on how it goes with the new versions.

Cheers,
Rob Hills
Waikiki, Western Australia

Rob Hills

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.3
  • MySQL version: 5.6
  • PHP version: 3.0
Re: DB Errors after "successful" upgrade to 4.5.2
November 24, 2014, 05:50:25 pm
Sorry, this has taken me much longer to sort out than I'd anticipated.

I've tried the patch, but I now get a different error on login:

Sorry but we are not able to provide this at the moment.
DB Error: no such table

Not only is the error less helpful than before, but there is no error logged in the DB that I can find.  Looking at the "recent log messages" page, all I can see are a couple of notices:
  • Role member (4) should be held by user Robert Hills (368) because they are part of group 64 (contactID: 225)
  • Initial roles: Array ( [2] => authenticated user [3] => administrator [4] => member ) , roles to add: Array ( ) , roles to remove: Array ( ) , final roles: Array ( [2] => authenticated user [3] => administrator [4] => member )
Is there anywhere else I can look or anything else I can do to get more information about the new error?

TIA,

Rob Hills
Waikiki, Western Australia
Rob Hills
Waikiki, Western Australia

Rob Hills

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.3
  • MySQL version: 5.6
  • PHP version: 3.0
Re: DB Errors after "successful" upgrade to 4.5.2
November 24, 2014, 06:38:58 pm
Quote from: Michael McAndrew on November 18, 2014, 03:37:55 am
I would definitely file a bug report...

OK, I've done that: https://issues.civicrm.org/jira/browse/CRM-15644
Rob Hills
Waikiki, Western Australia

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: DB Errors after "successful" upgrade to 4.5.2
November 26, 2014, 02:56:51 am
Hi Rob,

Sorry that didn't work out, could you try this patch instead, against the original version?

Also did you try setting up the prefixes for the Civi tables in settings.php, as I described in my comment of 18th Nov? That shouldn't be necessary with this new patch, but is another way to get it working if you're not able to patch immediately. It's something you would need to do anyway if you wanted to use Civi Views integration at some point.

Cheers,

Dave J
« Last Edit: November 26, 2014, 03:02:56 am by davej »

richsmith

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal 7.32
  • MySQL version: 5.5
  • PHP version: 5.4
Re: DB Errors after "successful" upgrade to 4.5.2
November 26, 2014, 04:38:20 am
DaveJ - thank you so much!

Just upgraded from civi 4.4 to 4.5 today and started getting these errors. Applied the patch and it seems to have sorted it out.

Many many thanks for this!

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • DB Errors after "successful" upgrade to 4.5.2

This forum was archived on 2017-11-26.