[SERVER-28433] Implement KeysCollectionCacheReaderAndUpdater Created: 22/Mar/17  Updated: 06/Dec/17  Resolved: 19/Apr/17

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 3.5.7

Type: Task Priority: Major - P3
Reporter: Misha Tyulenev Assignee: Randolph Tan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Sharding 2017-05-08
Participants:

 Description   

class KeysCollectionCacheReaderAndUpdater : public KeysCollectionCacheReader {
public:
    StatusWith<KeysCollectionDocument> refresh(OperationContext* opCtx) override {
        // assumption: users never insert new keys
        coll = admin.system.keys;
 
        auto currentTime = getCurrentLogicalTime(opCtx);
 
        // readConcern level local
        cursor = coll.find({ purpose: _purpose, expiresAt: { $gt: currentTime }}).sort({ expiresAt: 1 });
        
        // all writes have { w: majority } write concern
 
        if (!cursor.hasNext()) {
            currentKeyExpiresAt = currentTime + _keyRotationInterval;
            coll.insert({ newKey using currentKeyExpirsAt });
        }
        else {
            currentKeyExpiresAt = cursor.next()["expiresAt"];
        }
        
        // Create a new key in advance if we don't have a key on standby after the current one
        // expires.
        if (!cursor.hasNext()) {
            reserveKeyExpiresAt = currentKeyExpiresAt + _keyRotationInterval;
            coll.insert({ newKey using reserveKeyExpiresAt });
        }
        
        return KeysCollectionCacheReader::refresh(opCtx);
    }
    
private:
    std::string _purpose;
};



 Comments   
Comment by Githook User [ 18/Apr/17 ]

Author:

{u'username': u'renctan', u'name': u'Randolph Tan', u'email': u'randolph@10gen.com'}

Message: SERVER-28433 Use mock DistLockManager in test
Branch: master
https://github.com/mongodb/mongo/commit/89931a9ab6942c8f55afa1a523ac8fb0801ba731

Comment by Githook User [ 18/Apr/17 ]

Author:

{u'username': u'renctan', u'name': u'Randolph Tan', u'email': u'randolph@10gen.com'}

Message: Revert "Revert "SERVER-28433 Implement KeysCollectionCacheReaderAndUpdater""

This reverts commit bae70bcec33c9e45a8adfa54c8e4468b60093d04.
Branch: master
https://github.com/mongodb/mongo/commit/ecb02672a5bb3c2de35729278bb0537e8df3aefd

Comment by Githook User [ 18/Apr/17 ]

Author:

{u'username': u'dgottlieb', u'name': u'Daniel Gottlieb', u'email': u'daniel.gottlieb@10gen.com'}

Message: Revert "SERVER-28433 Implement KeysCollectionCacheReaderAndUpdater"

This reverts commit 5fa258635ab142b502ebf055f15b7613d20f8f30.
Branch: master
https://github.com/mongodb/mongo/commit/bae70bcec33c9e45a8adfa54c8e4468b60093d04

Comment by Githook User [ 17/Apr/17 ]

Author:

{u'username': u'renctan', u'name': u'Randolph Tan', u'email': u'randolph@10gen.com'}

Message: SERVER-28433 Implement KeysCollectionCacheReaderAndUpdater
Branch: master
https://github.com/mongodb/mongo/commit/5fa258635ab142b502ebf055f15b7613d20f8f30

Comment by Misha Tyulenev [ 03/Apr/17 ]

refresh - lgtm. Not sure what is planned for the getKey.
One of the solution to avoid majority reads is to issue a majority write in he refresh method so the value cant be rolled back and update the _key and _expiresAt

Comment by Randolph Tan [ 30/Mar/17 ]

misha.tyulenev, can you take a look at the pseudo code for the design.

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