Show
1. Start single node replica set, i.e. ./mongo --replSet test
2. ./mongo --eval "rs.initiate();"
3. Run script. It takes ~40 minutes to hit the error.
db.getSiblingDB("test").dropDatabase();
db.keystore.drop();
const localKMS = {
key: BinData(
0,
"/tu9jUCBqZdwCelwE/EAm/4WqdxrSMi04B8e9uAV+m30rI1J2nhKZZtQjdvsSCwuI4erR6IEcEK+5eGUAODv43NDNIR9QheT2edWFewUfHKsl9cnzTc86meIzOmYl6dr")
};
const clientSideFLEOptions = {
kmsProviders: {
local: localKMS,
},
keyVaultNamespace: "test.keystore",
schemaMap: {},
};
const shell = Mongo("localhost:27017", clientSideFLEOptions);
const edb = shell.getDB("test");
const keyVault = shell.getKeyVault();
keyVault.createKey(
"local", "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e3687b580d0");
assert.commandWorked(db.createEncryptedCollection("basic", {
encryptedFields: {
"fields": [
{
"path": "ssn",
"keyId": keyVault.createKey(
"local", "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e3687b580d0"),
"bsonType": "string",
"queries": { "queryType": "equality" }
},
{
"path": "mobile",
"keyId": keyVault.createKey(
"local", "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e3687b580d0"),
"bsonType": "string",
"queries": { "queryType": "equality" }
},
{
"path": "gender",
"keyId": keyVault.createKey(
"local", "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e3687b580d0"),
"bsonType": "string",
"queries": { "queryType": "equality" }
}
]
}
}));
print("Starting Load: " + new Date());
for (let i = 0; i < 10000000; i++) {
if (i % 100 == 0) { print(i + " ") }
let mobile = Math.random().toString().slice(2, 11);
mobile = mobile.slice(0, 3) + "-" + mobile.slice(3, 6) + "-" + mobile.slice(6);
const ssn = Math.random().toString().slice(2, 11);
const g = Math.floor(Math.random() * 10);
const gender = g < 2 ? "they" : g < 6 ? "she" : "he";
try {
edb.basic.insertOne({
name: "John Doe",
mobile: mobile,
ssn: ssn,
address: "157 Electric Ave.",
gender: gender,
});
} catch (e) {
let d = new Date();
print("\nException on load: " + d + "||" + e);
}
}
print("Done loading: " + new Date())
4. After 40 minutes, operations will be interrupted and visible in the shell as follows
Exception on load: <DATE> ||WriteError({
"index": 0,
"code" : 11601,
"errmsg" : "operation was interrupted",
...
})