Skip to content

Conversation

@justSmK
Copy link
Contributor

@justSmK justSmK commented Sep 11, 2025

@justSmK justSmK requested a review from enotniy September 11, 2025 12:36
@justSmK justSmK force-pushed the feature/WMSDK-510-fatalError-MBLogger branch from cc35567 to 189c7f5 Compare September 11, 2025 21:58
@justSmK justSmK force-pushed the feature/WMSDK-510-fatalError-MBLogger branch from 189c7f5 to 4562b9e Compare September 11, 2025 22:15
@enotniy enotniy requested a review from Copilot September 12, 2025 07:45
public let writesPerTrimCheck: Int
public let trimCooldownSec: TimeInterval

public static let `default` = LoggerDBConfig(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это просто эвристические параметры?

Copy link
Contributor Author

@justSmK justSmK Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да. Удобно вынести стало из-за их роста и для подстановки в тесты

Copy link

Copilot AI left a 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему не наоборот? Хранить последнее время и каждый раз проверять добавляя интервал

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Удобно было сделать deadline "до какого времени нельзя". Но можно и как ты предложил. Пока нигде не аффектят оба варианта.

@justSmK justSmK merged commit d00aad5 into develop Sep 12, 2025
8 of 9 checks passed
@justSmK justSmK deleted the feature/WMSDK-510-fatalError-MBLogger branch September 12, 2025 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants