My guess is this is not supposed to happen:

WD php: Duplicate entry 'server_localhost' for key 2                                                                                                                                                                                
query: INSERT INTO hosting_context (nid, name) VALUES (2, 'server_localhost') in /var/hostmaster/hostmaster-0.4-alpha8+services/profiles/hostmaster/modules/hosting/hosting.module on line 777. 

I see this in the hostmaster-migrate, more precisely during the deploy, which happens during provision-migrate of the frontend.

There's code in that function to check for already existing entries, so this shouldn't happen:

function hosting_context_register($nid, $name) {
  // Check first to see if this nid exists in the system. If so, update its name
  $result = db_query("SELECT nid FROM {hosting_context} WHERE nid=%d", $nid);
  if ($obj = db_fetch_object($result)) {
    db_query("UPDATE {hosting_context} SET name = '%s' WHERE nid = %d", $name, $nid);
  }
  else {
    // It's a new item
    db_query("INSERT INTO {hosting_context} (nid, name) VALUES (%d, '%s')", $nid, $name);
  }
}

.. unfortunately, there's a unique key on the name column (?!) which makes this fail.

Comments

anarcat’s picture

I suspect the problem is related to the fact that i'm trying to upgrade a system that has everything local: mysql and apache are on the same server.

adrian’s picture

names are meant to be unique.

the one db_server NODE should have been summarily deleted, and it's service merged into the web server node.

anarcat’s picture

Status: Active » Fixed

i fixed this by avoiding setting the service twice. Instead of two broken assumptions, we now only have one... If we need to fix the localhost server, we need to do it in just one place.

This may break upgrades for multiserver setups.

--- a/modules/hosting/hosting.install
+++ b/modules/hosting/hosting.install
@@ -232,6 +232,11 @@ function hosting_update_6008() {
       $records[$object->nid] = $object->title;
     }
 
+    // We start with the web server because we assume that the main hostmaster site is installed locally.
+    $server_id = variable_get('hosting_own_web_server', 2);
+    db_query("UPDATE {node} SET title='localhost' WHERE nid=%d", $server_id);
+    db_query("UPDATE {node_revisions} SET title='localhost' WHERE nid=%d", $server_id);
+
     $result =  db_query("SELECT n.nid, title FROM {node} n LEFT JOIN {hosting_server} s ON n.nid=s.nid WHERE n.status 
     while ($object = db_fetch_object($result)) {
       $records[$object->nid] = 'server_' . preg_replace("/[!\W\.\-]/", "", $object->title);
@@ -246,14 +251,6 @@ function hosting_update_6008() {
     $own_site = db_result(db_query("SELECT s.nid FROM {hosting_site} s LEFT JOIN {hosting_package} p ON s.profile=p.ni
     $records[$own_site] = 'hostmaster';
     
-    // We start with the web server because we assume that the main hostmaster site is installed locally.
-
-    $server_id = variable_get('hosting_own_web_server', 2);
-    db_query("UPDATE {node} SET title='localhost' WHERE nid=%d", $server_id);
-    db_query("UPDATE {node_revisions} SET title='localhost' WHERE nid=%d", $server_id);
-
-    $records[$server_id] = 'server_localhost';
-
     foreach ($records as $nid => $name) {
       hosting_context_register($nid, $name);
     }
adrian’s picture

we no longer rename the title of the server that way, it is now defaulted to 'php_uname("n")'.

this is only the primary web server mind you. We also set the context name of the server to '@server_master' now, so this wont be able to happen anymore.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 1862fb3 on dev-dns, dev-features, dev-log_directory, dev-migrate_aliases, dev-multiserver-install, dev-newsiteform, dev-nginx, dev-ports, dev-purgebackup, dev-restore, dev-ssl, prod-koumbit, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by anarcat:
    #829418 - don't hardcode the server_localhost context during the upgrade...
  • Commit 2e0e3c0 on dev-dns, dev-features, dev-log_directory, dev-migrate_aliases, dev-multiserver-install, dev-newsiteform, dev-nginx, dev-ports, dev-purgebackup, dev-restore, dev-ssl, prod-koumbit, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by anarcat:
    #829418 - don't hardcode the server_localhost context during the upgrade...

  • Commit 1862fb3 on dev-dns, dev-features, dev-log_directory, dev-migrate_aliases, dev-multiserver-install, dev-newsiteform, dev-nginx, dev-ports, dev-purgebackup, dev-restore, dev-ssl, prod-koumbit, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by anarcat:
    #829418 - don't hardcode the server_localhost context during the upgrade...
  • Commit 2e0e3c0 on dev-dns, dev-features, dev-log_directory, dev-migrate_aliases, dev-multiserver-install, dev-newsiteform, dev-nginx, dev-ports, dev-purgebackup, dev-restore, dev-ssl, prod-koumbit, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by anarcat:
    #829418 - don't hardcode the server_localhost context during the upgrade...