Merge ~ahasenack/ubuntu/+source/mongodb:bionic-mongo-restore into ubuntu/+source/mongodb:ubuntu/bionic-devel

Proposed by Andreas Hasenack
Status: Merged
Approved by: Andreas Hasenack
Approved revision: b28281e88cc10a26e1b24c593926453a3b33832c
Merged at revision: b28281e88cc10a26e1b24c593926453a3b33832c
Proposed branch: ~ahasenack/ubuntu/+source/mongodb:bionic-mongo-restore
Merge into: ubuntu/+source/mongodb:ubuntu/bionic-devel
Diff against target: 147 lines (+125/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/SERVER-36951-applyOps-createIndexes-without-uuid.patch (+116/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Review via email: mp+364985@code.launchpad.net

Description of the change

Bug has the SRU template filled out, including testing instructions. I ran them myself and confirmed this fixes the issue as described.

To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I did re-check the tests and updated the bug status a bit to be correct (needs Bionci&Cosmic bug Disco is done).

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Versions in B/C are identical, so it will be nearly the same aside the version in the changelog, but just FZI a matching cosmic upload will be needed as well.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I found no PPA associated to test the fix myself, but the change is straight forward and looks correct to me.
You mentioned that you tested it and I trust that as well.

Nothing to complain, except the missing Cosmic upload.

P.S. about testing, do the self tests run at build time? have you tried to add just the test but not the fix if this would reliably catch and stop it at build time?

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Sorry, the PPA is https://launchpad.net/~ahasenack/+archive/ubuntu/mongodb-restore-server-36951

Cosmic is an FTBFS (it was already, since the cosmic release). I'm working on that now.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

The tests do run at build time. I haven't experimented with them, as this package takes a long time to build.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Ack to the version update

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks, tagged and uploaded:

$ git push pkg upload/1%3.6.3-0ubuntu1.1
Enumerating objects: 20, done.
Counting objects: 100% (20/20), done.
Delta compression using up to 4 threads
Compressing objects: 100% (15/15), done.
Writing objects: 100% (15/15), 3.50 KiB | 298.00 KiB/s, done.
Total 15 (delta 10), reused 0 (delta 0)
To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/mongodb
 * [new tag] upload/1%3.6.3-0ubuntu1.1 -> upload/1%3.6.3-0ubuntu1.1

$ dput ubuntu ../mongodb_3.6.3-0ubuntu1.1_source.changes
Checking signature on .changes
gpg: ../mongodb_3.6.3-0ubuntu1.1_source.changes: Valid signature from AC983EB5BF6BCBA9
Checking signature on .dsc
gpg: ../mongodb_3.6.3-0ubuntu1.1.dsc: Valid signature from AC983EB5BF6BCBA9
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading mongodb_3.6.3-0ubuntu1.1.dsc: done.
  Uploading mongodb_3.6.3-0ubuntu1.1.debian.tar.xz: done.
  Uploading mongodb_3.6.3-0ubuntu1.1_source.buildinfo: done.
  Uploading mongodb_3.6.3-0ubuntu1.1_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index b58db7c..81b72e2 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+mongodb (1:3.6.3-0ubuntu1.1) bionic; urgency=medium
7+
8+ * d/p/SERVER-36951-applyOps-createIndexes-without-uuid.patch: fix restoring
9+ of a database backup when applyOps has a createIndexes command without a
10+ UUID. (LP: #1821391)
11+
12+ -- Andreas Hasenack <andreas@canonical.com> Fri, 22 Mar 2019 16:11:02 -0300
13+
14 mongodb (1:3.6.3-0ubuntu1) bionic; urgency=medium
15
16 * New upstream release (LP: #1761807).
17diff --git a/debian/patches/SERVER-36951-applyOps-createIndexes-without-uuid.patch b/debian/patches/SERVER-36951-applyOps-createIndexes-without-uuid.patch
18new file mode 100644
19index 0000000..7c9ee38
20--- /dev/null
21+++ b/debian/patches/SERVER-36951-applyOps-createIndexes-without-uuid.patch
22@@ -0,0 +1,116 @@
23+From 19e9da9cdc76f69076c0212dcd6208e05ea71d7a Mon Sep 17 00:00:00 2001
24+From: Dianna Hohensee <dianna.hohensee@10gen.com>
25+Date: Tue, 18 Sep 2018 11:30:49 -0400
26+Subject: [PATCH] SERVER-36951 a createIndexes operation inside applyOps is not
27+ required to have a UUID.
28+
29+(cherry picked from commit 0d0ba866052fd2b9ceaaa66c2b725a02822b102d)
30+
31+Bug: https://jira.mongodb.org/browse/SERVER-36951
32+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/mongodb/+bug/1821391
33+Origin: https://github.com/mongodb/mongo/commit/19e9da9cdc76f69076c0212dcd6208e05ea71d7a
34+Last-Update: 2019-03-22
35+
36+---
37+ jstests/replsets/apply_ops_create_indexes.js | 46 +++++++++++++++-----
38+ src/mongo/db/repl/oplog.cpp | 2 +-
39+ 2 files changed, 37 insertions(+), 11 deletions(-)
40+
41+diff --git a/jstests/replsets/apply_ops_create_indexes.js b/jstests/replsets/apply_ops_create_indexes.js
42+index 4fe813b5ed4..1aba4e710b9 100644
43+--- a/jstests/replsets/apply_ops_create_indexes.js
44++++ b/jstests/replsets/apply_ops_create_indexes.js
45+@@ -1,6 +1,6 @@
46+-/* This test ensures that indexes created by running applyOps are successfully replicated (see
47+- * SERVER-31435). Both insertion into system.indexes and createIndexes style oplog entries are
48+- * passed to applyOps here.
49++/**
50++ * This test ensures that indexes created by running applyOps are both successful and replicated
51++ * correctly (see SERVER-31435).
52+ */
53+ (function() {
54+ "use strict";
55+@@ -9,8 +9,18 @@
56+ let res = testDB.runCommand(cmd);
57+ assert.commandWorked(res, "could not run " + tojson(cmd));
58+ let indexes = new DBCommandCursor(testDB, res).toArray();
59++
60+ assert.eq(indexes.length, expectedNumIndexes);
61+- assert.eq(indexes[expectedNumIndexes - 1].name, indexName);
62++
63++ let foundIndex = false;
64++ for (let i = 0; i < indexes.length; ++i) {
65++ if (indexes[i].name == indexName) {
66++ foundIndex = true;
67++ }
68++ }
69++ assert(foundIndex,
70++ "did not find the index '" + indexName + "' amongst the collection indexes: " +
71++ tojson(indexes));
72+ };
73+
74+ let ensureOplogEntryExists = function(localDB, indexName) {
75+@@ -46,28 +56,44 @@
76+ // Create an index via the applyOps command with the createIndexes command format and make sure
77+ // it exists.
78+ let uuid = primaryTestDB.getCollectionInfos()[0].info.uuid;
79+- let cmdFormatIndexName = "a_1";
80++ let cmdFormatIndexNameA = "a_1";
81+ cmd = {
82+ applyOps: [{
83+ op: "c",
84+ ns: dbName + "." + collName,
85+ ui: uuid,
86+- o: {createIndexes: collName, v: 2, key: {a: 1}, name: cmdFormatIndexName}
87++ o: {createIndexes: collName, v: 2, key: {a: 1}, name: cmdFormatIndexNameA}
88++ }]
89++ };
90++ res = primaryTestDB.runCommand(cmd);
91++ assert.commandWorked(res, "could not run " + tojson(cmd));
92++ rst.awaitReplication();
93++ ensureIndexExists(primaryTestDB, collName, cmdFormatIndexNameA, 2);
94++
95++ // Same as directly above, but ensure that applyOps createIndexes can work without a uuid.
96++ let cmdFormatIndexNameB = "b_1";
97++ cmd = {
98++ applyOps: [{
99++ op: "c",
100++ ns: dbName + "." + collName,
101++ o: {createIndexes: collName, v: 2, key: {b: 1}, name: cmdFormatIndexNameB}
102+ }]
103+ };
104+ res = primaryTestDB.runCommand(cmd);
105+ assert.commandWorked(res, "could not run " + tojson(cmd));
106+ rst.awaitReplication();
107+- ensureIndexExists(primaryTestDB, collName, cmdFormatIndexName, 2);
108++ ensureIndexExists(primaryTestDB, collName, cmdFormatIndexNameB, 3);
109+
110+ let localDB = rst.getPrimary().getDB("local");
111+- ensureOplogEntryExists(localDB, cmdFormatIndexName);
112++ ensureOplogEntryExists(localDB, cmdFormatIndexNameA);
113++ ensureOplogEntryExists(localDB, cmdFormatIndexNameB);
114+
115+- // Make sure the index was replicated to the secondaries.
116++ // Make sure the indexes were replicated to the secondaries.
117+ let secondaries = rst.getSecondaries();
118+ for (let j = 0; j < secondaries.length; j++) {
119+ let secondaryTestDB = secondaries[j].getDB(dbName);
120+- ensureIndexExists(secondaryTestDB, collName, cmdFormatIndexName, 2);
121++ ensureIndexExists(secondaryTestDB, collName, cmdFormatIndexNameA, 3);
122++ ensureIndexExists(secondaryTestDB, collName, cmdFormatIndexNameB, 3);
123+ }
124+
125+ // Create an index by inserting into system.indexes in applyOps.
126+diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
127+index db55e1560e4..076d8253059 100644
128+--- a/src/mongo/db/repl/oplog.cpp
129++++ b/src/mongo/db/repl/oplog.cpp
130+@@ -789,7 +789,7 @@ std::map<std::string, ApplyOpMetadata> opsMap = {
131+ BSONObj& cmd,
132+ const OpTime& opTime,
133+ OplogApplication::Mode mode) -> Status {
134+- const NamespaceString nss(parseUUID(opCtx, ui));
135++ const NamespaceString nss(parseUUIDorNs(opCtx, ns, ui, cmd));
136+ BSONElement first = cmd.firstElement();
137+ invariant(first.fieldNameStringData() == "createIndexes");
138+ uassert(ErrorCodes::InvalidNamespace,
139diff --git a/debian/patches/series b/debian/patches/series
140index 5d72f11..63ec92e 100644
141--- a/debian/patches/series
142+++ b/debian/patches/series
143@@ -5,3 +5,4 @@ fix-ftbfs-with-gcc-7.patch
144 fix-altivec-endianness.patch
145 SERVER-34117-skip-dns-tests.patch
146 strip-test-binaries.patch
147+SERVER-36951-applyOps-createIndexes-without-uuid.patch

Subscribers

People subscribed via source and target branches