Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temporary table names should be more random #1

Open
jmcclelland opened this issue Jul 29, 2013 · 3 comments
Open

temporary table names should be more random #1

jmcclelland opened this issue Jul 29, 2013 · 3 comments

Comments

@jmcclelland
Copy link
Contributor

If you try to put two reports on your dashboard (which will create two temp tables during the same second), you get:
#0 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/Error.php(148): CRM_Core_Error::backtrace()
#1 internal function: CRM_Core_Error::handle(Object(DB_Error))
#2 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#3 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/DB.php(969): PEAR_Error->PEAR_Error("DB Error: already exists", -5, 16, (Array:2), "CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...")
#4 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-5, 16, (Array:2), "CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...")
#5 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -5, NULL, NULL, "CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...", "DB_Error", TRUE)
#6 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/DB/mysql.php(898): DB_common->raiseError(-5, NULL, NULL, NULL, "1050 ** Table 'civicrm_report_temp_entity_tag032607' already exists")
#7 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()
#8 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...")
#9 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/DB/DataObject.php(2421): DB_common->query("CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...")
#10 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/DB/DataObject.php(1613): DB_DataObject->_query("CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...")
#11 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/DAO.php(155): DB_DataObject->query("CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...")
#12 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/DAO.php(956): CRM_Core_DAO->query("CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...", TRUE)
#13 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/libraries/reportbase/CRM/Reportbase/Form/Report/ReportBase.php(3223): CRM_Core_DAO::executeQuery("CREATE TABLE civicrm_report_temp_entity_tag032607\n (\n contact_id...")
#14 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/libraries/reportbase/CRM/Reportbase/Form/Report/ReportBase.php(330): CRM_ReportBase_Form_Report_ReportBase->joinEntityTagFromContact("", (Array:0))
#15 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/libraries/advancedfundraising/CRM/Advancedfundraising/Form/Report/Contribute/Renewals.php(106): CRM_ReportBase_Form_Report_ReportBase->from()
#16 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/libraries/reportbase/CRM/Reportbase/Form/Report/ReportBase.php(914): CRM_Advancedfundraising_Form_Report_Contribute_Renewals->from()
#17 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/libraries/reportbase/CRM/Reportbase/Form/Report/ReportBase.php(836): CRM_ReportBase_Form_Report_ReportBase->buildQuery()
#18 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/libraries/reportbase/CRM/Reportbase/Form/Report/ReportBase.php(209): CRM_ReportBase_Form_Report_ReportBase->postProcess()
#19 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/libraries/advancedfundraising/CRM/Advancedfundraising/Form/Report/Contribute/Renewals.php(102): CRM_ReportBase_Form_Report_ReportBase->preProcess()
#20 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/Form.php(336): CRM_Advancedfundraising_Form_Report_Contribute_Renewals->preProcess()
#21 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Display.php(93): CRM_Core_Form->buildForm()
#22 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display->perform(Object(CRM_Advancedfundraising_Form_Report_Contribute_Renewals), "display")
#23 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Advancedfundraising_Form_Report_Contribute_Renewals), "display")
#24 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/Controller.php(316): HTML_QuickForm_Page->handle("display")
#25 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(117): CRM_Core_Controller->run()
#26 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Report/Page/Instance.php(104): CRM_Utils_Wrapper->run("CRM_Advancedfundraising_Form_Report_Contribute_Renewals", NULL, NULL)
#27 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/Invoke.php(292): CRM_Report_Page_Instance->run((Array:4), NULL)
#28 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/Invoke.php(70): CRM_Core_Invoke::runItem((Array:14))
#29 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
#30 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/sites/all/modules/civicrm/drupal/civicrm.module(436): CRM_Core_Invoke::invoke((Array:4))
#31 internal function: civicrm_invoke("report", "instance", "78")
#32 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/includes/menu.inc(517): call_user_func_array("civicrm_invoke", (Array:3))
#33 /var/aegir/platforms/nahuel-ourpowerbase-d7-c4.3/index.php(21): menu_execute_active_handler()
#34 {main}

Sorry but we are not able to provide this at the moment.
DB Error: already exists

Return to home page.

@jmcclelland
Copy link
Contributor Author

This patch seems to do the trick:

http://git.progressivetech.org/?p=extensions/nz.co.fuzion.reportbase.git;a=commitdiff;h=1ffc5b99f325322f6191f4ec8830a51319579f19

Although... every 1,000th time you rebuild the dashboard, you will get a conflict so may it could be tightened.

@eileenmcnaughton
Copy link
Owner

Hmm - my original thinking was that I would check if a temp table existed & use it rather than building it twice - but I didn't manage to find the clash in my testing so didn't go any further. However, I think I will look at that fix rather than yours (I have done a previous thing in the past & used day + hour but unless you think I should only regenerate that often I'll do Y-m-d-h-i)

NB the clear caches job should (4.2.10 or later) delete the temp tables.

@eileenmcnaughton
Copy link
Owner

Oh just thinking the weakness in my plan is that two different searches in the same minute could possibly clash. hmmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants