fix: TTL bump on markets storage reads#1017
Open
ogaziedaniel80-droid wants to merge 1 commit into
Open
Conversation
Bump persistent storage TTL on hot read paths in markets to prevent frequently-accessed markets from expiring. - MarketStateManager::get_market(): extend TTL on cache miss (persistent read) - QueryManager::get_market_from_storage(): extend TTL on query reads - Added 4 focused tests covering cache miss bump, cache hit non-bump, max_ttl clamp - Changed get_market_from_storage visibility to pub(crate) for testability Closes Predictify-org#861
|
@ogaziedaniel80-droid Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bump persistent storage TTL on hot read paths in markets to prevent frequently-accessed markets from expiring.
Changes
MarketStateManager::get_market()extends persistent TTL on cache missQueryManager::get_market_from_storage()extends persistent TTL on query readsget_market_from_storagevisibility topub(crate)for testabilityAcceptance Criteria
cargo test --package predictify-hybrid)cargo clippy)Implementation Details
Problem
Market storage reads on hot paths did not bump persistent TTL, meaning frequently-queried markets could expire even while actively used.
Solution
Added TTL extension calls using
MARKET_TTL_LEDGERS.min(env.storage().max_ttl())on two hot read paths:Cache miss in
get_market()(markets.rs): When a market is fetched from persistent storage and not in the instance cache, the persistent TTL is extended to the full market tier.Direct reads in
get_market_from_storage()(queries.rs): All query functions that bypass the instance cache now extend persistent TTL on read.Tests
test_get_market_bumps_persistent_ttl_on_cache_miss— verifies TTL refresh on cache misstest_get_market_cache_hit_does_not_bump_persistent_ttl— verifies cache hits only bump instance TTLtest_get_market_ttl_bump_respects_max_ttl— verifies TTL never exceeds max_ttl()test_get_market_from_storage_bumps_persistent_ttl— verifies query path TTL refreshCloses #861