Answers.Body: <p>After posting my comment, I did a little bit of digging into what the <code>CRM_Core_ManagedEntities::reconcile</code> function does.  It says:</p>
  
  <pre><code>* Identify any enabled/disabled modules. Add new entities, update
  * existing entities, and remove orphaned (stale) entities
  </code></pre>
  
  <p>So it would seem that it's confused because "Benefits Specialist Is" is a relationship associated with CiviCase, but perhaps you have it enabled with CiviCase disabled or vice versa.  Try enabling/disabling that relationship to match whether you use CiviCase and see if the error persists.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-08T16:06:41.880Z
Answers.Text: Error went away when disabling some unused demo cases. It's weird that Civicirm includes these even when I remember that during installation I decided not to enable the demo content. 
  
  Thanks for leading me in that direction.
Answers.UserDisplayName: ñull
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-08T13:29:12.583Z
Answers.LastActivityDate: 2015-09-08T13:29:12.583Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>Same happened after upgrade from 4.6 to 5.1 and I had visit the Case Types config page, then remove the Case Roles mentioned in ConfigAndLog, saved the Case Type, then added them back in again.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-20T13:12:16.630Z
Answers.LastActivityDate: 2018-06-20T13:12:16.630Z
Answers.UserDisplayName: Darren
Body: <p>According documentation I created a skeleton module with civix and answered yes to install it. It then gives an error response as in the Title. Afterwards is listed active in the extensions page. </p>
  
  <p>This is on 4.6.8 recently upgraded from 4.6.4.  Since the module seems active the error messsage is apparently not related to the installed module. When under Drupal I use the tool drush I got this more extensive error response even before creating/installing the skeleton module: </p>
  
  <pre><code>exception 'Exception' with message 'API error: DB Error: already exists' in /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php:453              [error]
  Stack trace:
  #0 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(234): CRM_Core_ManagedEntities-&gt;onApiError('RelationshipTyp...', 'create', Array, Array)
  #1 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(179): CRM_Core_ManagedEntities-&gt;insertNewEntity(Array)
  #2 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(141): CRM_Core_ManagedEntities-&gt;reconcileEnabledModule(Object(CRM_Core_Module), Array)
  #3 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(122): CRM_Core_ManagedEntities-&gt;reconcileEnabledModules()
  #4 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Invoke.php(403): CRM_Core_ManagedEntities-&gt;reconcile()
  #5 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/drupal/civicrm.module(1407): CRM_Core_Invoke::rebuildMenuAndCaches(true)
  #6 [internal function]: civicrm_modules_enabled(Array)
  #7 /var/www/civicrm/htdocs/drupal/includes/module.inc(895): call_user_func_array('civicrm_modules...', Array)
  #8 /var/www/civicrm/htdocs/drupal/includes/module.inc(499): module_invoke_all('modules_enabled', Array)
  #9 /home/c2/.composer/vendor/drush/drush/commands/core/drupal/environment_7.inc(143): module_enable(Array)
  #10 /home/c2/.composer/vendor/drush/drush/commands/pm/pm.drush.inc(1120): drush_module_enable(Array)
  #11 [internal function]: drush_pm_enable('help')
  #12 /home/c2/.composer/vendor/drush/drush/includes/command.inc(368): call_user_func_array('drush_pm_enable', Array)
  #13 /home/c2/.composer/vendor/drush/drush/includes/command.inc(219): _drush_invoke_hooks(Array, Array)
  #14 [internal function]: drush_command('help')
  #15 /home/c2/.composer/vendor/drush/drush/includes/command.inc(187): call_user_func_array('drush_command', Array)
  #16 /home/c2/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
  #17 /home/c2/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot-&gt;bootstrap_and_dispatch()
  #18 /home/c2/.composer/vendor/drush/drush/drush.php(11): drush_main()
  #19 {main}
  </code></pre>
  
  <p>When I look in the related ConfigAndLog I see:</p>
  
  <pre><code>Sep 08 14:14:08  [info] $backTrace = #0 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Error.php(897): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
  #2 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
  #3 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB.php(976): PEAR_Error-&gt;PEAR_Error("DB Error: already exists", -5, 16, (Array:2), "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #4 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error-&gt;DB_Error(-5, 16, (Array:2), "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #5 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR-&gt;raiseError(NULL, -5, NULL, NULL, "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...", "DB_Error", TRUE)
  #6 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/mysqli.php(929): DB_common-&gt;raiseError(-5, NULL, NULL, NULL, "1062 ** Duplicate entry 'Benefits Specialist is' for key 'UI_name_a_b'")
  #7 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli-&gt;mysqliRaiseError()
  #8 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysqli-&gt;simpleQuery("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #9 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/DataObject.php(2442): DB_common-&gt;query("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #10 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/DataObject.php(1060): DB_DataObject-&gt;_query("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #11 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/DAO.php(450): DB_DataObject-&gt;insert()
  #12 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Contact/BAO/RelationshipType.php(126): CRM_Core_DAO-&gt;save()
  #13 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/v3/RelationshipType.php(62): CRM_Contact_BAO_RelationshipType::add((Array:11), (Array:1))
  #14 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_relationship_type_create((Array:11))
  #15 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Kernel.php(96): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:9))
  #16 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel-&gt;run("RelationshipType", "create", (Array:10), NULL)
  #17 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(232): civicrm_api("RelationshipType", "create", (Array:10))
  #18 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(179): CRM_Core_ManagedEntities-&gt;insertNewEntity((Array:6))
  #19 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(141): CRM_Core_ManagedEntities-&gt;reconcileEnabledModule(Object(CRM_Core_Module), (Array:4))
  #20 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(122): CRM_Core_ManagedEntities-&gt;reconcileEnabledModules()
  #21 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Invoke.php(403): CRM_Core_ManagedEntities-&gt;reconcile()
  #22 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Extension/Manager.php(246): CRM_Core_Invoke::rebuildMenuAndCaches(TRUE)
  #23 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/v3/Extension.php(56): CRM_Extension_Manager-&gt;install((Array:1))
  #24 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_extension_install((Array:3))
  #25 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Kernel.php(96): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:9))
  #26 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel-&gt;run("Extension", "install", (Array:3), NULL)
  #27 /home/c2/bin/civix.php/src/CRM/ClientBundle/class.api.php(228): civicrm_api("Extension", "install", (Array:3))
  #28 /home/c2/bin/civix.php/src/CRM/ClientBundle/class.api.php(141): civicrm_api3-&gt;call("Extension", "install", (Array:1))
  #29 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(101): civicrm_api3-&gt;__call("install", (Array:1))
  #30 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(101): civicrm_api3-&gt;install((Array:1))
  #31 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(80): CRM\CivixBundle\Command\InitCommand-&gt;tryEnable(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), "ipdp.relperms")
  #32 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(238): CRM\CivixBundle\Command\InitCommand-&gt;execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #33 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(192): Symfony\Component\Console\Command\Command-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #34 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(78): Symfony\Component\Console\Application-&gt;doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #35 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(105): Symfony\Bundle\FrameworkBundle\Console\Application-&gt;doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #36 /home/c2/bin/civix.php/civix(22): Symfony\Component\Console\Application-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput))
  #37 {main}
  
  
  Sep 08 14:14:08  [info] $ManagedEntities_failed = Array
  (
      [entity] =&gt; RelationshipType
      [action] =&gt; create
      [params] =&gt; Array
          (
              [version] =&gt; 3
              [name_a_b] =&gt; Benefits Specialist is
              [name_b_a] =&gt; Benefits Specialist
              [label_a_b] =&gt; Benefits Specialist is
              [label_b_a] =&gt; Benefits Specialist
              [description] =&gt; Benefits Specialist
              [contact_type_a] =&gt; Individual
              [contact_type_b] =&gt; Individual
              [contact_sub_type_a] =&gt; 
              [contact_sub_type_b] =&gt; 
          )
  
      [result] =&gt; Array
          (
              [error_code] =&gt; already exists
              [tip] =&gt; add debug=1 to your API call to have more info about the error
              [is_error] =&gt; 1
              [error_message] =&gt; DB Error: already exists
          )
  
  )
  </code></pre>
  
  <p>What could be the cause and how to fix this? </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-08T13:22:03.117Z
Comments.Text: It looks like the issue is happening during either the menu rebuild or (more likely) cache clearing.  Try doing a cache clear (**Administer menu > System Settings > Cleanup Caches and Update Paths**, press the "Cleanup Caches" button) and also rebuild the menu (example.org/civicrm/menu/rebuild?reset=1).  Does either one trigger the issue?  If so we can update the question to reflect that.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-27T09:16:28.893Z
Comments.Text: I have the same error. We use CiviCase on this site and relationships are setup correctly and suddenly we have this error. How do we get rid of this error? The error only happens on the test site and not on the live site. In the log file I see the following: Oct 27 11:34:09 [info] $ManagedEntities_failed = Array ( [entity] => RelationshipType [action] => create [params] => Array ( [version] => 3 [name_a_b] => Case Coordinator is [name_b_a] => Case Coordinator [label_a_b] => Case Coordinator is [label_b_a] => Case Coordinator [description] => Case Coordinator [contact_type_a] => Individual [con
Comments.UserDisplayName: Jaap Jansma - CiviCooP
Tags: <database><issues><civix>
Title: Civix: Install error: API error: DB Error: already exists
ThreadText: # Civix: Install error: API error: DB Error: already exists
  
  (Asked by: username_0 on 2015-09-08)
  
  According documentation I created a skeleton module with civix and answered yes to install it. It then gives an error response as in the Title. Afterwards is listed active in the extensions page. 
  This is on 4.6.8 recently upgraded from 4.6.4.  Since the module seems active the error messsage is apparently not related to the installed module. When under Drupal I use the tool drush I got this more extensive error response even before creating/installing the skeleton module: 
  exception 'Exception' with message 'API error: DB Error: already exists' in /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php:453              [error]
  Stack trace:
  #0 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(234): CRM_Core_ManagedEntities->onApiError('RelationshipTyp...', 'create', Array, Array)
  #1 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(179): CRM_Core_ManagedEntities->insertNewEntity(Array)
  #2 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(141): CRM_Core_ManagedEntities->reconcileEnabledModule(Object(CRM_Core_Module), Array)
  #3 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(122): CRM_Core_ManagedEntities->reconcileEnabledModules()
  #4 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Invoke.php(403): CRM_Core_ManagedEntities->reconcile()
  #5 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/drupal/civicrm.module(1407): CRM_Core_Invoke::rebuildMenuAndCaches(true)
  #6 [internal function]: civicrm_modules_enabled(Array)
  #7 /var/www/civicrm/htdocs/drupal/includes/module.inc(895): call_user_func_array('civicrm_modules...', Array)
  #8 /var/www/civicrm/htdocs/drupal/includes/module.inc(499): module_invoke_all('modules_enabled', Array)
  #9 /home/c2/.composer/vendor/drush/drush/commands/core/drupal/environment_7.inc(143): module_enable(Array)
  #10 /home/c2/.composer/vendor/drush/drush/commands/pm/pm.drush.inc(1120): drush_module_enable(Array)
  #11 [internal function]: drush_pm_enable('help')
  #12 /home/c2/.composer/vendor/drush/drush/includes/command.inc(368): call_user_func_array('drush_pm_enable', Array)
  #13 /home/c2/.composer/vendor/drush/drush/includes/command.inc(219): _drush_invoke_hooks(Array, Array)
  #14 [internal function]: drush_command('help')
  #15 /home/c2/.composer/vendor/drush/drush/includes/command.inc(187): call_user_func_array('drush_command', Array)
  #16 /home/c2/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
  #17 /home/c2/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
  #18 /home/c2/.composer/vendor/drush/drush/drush.php(11): drush_main()
  #19 {main}
  
  When I look in the related ConfigAndLog I see:
  Sep 08 14:14:08  [info] $backTrace = #0 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Error.php(897): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
  #2 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
  #3 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error("DB Error: already exists", -5, 16, (Array:2), "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #4 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-5, 16, (Array:2), "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #5 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -5, NULL, NULL, "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...", "DB_Error", TRUE)
  #6 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/mysqli.php(929): DB_common->raiseError(-5, NULL, NULL, NULL, "1062 ** Duplicate entry 'Benefits Specialist is' for key 'UI_name_a_b'")
  #7 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
  #8 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #9 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/DataObject.php(2442): DB_common->query("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #10 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/DataObject.php(1060): DB_DataObject->_query("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
  #11 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/DAO.php(450): DB_DataObject->insert()
  #12 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Contact/BAO/RelationshipType.php(126): CRM_Core_DAO->save()
  #13 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/v3/RelationshipType.php(62): CRM_Contact_BAO_RelationshipType::add((Array:11), (Array:1))
  #14 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_relationship_type_create((Array:11))
  #15 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Kernel.php(96): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
  #16 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel->run("RelationshipType", "create", (Array:10), NULL)
  #17 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(232): civicrm_api("RelationshipType", "create", (Array:10))
  #18 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(179): CRM_Core_ManagedEntities->insertNewEntity((Array:6))
  #19 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(141): CRM_Core_ManagedEntities->reconcileEnabledModule(Object(CRM_Core_Module), (Array:4))
  #20 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(122): CRM_Core_ManagedEntities->reconcileEnabledModules()
  #21 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Invoke.php(403): CRM_Core_ManagedEntities->reconcile()
  #22 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Extension/Manager.php(246): CRM_Core_Invoke::rebuildMenuAndCaches(TRUE)
  #23 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/v3/Extension.php(56): CRM_Extension_Manager->install((Array:1))
  #24 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_extension_install((Array:3))
  #25 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Kernel.php(96): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
  #26 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel->run("Extension", "install", (Array:3), NULL)
  #27 /home/c2/bin/civix.php/src/CRM/ClientBundle/class.api.php(228): civicrm_api("Extension", "install", (Array:3))
  #28 /home/c2/bin/civix.php/src/CRM/ClientBundle/class.api.php(141): civicrm_api3->call("Extension", "install", (Array:1))
  #29 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(101): civicrm_api3->__call("install", (Array:1))
  #30 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(101): civicrm_api3->install((Array:1))
  #31 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(80): CRM\CivixBundle\Command\InitCommand->tryEnable(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), "ipdp.relperms")
  #32 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(238): CRM\CivixBundle\Command\InitCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #33 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(192): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #34 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(78): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #35 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(105): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #36 /home/c2/bin/civix.php/civix(22): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
  #37 {main}
  
  
  Sep 08 14:14:08  [info] $ManagedEntities_failed = Array
  (
      [entity] => RelationshipType
      [action] => create
      [params] => Array
          (
              [version] => 3
              [name_a_b] => Benefits Specialist is
              [name_b_a] => Benefits Specialist
              [label_a_b] => Benefits Specialist is
              [label_b_a] => Benefits Specialist
              [description] => Benefits Specialist
              [contact_type_a] => Individual
              [contact_type_b] => Individual
              [contact_sub_type_a] => 
              [contact_sub_type_b] => 
          )
  
      [result] => Array
          (
              [error_code] => already exists
              [tip] => add debug=1 to your API call to have more info about the error
              [is_error] => 1
              [error_message] => DB Error: already exists
          )
  
  )
  
  What could be the cause and how to fix this?
  
  **Tags:** database, issues, civix
  
  > **Comments:**
  > **username_1**: It looks like the issue is happening during either the menu rebuild or (more likely) cache clearing.  Try doing a cache clear (**Administer menu > System Settings > Cleanup Caches and Update Paths**, press the "Cleanup Caches" button) and also rebuild the menu (example.org/civicrm/menu/rebuild?reset=1).  Does either one trigger the issue?  If so we can update the question to reflect that.  
  > **username_2**: I have the same error. We use CiviCase on this site and relationships are setup correctly and suddenly we have this error. How do we get rid of this error? The error only happens on the test site and not on the live site. In the log file I see the following: Oct 27 11:34:09 [info] $ManagedEntities_failed = Array ( [entity] => RelationshipType [action] => create [params] => Array ( [version] => 3 [name_a_b] => Case Coordinator is [name_b_a] => Case Coordinator [label_a_b] => Case Coordinator is [label_b_a] => Case Coordinator [description] => Case Coordinator [contact_type_a] => Individual [con  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-09-08. Score: 2
  
  After posting my comment, I did a little bit of digging into what the CRM_Core_ManagedEntities::reconcile function does.  It says:
  * Identify any enabled/disabled modules. Add new entities, update
  * existing entities, and remove orphaned (stale) entities
  
  So it would seem that it's confused because "Benefits Specialist Is" is a relationship associated with CiviCase, but perhaps you have it enabled with CiviCase disabled or vice versa.  Try enabling/disabling that relationship to match whether you use CiviCase and see if the error persists.
  
  > **Comments:**
  > **username_0**: Error went away when disabling some unused demo cases. It's weird that Civicirm includes these even when I remember that during installation I decided not to enable the demo content.   Thanks for leading me in that direction.  
  
  ---
  
  ### Answer by username_3 on 2018-06-20. Score: 0
  
  Same happened after upgrade from 4.6 to 5.1 and I had visit the Case Types config page, then remove the Case Roles mentioned in ConfigAndLog, saved the Case Type, then added them back in again.
  
  
  ---
  
  