Context
Raised as a suggestion on the session manager's checkSession implementation.
Currently, the cache liveness check in checkSession compares only MetadataKeyBackendIDs to detect cross-pod metadata drift:
if cachedIDs, present := sess.GetMetadata()[vmcpsession.MetadataKeyBackendIDs]; present {
if cachedIDs != metadata[vmcpsession.MetadataKeyBackendIDs] {
return cache.ErrExpired
}
}
Problem
This approach requires checkSession to know which specific metadata key to inspect. If new metadata keys are introduced in the future, staleness detection won't cover them unless checkSession is explicitly updated. The session manager doesn't need to care about which key drifted — if in-memory state doesn't match storage, it should evict and let the next restore pick up current state.
Suggestion
Replace the per-key comparison with maps.Equal over the full metadata maps:
if !maps.Equal(sess.GetMetadata(), metadata) {
return cache.ErrExpired
}
Both sides are map[string]string, so maps.Equal works directly with no reflection overhead. This gives all present and future metadata keys staleness detection for free without any further changes to checkSession.
Acceptance Criteria
References
Context
Raised as a suggestion on the session manager's
checkSessionimplementation.Currently, the cache liveness check in
checkSessioncompares onlyMetadataKeyBackendIDsto detect cross-pod metadata drift:Problem
This approach requires
checkSessionto know which specific metadata key to inspect. If new metadata keys are introduced in the future, staleness detection won't cover them unlesscheckSessionis explicitly updated. The session manager doesn't need to care about which key drifted — if in-memory state doesn't match storage, it should evict and let the next restore pick up current state.Suggestion
Replace the per-key comparison with
maps.Equalover the full metadata maps:Both sides are
map[string]string, somaps.Equalworks directly with no reflection overhead. This gives all present and future metadata keys staleness detection for free without any further changes tocheckSession.Acceptance Criteria
checkSessionusesmaps.Equalto compare the full metadata mapsMetadataKeyBackendIDscomparison is removedcheckSessionReferences