SERVER-118711 Revert SERVER-113888 SERVER-113889 (#48090)
GitOrigin-RevId: ea633db31f853ce5f1f207d47fa150d0f4ca706d
This commit is contained in:
parent
dcc1dbb423
commit
d4b6bdff20
@ -498,8 +498,6 @@ last-continuous:
|
||||
ticket: SERVER-113887
|
||||
- test_file: jstests/sharding/disable_resumable_range_deleter.js
|
||||
ticket: SERVER-112357
|
||||
- test_file: jstests/core/index/index_on_incorrect_collection.js
|
||||
ticket: SERVER-113888
|
||||
- test_file: jstests/core_sharding/ddl/cannot_track_temporary_collection.js
|
||||
ticket: SERVER-114666
|
||||
- test_file: jstests/core/query/regex/regex_max_pattern_length.js
|
||||
@ -1077,8 +1075,6 @@ last-lts:
|
||||
ticket: SERVER-113887
|
||||
- test_file: jstests/sharding/disable_resumable_range_deleter.js
|
||||
ticket: SERVER-112357
|
||||
- test_file: jstests/core/index/index_on_incorrect_collection.js
|
||||
ticket: SERVER-113888
|
||||
- test_file: jstests/core_sharding/ddl/cannot_track_temporary_collection.js
|
||||
ticket: SERVER-114666
|
||||
- test_file: jstests/core/query/regex/regex_max_pattern_length.js
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
/**
|
||||
* If an incompatible index exists on a collection, the server should prevent updates to that index
|
||||
* with non-fatal errors.
|
||||
*/
|
||||
|
||||
import {after, before, describe, it} from "jstests/libs/mochalite.js";
|
||||
|
||||
describe(
|
||||
"Nonfatal error when attempting to update an improper timeseries-only index on a non-timeseries collection.",
|
||||
function() {
|
||||
const collName = jsTestName();
|
||||
before(function() {
|
||||
this.coll = db.getCollection(collName);
|
||||
this.coll.drop();
|
||||
assert.commandWorked(db.createCollection(collName));
|
||||
});
|
||||
|
||||
it("Prevents updating 2dsphere_bucket indices for top-level measurements", function() {
|
||||
// Authorization rules will normally prevent a non-system user from creating this index.
|
||||
assert.commandWorked(this.coll.createIndex({x: "2dsphere_bucket"}));
|
||||
assert.commandFailed(this.coll.insert({control: {version: 2}, x: HexData(0, "00")}));
|
||||
});
|
||||
|
||||
it("Prevents updating 2dsphere_bucket indices for nested measurements", function() {
|
||||
// Authorization rules will normally prevent a non-system user from creating this index.
|
||||
assert.commandWorked(this.coll.createIndex({"data.a.b.c": "2dsphere_bucket"}));
|
||||
assert.commandFailed(
|
||||
this.coll.insert({control: {version: 2}, data: {a: {b: {c: [0, 0]}}}}));
|
||||
});
|
||||
|
||||
after(function() {
|
||||
this.coll.drop();
|
||||
});
|
||||
});
|
||||
@ -1,66 +0,0 @@
|
||||
/**
|
||||
* Ensures that a createIndexes command request fails when creating an index with illegal options.
|
||||
*/
|
||||
|
||||
import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js";
|
||||
import {after, afterEach, before, describe, it} from "jstests/libs/mochalite.js";
|
||||
|
||||
describe("Specifying index type in the createIndex command", function() {
|
||||
const collName = jsTestName();
|
||||
const testUser = "mongo";
|
||||
const testPass = "mongo";
|
||||
|
||||
before(function() {
|
||||
this.conn = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1"});
|
||||
this.admin = this.conn.getDB("admin");
|
||||
this.admin.createUser({user: testUser, pwd: testPass, roles: jsTest.adminUserRoles});
|
||||
this.admin.logout();
|
||||
this.admin.auth({user: testUser, pwd: testPass});
|
||||
this.db = this.admin.getSiblingDB("test");
|
||||
});
|
||||
|
||||
const illegalIndexTypes = [
|
||||
{type: "2dsphere_bucket", codes: [ErrorCodes.IndexOptionsConflict]},
|
||||
{type: "queryable_encrypted_range", codes: [ErrorCodes.IndexOptionsConflict]},
|
||||
{type: "wildcard", codes: [7246202]},
|
||||
{type: "columnstore", codes: [ErrorCodes.NotImplemented]},
|
||||
{type: "geoHaystack", codes: [ErrorCodes.CannotCreateIndex]},
|
||||
];
|
||||
|
||||
const legalIndexTypes = [1, "2d", "2dsphere", "text", "hashed"];
|
||||
illegalIndexTypes.forEach((args) => {
|
||||
const indexType = args.type;
|
||||
const expectedErrorCodes = args.codes;
|
||||
it(`Cannot create a '${indexType}' index`, function() {
|
||||
this.testCollName = collName + "." + indexType;
|
||||
assert.commandFailedWithCode(
|
||||
this.db[this.testCollName].createIndex({"foo": indexType}),
|
||||
expectedErrorCodes,
|
||||
);
|
||||
// TODO(SERVER-114308): Primary-driven index builds eagerly create the collection, this
|
||||
// assertion will fail on those build variants.
|
||||
if (!FeatureFlagUtil.isPresentAndEnabled(this.db, "PrimaryDrivenIndexBuilds")) {
|
||||
assert.doesNotContain(
|
||||
this.db.getCollectionNames(),
|
||||
[this.testCollName],
|
||||
`The ${this.testCollName} collection should not be implicitly created upon failing to create the index.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
legalIndexTypes.forEach(function(indexType) {
|
||||
it(`Can create a '${indexType == 1 ? "btree" : indexType}' index`, function() {
|
||||
this.testCollName = collName + "." + indexType;
|
||||
assert.commandWorked(this.db[this.testCollName].createIndex({"foo": indexType}));
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.db[this.testCollName].drop();
|
||||
});
|
||||
|
||||
after(function() {
|
||||
MongoRunner.stopMongod(this.conn);
|
||||
});
|
||||
});
|
||||
@ -203,31 +203,6 @@ void validateTTLOptions(OperationContext* opCtx,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the user is authorized to create an index of a given type.
|
||||
*/
|
||||
void validateIndexType(OperationContext* opCtx, const CreateIndexesCommand& cmd) {
|
||||
const boost::optional<auth::ValidatedTenancyScope>& vts =
|
||||
auth::ValidatedTenancyScope::get(opCtx);
|
||||
const auto tenantId =
|
||||
vts && vts->hasTenantId() ? boost::make_optional(vts->tenantId()) : boost::none;
|
||||
|
||||
const bool isAuthForInternal =
|
||||
AuthorizationSession::get(opCtx->getClient())
|
||||
->isAuthorizedForActionsOnResource(ResourcePattern::forClusterResource(tenantId),
|
||||
ActionType::internal);
|
||||
for (const auto& elem : cmd.getIndexes()) {
|
||||
for (const auto& key : elem.getField("key").Obj()) {
|
||||
const auto type = key.str(); // will return "" for btree
|
||||
if (IndexNames::isInternalOnly(type)) {
|
||||
uassert(ErrorCodes::IndexOptionsConflict,
|
||||
fmt::format("Index Type {} is for internal use only", type),
|
||||
isAuthForInternal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkEncryptedFieldIndexRestrictions(OperationContext* opCtx,
|
||||
const Collection* coll,
|
||||
const CreateIndexesCommand& cmd) {
|
||||
@ -586,7 +561,6 @@ CreateIndexesReply runCreateIndexesWithCoordinator(OperationContext* opCtx,
|
||||
}
|
||||
|
||||
validateTTLOptions(opCtx, collection.getCollectionPtr().get(), cmd);
|
||||
validateIndexType(opCtx, cmd);
|
||||
|
||||
if (collection.exists() &&
|
||||
!UncommittedCatalogUpdates::get(opCtx).isCreatedCollection(opCtx, ns)) {
|
||||
|
||||
@ -106,18 +106,4 @@ IndexType IndexNames::nameToType(StringData accessMethod) {
|
||||
return typeIt->second;
|
||||
}
|
||||
|
||||
// static
|
||||
bool IndexNames::isInternalOnly(const std::string& name) {
|
||||
if (isKnownName(name)) {
|
||||
switch (nameToType(name)) {
|
||||
case INDEX_2DSPHERE_BUCKET:
|
||||
case INDEX_ENCRYPTED_RANGE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
@ -86,11 +86,6 @@ public:
|
||||
* Convert an index name to an IndexType.
|
||||
*/
|
||||
static IndexType nameToType(StringData accessMethod);
|
||||
|
||||
/**
|
||||
* Index is not intended to be user facing.
|
||||
*/
|
||||
static bool isInternalOnly(const std::string& name);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -174,7 +174,7 @@ boost::optional<BSONColumn> _extractAllElementsAlongBucketPath(
|
||||
case 0:
|
||||
case 1: {
|
||||
if (auto res = _splitPath(path)) {
|
||||
const auto& [left, next] = *res;
|
||||
auto& [left, next] = *res;
|
||||
BSONElement e = obj.getField(left);
|
||||
if (depth > 0 || left == timeseries::kBucketDataFieldName) {
|
||||
if (e.type() == BSONType::object) {
|
||||
@ -229,9 +229,7 @@ boost::optional<BSONColumn> _extractAllElementsAlongBucketPath(
|
||||
// measurement field (i.e. data.a) and we need to iterate over each of the
|
||||
// numerically-indexed entries (i.e. data.a.1, data.a.5, etc.) to extract
|
||||
// the actual field we want.
|
||||
massert(11388801,
|
||||
"Malformed measurement field in compressed timeseries bucket",
|
||||
depth == 1);
|
||||
invariant(depth == 1);
|
||||
BSONColumn storage{e};
|
||||
for (const BSONElement& e2 : storage) {
|
||||
if (!e2.eoo()) {
|
||||
@ -253,7 +251,7 @@ boost::optional<BSONColumn> _extractAllElementsAlongBucketPath(
|
||||
// numerically-indexed entries (i.e. data.a.1, data.a.5, etc.) to extract the actual
|
||||
// field we want. If we are after a top-level field, then we already have the element we
|
||||
// want in 'e'. If we are after a nested field, then we need to recurse.
|
||||
massert(11388802, "Expected uncompressed bucket", !isCompressed);
|
||||
invariant(!isCompressed);
|
||||
for (const BSONElement& e : obj) {
|
||||
if (path.empty()) {
|
||||
// The top-level measurement field (i.e. data.a) is the indexed field we are
|
||||
|
||||
Loading…
Reference in New Issue
Block a user