Storage Engine API
mongo::WiredTigerSizeStorer Class Reference

The WiredTigerSizeStorer class serves as a write buffer to durably store size information for MongoDB collections. More...

#include <wiredtiger_size_storer.h>

Detailed Description

The WiredTigerSizeStorer class serves as a write buffer to durably store size information for MongoDB collections.

The size storer uses a separate WiredTiger table as key-value store, where the URI serves as key and the value is a BSON document with numRecords and dataSize fields. This buffering is neccessary to allow concurrent updates of size information without causing write conflicts. The dirty size information is periodically stored written back to the table, including on clean shutdown and/or catalog reload. Crashes or replica-set fail-overs may result in size updates to be lost, so size information is only approximate. Reads use the buffer for pending stores, or otherwise read directly from the WiredTiger table using a dedicated session and cursor.

Classes

struct  SizeInfo
 SizeInfo is a thread-safe buffer for keeping track of the number of documents in a collection and their data size. More...
 

Public Member Functions

 WiredTigerSizeStorer (WT_CONNECTION *conn, const std::string &storageUri, const bool readOnly=false)
 
 ~WiredTigerSizeStorer ()
 
void store (StringData uri, std::shared_ptr< SizeInfo > sizeInfo)
 Ensure that the shared SizeInfo will be stored by the next call to flush. More...
 
std::shared_ptr< SizeInfoload (StringData uri) const
 
void flush (bool syncToDisk)
 Writes all changes to the underlying table. More...
 

Private Types

using Buffer = StringMap< std::shared_ptr< SizeInfo > >
 

Private Attributes

const WiredTigerSession _session
 
const bool _readOnly
 
stdx::mutex _cursorMutex
 
WT_CURSOR * _cursor
 
stdx::mutex _bufferMutex
 
Buffer _buffer
 

Member Typedef Documentation

◆ Buffer

using mongo::WiredTigerSizeStorer::Buffer = StringMap<std::shared_ptr<SizeInfo> >
private

Constructor & Destructor Documentation

◆ WiredTigerSizeStorer()

mongo::WiredTigerSizeStorer::WiredTigerSizeStorer ( WT_CONNECTION *  conn,
const std::string &  storageUri,
const bool  readOnly = false 
)

◆ ~WiredTigerSizeStorer()

mongo::WiredTigerSizeStorer::~WiredTigerSizeStorer ( )

Member Function Documentation

◆ flush()

void mongo::WiredTigerSizeStorer::flush ( bool  syncToDisk)

Writes all changes to the underlying table.

◆ load()

std::shared_ptr< WiredTigerSizeStorer::SizeInfo > mongo::WiredTigerSizeStorer::load ( StringData  uri) const

◆ store()

void mongo::WiredTigerSizeStorer::store ( StringData  uri,
std::shared_ptr< SizeInfo sizeInfo 
)

Ensure that the shared SizeInfo will be stored by the next call to flush.

Values stored are no older than the values at time of this call, but may be newer.

Member Data Documentation

◆ _buffer

Buffer mongo::WiredTigerSizeStorer::_buffer
private

◆ _bufferMutex

stdx::mutex mongo::WiredTigerSizeStorer::_bufferMutex
mutableprivate

◆ _cursor

WT_CURSOR* mongo::WiredTigerSizeStorer::_cursor
private

◆ _cursorMutex

stdx::mutex mongo::WiredTigerSizeStorer::_cursorMutex
mutableprivate

◆ _readOnly

const bool mongo::WiredTigerSizeStorer::_readOnly
private

◆ _session

const WiredTigerSession mongo::WiredTigerSizeStorer::_session
private

The documentation for this class was generated from the following files: