[SERVER-36397] Embedded Server SDK Should Return Error When TTL Index Creation is Attempted Created: 01/Aug/18  Updated: 29/Oct/23  Resolved: 08/Aug/18

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.0.2, 4.1.2

Type: Improvement Priority: Major - P3
Reporter: Matt Lord (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-42566 mobile SE variants don't honor timing... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.0
Sprint: Platforms 2018-08-13
Participants:

 Description   

The Embedded Server doesn't support TTL indexes today – because there are no background threads in the Embedded Server, and there's a dedicated background thread used for expiring TTL indexes – so we should return an error when a user tries to create them. We don't seem to be doing that today though:

From the client side:

test@mongolord> version()
4.1.1-189-g114b1e828e
test@mongolord> db.version()
4.1.1-189-g114b1e828e
test@mongolord> db.serverStatus().storageEngine
{
	"name" : "mobile",
	"supportsCommittedReads" : false,
	"supportsSnapshotReadConcern" : false,
	"readOnly" : false,
	"persistent" : true
}
test@mongolord> use test;
switched to db test
test@mongolord> db.ttltest.insertOne( {"name":"Matt Lord", "age":42, "inserted":new Date()} );
{
	"acknowledged" : true,
	"insertedId" : ObjectId("5b63166b9904d20a99a3faba")
}
test@mongolord> db.ttltest.find()
{ "_id" : ObjectId("5b63166b9904d20a99a3faba"), "name" : "Matt Lord", "age" : 42, "inserted" : ISODate("2018-08-02T14:34:19.480Z") }
test@mongolord> db.ttltest.createIndex( {"inserted":1}, {expireAfterSeconds:3} );
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
test@mongolord> sleep(15000);
test@mongolord> db.ttltest.find();
{ "_id" : ObjectId("5b63166b9904d20a99a3faba"), "name" : "Matt Lord", "age" : 42, "inserted" : ISODate("2018-08-02T14:34:19.480Z") }

From the Server side:

mongolord:mongo matt$ ./mongoed --dbpath /tmp/
2018-08-02T10:32:48.208-0400 I -        [main] MongoDB embedded standalone application, for testing purposes only
2018-08-02T10:32:48.258-0400 I CONTROL  [initandlisten] MongoDB starting : pid=32931 port=27017 dbpath=/tmp/ 64-bit
2018-08-02T10:32:48.284-0400 I STORAGE  [initandlisten] createCollection: admin.system.version with provided UUID: c8856c07-86c3-4c33-ab0b-6ef6990450df
2018-08-02T10:32:48.294-0400 W ASIO     [initandlisten] No TransportLayer configured during NetworkInterface startup
2018-08-02T10:32:48.296-0400 I COMMAND  [initandlisten] setting featureCompatibilityVersion to 4.2
2018-08-02T10:32:48.301-0400 I NETWORK  [initandlisten] waiting for connections on port 27017
2018-08-02T10:32:56.420-0400 I NETWORK  [listener] connection accepted from 127.0.0.1:65244 #1 (1 connection now open)
2018-08-02T10:32:56.423-0400 I NETWORK  [conn1] received client metadata from 127.0.0.1:65244 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.1.1-189-g114b1e828e" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "17.7.0" } }
2018-08-02T10:34:19.492-0400 I STORAGE  [conn1] createCollection: test.ttltest with generated UUID: 67ff252c-4685-4fbb-b438-4e49c92c5ca0
2018-08-02T10:34:19.510-0400 I INDEX    [conn1] build index on: test.ttltest properties: { v: 2, key: { inserted: 1.0 }, name: "inserted_1", ns: "test.ttltest", expireAfterSeconds: 3.0 }
2018-08-02T10:34:19.510-0400 I INDEX    [conn1] 	 building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2018-08-02T10:34:19.511-0400 I INDEX    [conn1] build index done.  scanned 1 total records. 0 secs

 
We should return an error to the client immediately that TTL indexes are not supported, like we currently do for capped collections.



 Comments   
Comment by Githook User [ 08/Aug/18 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-36397 Don't allow creation of TTL indexes in embedded.

(cherry picked from commit dbf1808cb4a7def9066fcb95df32dc50da9bb449)
Branch: v4.0
https://github.com/mongodb/mongo/commit/ec69188ab4909dad5a3e405615b1f4c4982057b3

Comment by Henrik Edin [ 08/Aug/18 ]

Pushed with the wrong ticket number:

Author:

{'username': 'henrikedin', 'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com'}

Message: SERVER-36391 Don't allow creation of TTL indexes in embedded.
Branch: master
https://github.com/mongodb/mongo/commit/dbf1808cb4a7def9066fcb95df32dc50da9bb449

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