-
Notifications
You must be signed in to change notification settings - Fork 18
WMSDK-510: Remove fatal error through loadPersistentStores, add fallbacks and states. New trim DB size if needed. #594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…acks and states. New trim DB size if needed.
cc35567 to
189c7f5
Compare
189c7f5 to
4562b9e
Compare
| public let writesPerTrimCheck: Int | ||
| public let trimCooldownSec: TimeInterval | ||
|
|
||
| public static let `default` = LoggerDBConfig( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это просто эвристические параметры?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да. Удобно вынести стало из-за их роста и для подстановки в тесты
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the MindboxLogger Core Data management system to remove fatal errors during store loading, adds better error handling with fallback states, and implements a new database trimming mechanism to manage storage size.
- Replace fatal errors with graceful degradation to a disabled state when database loading fails
- Add comprehensive database trimming functionality with configurable policies for managing store size
- Refactor persistence loading into a modular loader system with better error recovery
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| MindboxLogger/Shared/LoggerRepository/MBLoggerCoreDataManager.swift | Main refactor removing fatal errors, adding state management and trimming logic |
| MindboxLogger/Shared/LoggerRepository/LoggerDatabaseLoader.swift | New modular database loader with auto-recovery from corruption |
| MindboxLogger/Shared/LoggerRepository/LogStoreTrimmer.swift | New trimming component with configurable policies and cooldown management |
| MindboxLogger/Shared/LoggerRepository/SQLiteLogicalSizeMeasurer.swift | New component for measuring actual SQLite database size |
| MindboxLogger/Shared/LoggerRepository/LoggerDBConfig.swift | Configuration structure for database management policies |
| MindboxTests/MindboxLogger/MBLoggerCoreDataManagerTests.swift | Updated tests for new functionality and refactored test helpers |
| MindboxTests/MindboxLogger/Mocks/TestContainers.swift | New test mocks for database loading scenarios |
| MindboxTests/MindboxLogger/LoggerDatabaseLoaderTests.swift | Tests for the new database loader functionality |
| MindboxTests/MindboxLogger/LogStoreTrimmerTests.swift | Tests for the trimming component |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| let sizeKB = precomputedSizeKB ?? sizeMeasurer.sizeKB() | ||
| guard let fraction = computeTrimFraction(sizeKB: sizeKB, limitKB: config.dbSizeLimitKB) else { return false } | ||
| try delete(fraction) | ||
| cooldownUntil = clock.now.addingTimeInterval(config.trimCooldownSec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему не наоборот? Хранить последнее время и каждый раз проверять добавляя интервал
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Удобно было сделать deadline "до какого времени нельзя". Но можно и как ты предложил. Пока нигде не аффектят оба варианта.
Issue