Status WiredTigerKVEngine::repairIdent( OperationContext* opCtx, const StringData& ident ) { WiredTigerSession session( _conn, -1 ); WT_SESSION* s = session.getSession(); string uri = _uri(ident); return wtRCToStatus( s->compact(s, uri.c_str(), NULL ) ); }
StatusWith<RecordId> WiredTigerRecordStore::insertRecord(OperationContext* txn, const char* data, int len, bool enforceQuota) { if (_isCapped && len > _cappedMaxSize) { return StatusWith<RecordId>(ErrorCodes::BadValue, "object to insert exceeds cappedMaxSize"); } RecordId loc; if (_useOplogHack) { StatusWith<RecordId> status = extractAndCheckLocForOplog(data, len); if (!status.isOK()) return status; loc = status.getValue(); if (loc > _oplog_highestSeen) { stdx::lock_guard<stdx::mutex> lk(_uncommittedDiskLocsMutex); if (loc > _oplog_highestSeen) { _oplog_highestSeen = loc; } } } else if (_isCapped) { stdx::lock_guard<stdx::mutex> lk(_uncommittedDiskLocsMutex); loc = _nextId(); _addUncommitedDiskLoc_inlock(txn, loc); } else { loc = _nextId(); } WiredTigerCursor curwrap(_uri, _tableId, true, txn); curwrap.assertInActiveTxn(); WT_CURSOR* c = curwrap.get(); invariant(c); c->set_key(c, _makeKey(loc)); WiredTigerItem value(data, len); c->set_value(c, value.Get()); int ret = WT_OP_CHECK(c->insert(c)); if (ret) { return StatusWith<RecordId>(wtRCToStatus(ret, "WiredTigerRecordStore::insertRecord")); } _changeNumRecords(txn, 1); _increaseDataSize(txn, len); cappedDeleteAsNeeded(txn, loc); return StatusWith<RecordId>(loc); }
Status WiredTigerKVEngine::createRecordStore( OperationContext* opCtx, const StringData& ns, const StringData& ident, const CollectionOptions& options ) { WiredTigerSession session( _conn, -1 ); StatusWith<std::string> result = WiredTigerRecordStore::generateCreateString(ns, options, _rsOptions); if (!result.isOK()) { return result.getStatus(); } std::string config = result.getValue(); string uri = _uri( ident ); WT_SESSION* s = session.getSession(); LOG(1) << "WiredTigerKVEngine::createRecordStore uri: " << uri << " config: " << config; return wtRCToStatus( s->create( s, uri.c_str(), config.c_str() ) ); }
Status WiredTigerSnapshotManager::setTransactionReadTimestamp(Timestamp pointInTime, WT_SESSION* session, bool roundToOldest) const { char readTSConfigString[15 /* read_timestamp= */ + 16 /* 16 hexadecimal digits */ + 17 /* ,round_to_oldest= */ + 5 /* false */ + 1 /* trailing null */]; auto size = std::snprintf(readTSConfigString, sizeof(readTSConfigString), "read_timestamp=%llx,round_to_oldest=%s", pointInTime.asULL(), (roundToOldest) ? "true" : "false"); if (size < 0) { int e = errno; error() << "error snprintf " << errnoWithDescription(e); fassertFailedNoTrace(40664); } invariant(static_cast<std::size_t>(size) < sizeof(readTSConfigString)); return wtRCToStatus(session->timestamp_transaction(session, readTSConfigString)); }
Status WiredTigerRecoveryUnit::setTimestamp(Timestamp timestamp) { _ensureSession(); LOG(3) << "WT set timestamp of future write operations to " << timestamp; WT_SESSION* session = _session->getSession(); invariant(_inUnitOfWork(), toString(_state)); invariant(_prepareTimestamp.isNull()); invariant(_commitTimestamp.isNull(), str::stream() << "Commit timestamp set to " << _commitTimestamp.toString() << " and trying to set WUOW timestamp to " << timestamp.toString()); _lastTimestampSet = timestamp; // Starts the WT transaction associated with this session. getSession(); const std::string conf = "commit_timestamp=" + integerToHex(timestamp.asULL()); auto rc = session->timestamp_transaction(session, conf.c_str()); if (rc == 0) { _isTimestamped = true; } return wtRCToStatus(rc, "timestamp_transaction"); }
Status WiredTigerSnapshotManager::createSnapshot(OperationContext* opCtx, const SnapshotName& name) { auto session = WiredTigerRecoveryUnit::get(opCtx)->getSession(opCtx)->getSession(); const std::string config = str::stream() << "name=" << name.asU64(); return wtRCToStatus(session->snapshot(session, config.c_str())); }
Status WiredTigerKVEngine::createSortedDataInterface( OperationContext* opCtx, const StringData& ident, const IndexDescriptor* desc ) { return wtRCToStatus( WiredTigerIndex::Create( opCtx, _uri( ident ), _indexOptions, desc ) ); }