From 2b46d9107bcc3dfd2b026f1c08a4f47a126c208e Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Fri, 5 Oct 2012 12:01:23 -0400 Subject: [PATCH 1/5] DOCS-401 added topic on dupe key in slaves error --- source/administration/replica-sets.txt | 45 ++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/source/administration/replica-sets.txt b/source/administration/replica-sets.txt index 921bee92aa9..d7f4213a6dd 100644 --- a/source/administration/replica-sets.txt +++ b/source/administration/replica-sets.txt @@ -398,8 +398,8 @@ directly. Replacing a Member ~~~~~~~~~~~~~~~~~~ -Use this procedure to replace a member of a replica set when the host -name has changed. This procedure preserves all existing configuration +Use this procedure to replace a member of a replica set when the hostname +has changed. This procedure preserves all existing configuration for a member, except its hostname/location. You may need to replace a replica set member if you want to replace an @@ -928,3 +928,44 @@ use an update operation that resembles the following: Modify the timestamp values as needed based on your oplog entry. This operation may take some period to complete because the update must scan and pull the entire oplog into memory. + +Duplicate Key Error on local.slaves +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The duplicate key error on local.slaves, shown below, occurs when a +connected host changes its hostname. This is a benign error and does not +affect operations. + +.. example:: + + .. code-block:: javascript + + exception 11000 E11000 duplicate key error index: local.slaves.$_id_ dup key: { : ObjectId('') } 0ms + +The error occurs when a host connected to the current host, either +through :term:`replication` or through :term:`master`- :term:`slave` +configuration, changes its hostname. The ``local.slaves`` collection +creates a new document with the new hostname but also keeps the old +document with the old hostname. The local.slaves`` collection now has +two documents with the same ``_id`` field. + +.. example:: This example shows a ``local.slaves`` collection where the + hostname for ``abc.example.com`` changed to ``xyz.example.com``. Both + hostnames still exist in the collection, and both have the same ``_id``. + + .. code-block:: javascript + + PRIMARY> db.slaves.find() + { "_id" : "123", "host" : "abc.example.com", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1338775234001, 1) } + { "_id" : "456", "host" : "def.example.com", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1338775234002, 1) } + { "_id" : "123", "host" : "xyz.example.com", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1349290750000, 1) } + +To stop the error from appearing, drop the ``local.slaves`` collection, as +shown here: + +.. code-block:: javascript + + db.slaves.drop() + +At the next sync between the hosts, MongoDB re-creates the +``local.slaves`` collection and records only the current hostnames. From d2cb2b03e60d7b09c7e7429866d6105f9b8c5bc1 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Fri, 5 Oct 2012 12:20:16 -0400 Subject: [PATCH 2/5] DOCS-401 added topic on dupe key in slaves error --- source/administration/replica-sets.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/administration/replica-sets.txt b/source/administration/replica-sets.txt index d7f4213a6dd..bf4c175c7ae 100644 --- a/source/administration/replica-sets.txt +++ b/source/administration/replica-sets.txt @@ -950,15 +950,15 @@ document with the old hostname. The local.slaves`` collection now has two documents with the same ``_id`` field. .. example:: This example shows a ``local.slaves`` collection where the - hostname for ``abc.example.com`` changed to ``xyz.example.com``. Both + hostname for ``mdb1.example.net`` changed to ``db1.example.net``. Both hostnames still exist in the collection, and both have the same ``_id``. .. code-block:: javascript PRIMARY> db.slaves.find() - { "_id" : "123", "host" : "abc.example.com", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1338775234001, 1) } - { "_id" : "456", "host" : "def.example.com", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1338775234002, 1) } - { "_id" : "123", "host" : "xyz.example.com", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1349290750000, 1) } + { "_id" : "101", "host" : "mdb1.example.net", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1338775234001, 1) } + { "_id" : "102", "host" : "mdb2.example.net", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1338775234002, 1) } + { "_id" : "101", "host" : "db1.example.net", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1349290750000, 1) } To stop the error from appearing, drop the ``local.slaves`` collection, as shown here: @@ -967,5 +967,5 @@ shown here: db.slaves.drop() -At the next sync between the hosts, MongoDB re-creates the +At the next synchronization of the replica set or the master-slave configuration, MongoDB re-creates the ``local.slaves`` collection and records only the current hostnames. From 2a31f634333db822f06dcee32f13dff5b84bedb1 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Fri, 5 Oct 2012 13:41:12 -0400 Subject: [PATCH 3/5] DOCS-401 edits. not ready for merge --- source/administration/replica-sets.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/administration/replica-sets.txt b/source/administration/replica-sets.txt index bf4c175c7ae..d7c9c41d45c 100644 --- a/source/administration/replica-sets.txt +++ b/source/administration/replica-sets.txt @@ -943,7 +943,7 @@ affect operations. exception 11000 E11000 duplicate key error index: local.slaves.$_id_ dup key: { : ObjectId('') } 0ms The error occurs when a host connected to the current host, either -through :term:`replication` or through :term:`master`- :term:`slave` +through :term:`replica sets ` or through :term:`master`- :term:`slave` configuration, changes its hostname. The ``local.slaves`` collection creates a new document with the new hostname but also keeps the old document with the old hostname. The local.slaves`` collection now has From 8c08e46e7a116f9989e74f7ba8080db356a4c934 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Fri, 5 Oct 2012 15:21:48 -0400 Subject: [PATCH 4/5] DOCS-401 major edits: dupe key in local.slaves --- source/administration/replica-sets.txt | 37 +++++++++----------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/source/administration/replica-sets.txt b/source/administration/replica-sets.txt index d7c9c41d45c..dcc1acb5af5 100644 --- a/source/administration/replica-sets.txt +++ b/source/administration/replica-sets.txt @@ -932,9 +932,12 @@ scan and pull the entire oplog into memory. Duplicate Key Error on local.slaves ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The duplicate key error on local.slaves, shown below, occurs when a -connected host changes its hostname. This is a benign error and does not -affect operations. +The *duplicate key on local.slaves* error, shown below, occurs when a +:term:`secondary` or :term:`slave` changes its hostname and the +:term:`primary` or :term:`master` tries to update its ``local.slaves`` +collection with the new name but runs into a duplicate `_id` field. The +duplicate `_id` field exists in a document containing the previous +hostname. .. example:: @@ -942,30 +945,16 @@ affect operations. exception 11000 E11000 duplicate key error index: local.slaves.$_id_ dup key: { : ObjectId('') } 0ms -The error occurs when a host connected to the current host, either -through :term:`replica sets ` or through :term:`master`- :term:`slave` -configuration, changes its hostname. The ``local.slaves`` collection -creates a new document with the new hostname but also keeps the old -document with the old hostname. The local.slaves`` collection now has -two documents with the same ``_id`` field. +This is a benign error and does not affect replication operations on +the :term:`secondary` or :term:`slave`. -.. example:: This example shows a ``local.slaves`` collection where the - hostname for ``mdb1.example.net`` changed to ``db1.example.net``. Both - hostnames still exist in the collection, and both have the same ``_id``. - - .. code-block:: javascript - - PRIMARY> db.slaves.find() - { "_id" : "101", "host" : "mdb1.example.net", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1338775234001, 1) } - { "_id" : "102", "host" : "mdb2.example.net", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1338775234002, 1) } - { "_id" : "101", "host" : "db1.example.net", "ns" : "local.oplog.rs", "syncedTo" : Timestamp(1349290750000, 1) } - -To stop the error from appearing, drop the ``local.slaves`` collection, as -shown here: +To stop the error from appearing, drop the ``local.slaves`` collection +from the :term:`primary` or :term:`master`, as shown here: .. code-block:: javascript db.slaves.drop() -At the next synchronization of the replica set or the master-slave configuration, MongoDB re-creates the -``local.slaves`` collection and records only the current hostnames. +The next time a :term:`secondary` or :term:`slave` polls the +:term:`primary` or :term:`master`, the :term:`primary` or :term:`master` +recreates the ``local.slaves`` collection. \ No newline at end of file From 70e54bfb82ef05dcdcfabe3bdd34a1803bbbe957 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Fri, 5 Oct 2012 15:28:41 -0400 Subject: [PATCH 5/5] DOCS-401 minor edit --- source/administration/replica-sets.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/administration/replica-sets.txt b/source/administration/replica-sets.txt index dcc1acb5af5..cf021e223f3 100644 --- a/source/administration/replica-sets.txt +++ b/source/administration/replica-sets.txt @@ -935,9 +935,8 @@ Duplicate Key Error on local.slaves The *duplicate key on local.slaves* error, shown below, occurs when a :term:`secondary` or :term:`slave` changes its hostname and the :term:`primary` or :term:`master` tries to update its ``local.slaves`` -collection with the new name but runs into a duplicate `_id` field. The -duplicate `_id` field exists in a document containing the previous -hostname. +collection with the new name. The update fails because it contains the +same `_id` value as the document containing the previous hostname. .. example::