[SERVER-29641] checkReplicatedDataHashes() throws a TypeError when replSetTest uses mongobridge Created: 14/Jun/17  Updated: 30/Oct/23  Resolved: 12/Aug/17

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.5.12

Type: Bug Priority: Major - P3
Reporter: Allison Chang Assignee: Eddie Louie
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-23219 DBCommandCursor doesn't route getMore... Closed
is related to SERVER-26298 checkReplicatedDataHashes should corr... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

repro_29641.js

(function() {
    'use strict';
 
    var testName = "bridge_failure";
    var dbName = "test";
 
    var replTest = new ReplSetTest({name: testName, nodes: 3, useBridge: true});
    var nodes = replTest.nodeList();
    var conns = replTest.startSet();
    replTest.initiate({
        "_id": testName,
        "members": [
            {"_id": 0, "host": nodes[0]},
            {"_id": 1, "host": nodes[1]},
            {"_id": 2, "host": nodes[2]}
        ]
    });
 
    replTest.checkReplicatedDataHashes(testName);
 
}());

Run with following:

buildscripts/resmoke.py --suites=replica_sets repro_29641.js --storageEngine=wiredTiger

Sprint: TIG 2017-07-31, TIG 2017-08-21
Participants:

 Description   

[js_test:rollback_rename_collection] 2017-06-14T17:37:29.400-0400 2017-06-14T17:37:29.399-0400 E QUERY    [thread1] TypeError: can't redefine non-configurable property "_mongo" :
[js_test:rollback_rename_collection] 2017-06-14T17:37:29.401-0400 ReplSetTest/this.getHashes@src/mongo/shell/replsettest.js:1083:1
[js_test:rollback_rename_collection] 2017-06-14T17:37:29.401-0400 checkDBHashesForReplSet@src/mongo/shell/replsettest.js:1278:32
[js_test:rollback_rename_collection] 2017-06-14T17:37:29.401-0400 ReplSetTest/this.checkReplicaSet@src/mongo/shell/replsettest.js:1158:13
[js_test:rollback_rename_collection] 2017-06-14T17:37:29.401-0400 ReplSetTest/this.checkReplicatedDataHashes@src/mongo/shell/replsettest.js:1406:9
[js_test:rollback_rename_collection] 2017-06-14T17:37:29.401-0400 @jstests/replsets/rollback_rename_collection.js:70:5
[js_test:rollback_rename_collection] 2017-06-14T17:37:29.401-0400 @jstests/replsets/rollback_rename_collection.js:25:2
[js_test:rollback_rename_collection] 2017-06-14T17:37:29.402-0400 failed to load: jstests/replsets/rollback_rename_collection.js
[js_test:rollback_rename_collection] 2017-06-14T17:37:29.402-0400 d20015| 2017-06-14T17:37:29.399-0400 I CONTROL  [signalProcessingThread] got signal 15 (Terminated: 15), will terminate after current cmd ends



 Comments   
Comment by Githook User [ 12/Aug/17 ]

Author:

{'name': 'Eddie Louie', 'username': 'elouie99', 'email': 'eddie.louie@mongodb.com'}

Message: SERVER-29641 Remove code that redefines property _mongo in response object
Branch: master
https://github.com/mongodb/mongo/commit/a7c6f1cb7a3564d2d6fa8ca5d41f9b014f43cb2e

Comment by Max Hirschhorn [ 11/Aug/17 ]

eddie.louie and I spent some time debugging this one together. The solution is to remove the Object.defineProperty() lines since they were unnecessary anyway (SERVER-23219 is already causing the "_mongo" property to be defined on the response object).

The idea behind the changes from SERVER-26298 (which introduced the Object.defineProperty(res.master, "_mongo", {value: this.liveNodes.master}) logic) was to make it so we didn't need to rely on the host and port when collecting diagnostics from a secondary with a different dbhash. We chose to mimic the changes from SERVER-23219 to add a "_mongo" property to the returned object representing the server connection used to make the request. The changes from SERVER-23219 had already made it so that any response from the server via Mongo.prototype.runCommand() will include the original connection as the "_mongo" property.

As to why this only fails when useBridge=true, SpiderMonkey apparently doesn't consider it an error to assign a non-configurable, non-writable property the same value as its current value via Object.defineProperty() when it is a C++ object. It does however correctly error when it is a plain-old JavaScript object:

(function() {
    "use strict";
    const obj = {};
    Object.defineProperty(obj, "prop", {value: 1});
    obj.prop = 2;
})();

throws a "TypeError: "prop" is read-only" error. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#Writable_attribute

Generated at Thu Feb 08 04:21:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.