SERVER-115326: Don't reset logical session cache reaper metrics prematurely (#46151)
GitOrigin-RevId: 0938e8144141fdf13b416258b5b61b6cf3e3b34b
This commit is contained in:
parent
701f29ddcc
commit
45279cc75b
@ -89,6 +89,13 @@ LogicalSessionCacheImpl::LogicalSessionCacheImpl(std::unique_ptr<ServiceLiaison>
|
||||
_reapSessionsOlderThanFn(std::move(reapSessionsOlderThanFn)) {
|
||||
_stats.setLastSessionsCollectionJobTimestamp(_service->now());
|
||||
_stats.setLastTransactionReaperJobTimestamp(_service->now());
|
||||
_stats.setLastTransactionReaperJobDurationUpdatedTimestamp(_service->now());
|
||||
_stats.setLastTransactionReaperJobEntriesCleanedUpUpdatedTimestamp(_service->now());
|
||||
_stats.setLastSessionsCollectionJobDurationMillisUpdatedTimestamp(_service->now());
|
||||
_stats.setLastSessionsCollectionJobEntriesRefreshedUpdatedTimestamp(_service->now());
|
||||
_stats.setLastSessionsCollectionJobEntriesEndedUpdatedTimestamp(_service->now());
|
||||
_stats.setLastSessionsCollectionJobCursorsClosedUpdatedTimestamp(_service->now());
|
||||
|
||||
|
||||
// Skip initializing this background thread when using 'recoverFromOplogAsStandalone=true',
|
||||
// --magicRestore, or --queryableBackupMode as the server is put in read-only mode after oplog
|
||||
@ -206,11 +213,6 @@ Status LogicalSessionCacheImpl::_reap(Client* client) {
|
||||
// Take the lock to update some stats.
|
||||
{
|
||||
stdx::lock_guard<stdx::mutex> lk(_mutex);
|
||||
|
||||
// Clear the last set of stats for our new run.
|
||||
_stats.setLastTransactionReaperJobDurationMillis(0);
|
||||
_stats.setLastTransactionReaperJobEntriesCleanedUp(0);
|
||||
|
||||
// Start the new run.
|
||||
_stats.setLastTransactionReaperJobTimestamp(_service->now());
|
||||
_stats.setTransactionReaperJobCount(_stats.getTransactionReaperJobCount() + 1);
|
||||
@ -237,6 +239,7 @@ Status LogicalSessionCacheImpl::_reap(Client* client) {
|
||||
stdx::lock_guard<stdx::mutex> lk(_mutex);
|
||||
auto millis = _service->now() - _stats.getLastTransactionReaperJobTimestamp();
|
||||
_stats.setLastTransactionReaperJobDurationMillis(millis.count());
|
||||
_stats.setLastTransactionReaperJobDurationUpdatedTimestamp(_service->now());
|
||||
}
|
||||
|
||||
return ex.toStatus();
|
||||
@ -246,7 +249,9 @@ Status LogicalSessionCacheImpl::_reap(Client* client) {
|
||||
stdx::lock_guard<stdx::mutex> lk(_mutex);
|
||||
auto millis = _service->now() - _stats.getLastTransactionReaperJobTimestamp();
|
||||
_stats.setLastTransactionReaperJobDurationMillis(millis.count());
|
||||
_stats.setLastTransactionReaperJobDurationUpdatedTimestamp(_service->now());
|
||||
_stats.setLastTransactionReaperJobEntriesCleanedUp(numReaped);
|
||||
_stats.setLastTransactionReaperJobEntriesCleanedUpUpdatedTimestamp(_service->now());
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
@ -275,13 +280,6 @@ void LogicalSessionCacheImpl::_refresh(Client* client) {
|
||||
// Stats for serverStatus:
|
||||
{
|
||||
stdx::lock_guard<stdx::mutex> lk(_mutex);
|
||||
|
||||
// Clear the refresh-related stats with the beginning of our run.
|
||||
_stats.setLastSessionsCollectionJobDurationMillis(0);
|
||||
_stats.setLastSessionsCollectionJobEntriesRefreshed(0);
|
||||
_stats.setLastSessionsCollectionJobEntriesEnded(0);
|
||||
_stats.setLastSessionsCollectionJobCursorsClosed(0);
|
||||
|
||||
// Start the new run.
|
||||
_stats.setLastSessionsCollectionJobTimestamp(_service->now());
|
||||
_stats.setSessionsCollectionJobCount(_stats.getSessionsCollectionJobCount() + 1);
|
||||
@ -292,6 +290,7 @@ void LogicalSessionCacheImpl::_refresh(Client* client) {
|
||||
stdx::lock_guard<stdx::mutex> lk(_mutex);
|
||||
auto millis = _service->now() - _stats.getLastSessionsCollectionJobTimestamp();
|
||||
_stats.setLastSessionsCollectionJobDurationMillis(millis.count());
|
||||
_stats.setLastSessionsCollectionJobDurationMillisUpdatedTimestamp(_service->now());
|
||||
});
|
||||
|
||||
ON_BLOCK_EXIT([&opCtx] { clearShardingOperationFailedStatus(opCtx); });
|
||||
@ -321,7 +320,7 @@ void LogicalSessionCacheImpl::_refresh(Client* client) {
|
||||
}
|
||||
};
|
||||
ScopeGuard activeSessionsBackSwapper([&] { backSwap(_activeSessions, activeSessions); });
|
||||
auto explicitlyEndingBackSwaper =
|
||||
auto explicitlyEndingBackSwapper =
|
||||
ScopeGuard([&] { backSwap(_endingSessions, explicitlyEndingSessions); });
|
||||
|
||||
// remove all explicitlyEndingSessions from activeSessions
|
||||
@ -351,14 +350,16 @@ void LogicalSessionCacheImpl::_refresh(Client* client) {
|
||||
{
|
||||
stdx::lock_guard<stdx::mutex> lk(_mutex);
|
||||
_stats.setLastSessionsCollectionJobEntriesRefreshed(activeSessionRecords.size());
|
||||
_stats.setLastSessionsCollectionJobEntriesRefreshedUpdatedTimestamp(_service->now());
|
||||
}
|
||||
|
||||
// Remove the ending sessions from the sessions collection.
|
||||
_sessionsColl->removeRecords(opCtx, explicitlyEndingSessions);
|
||||
explicitlyEndingBackSwaper.dismiss();
|
||||
explicitlyEndingBackSwapper.dismiss();
|
||||
{
|
||||
stdx::lock_guard<stdx::mutex> lk(_mutex);
|
||||
_stats.setLastSessionsCollectionJobEntriesEnded(explicitlyEndingSessions.size());
|
||||
_stats.setLastSessionsCollectionJobEntriesEndedUpdatedTimestamp(_service->now());
|
||||
}
|
||||
|
||||
// Find which running, but not recently active sessions, are expired, and add them
|
||||
@ -401,6 +402,7 @@ void LogicalSessionCacheImpl::_refresh(Client* client) {
|
||||
{
|
||||
stdx::lock_guard<stdx::mutex> lk(_mutex);
|
||||
_stats.setLastSessionsCollectionJobCursorsClosed(killRes);
|
||||
_stats.setLastSessionsCollectionJobCursorsClosedUpdatedTimestamp(_service->now());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,25 +51,37 @@ structs:
|
||||
lastSessionsCollectionJobDurationMillis:
|
||||
type: int
|
||||
default: 0
|
||||
lastSessionsCollectionJobDurationMillisUpdatedTimestamp:
|
||||
type: date
|
||||
lastSessionsCollectionJobTimestamp:
|
||||
type: date
|
||||
lastSessionsCollectionJobEntriesRefreshed:
|
||||
type: int
|
||||
default: 0
|
||||
lastSessionsCollectionJobEntriesRefreshedUpdatedTimestamp:
|
||||
type: date
|
||||
lastSessionsCollectionJobEntriesEnded:
|
||||
type: int
|
||||
default: 0
|
||||
lastSessionsCollectionJobEntriesEndedUpdatedTimestamp:
|
||||
type: date
|
||||
lastSessionsCollectionJobCursorsClosed:
|
||||
type: int
|
||||
default: 0
|
||||
lastSessionsCollectionJobCursorsClosedUpdatedTimestamp:
|
||||
type: date
|
||||
transactionReaperJobCount:
|
||||
type: int
|
||||
default: 0
|
||||
lastTransactionReaperJobDurationMillis:
|
||||
type: int
|
||||
default: 0
|
||||
lastTransactionReaperJobDurationUpdatedTimestamp:
|
||||
type: date
|
||||
lastTransactionReaperJobTimestamp:
|
||||
type: date
|
||||
lastTransactionReaperJobEntriesCleanedUp:
|
||||
type: int
|
||||
default: 0
|
||||
lastTransactionReaperJobEntriesCleanedUpUpdatedTimestamp:
|
||||
type: date
|
||||
|
||||
Loading…
Reference in New Issue
Block a user