Skip to content

Database Wrapper Cleanup#675

Merged
mpretty-cyro merged 73 commits into
session-foundation:devfrom
mpretty-cyro:fix/database-issues
Mar 27, 2026
Merged

Database Wrapper Cleanup#675
mpretty-cyro merged 73 commits into
session-foundation:devfrom
mpretty-cyro:fix/database-issues

Conversation

@mpretty-cyro

@mpretty-cyro mpretty-cyro commented Mar 2, 2026

Copy link
Copy Markdown
Collaborator
  • Updated Storage to be an actor and drastically simplified the code (only supports async/await now)
  • Updated database migration code to try to be self-recoverable after a suspension
  • Updated the home screen to fetch the pinned conversation count as part of it's state rather than when generating swipe actions
  • Updated the background poller to resubscribe for push notifications
  • Updated calls to use non-blocking database queries
  • Updated the emoji picker to use a non-blocking database query to fetch recent reactions
  • Updated the MediaGalleryViewModel to use non-blocking database queries and caching to fetch album info
  • Updated the notification presenter to use non-blocking database queries to fetch thread info
  • Updated the dev settings screen to fetch the PN state as part of it's query instead of in a blocking way when being initialized
  • Updated the NewClosedGroupVC to use a non-blocking database query to get contacts
  • Removed synchronous read/write calls from database wrapper
  • Removed publisher read/write calls from database wrapper
  • Removed overly complex applicationWillEnterForeground code
  • Removed "max streams" settings, added maxConcurrentFiles dev/env settings
  • Removed a C++ "clear loggers" call when clearing account data (caused false crashes)
  • Renamed readAsync/writeAsync to read/write
  • Reworked PN registration to resolve a few bugs causing registration failure
  • Fixed a small issue where the version support banner could appear briefly
  • Fixed an issue where "@you" wouldn't be highlighted in some cases

Note: This is based on #500

• Updated the home screen to fetch the pinned conversation count as part of it's state rather than when generating swipe actions
• Updated calls to use non-blocking database queries
• Updated the emoji picker to use a non-blocking database query to fetch recent reactions
• Updated the MediaGalleryViewModel to use non-blocking database queries and caching to fetch album info
• Updated the notification presenter to use non-blocking database queries to fetch thread info
• Updated the dev settings screen to fetch the PN state as part of it's query instead of in a blocking way when being initialized
• Updated the NewClosedGroupVC to use a non-blocking database query to get contacts
• Removed synchronous read/write calls from database wrapper
• Removed publisher read/write calls from database wrapper
@mpretty-cyro mpretty-cyro self-assigned this Mar 2, 2026
@mpretty-cyro mpretty-cyro added enhancement New feature or request Jira This ticket is being tracked in Jira labels Mar 4, 2026
@mpretty-cyro mpretty-cyro changed the title [WIP] Database Wrapper Cleanup Database Wrapper Cleanup Mar 6, 2026
@mpretty-cyro
mpretty-cyro marked this pull request as ready for review March 6, 2026 01:10
• Fixed a possible race condition which could result in conversations with profiles that are missing their display pictures updating to render their display pics once they are downloaded
• Fixed a race conditions where a call message could be sent before setting the local description resulting in call failures
• Fixed a race condition where receiving call messages out of order could result in data getting dropped and call failures
• Fixed a couple of race conditions where continuations could be resolved multiple times which could result in a crash
• Fixed an issue where we would process call messages for already ended calls which could prevent subsequent calls from working
• Fixed an issue where the call description could get updated after the call had ended (which looked strange)
• Fixed an issue where the code would blindly retry answering a call even if it was already in a closed state (this could block subsequent calls from being answered)
• Fixed an issue where removing a value from UserDefaults wouldn't emit an event
• Fixed an issue where checking whether a feature has been set could return a false negative
• Added an initial event buffer to the ObservationManager to catch events which are sent during initial setup/query which could fall through the cracks
• Simplified the ObservationManager interface
• Refactored the ThreadDisappearingMessagesSettingsViewModel to use the new ObservationBuilder and observe role changes to resolve a race condition of trying to set disappearing messages before the users role has been received
• Fixed a couple race conditions in the ObservationManager
• Fixed a race condition when removing dependencies from job in the JobRunner
# Conflicts:
#	Session.xcodeproj/project.pbxproj
#	SessionUIKit/Components/SwiftUI/DonationCTAModal.swift
# Conflicts:
#	Session/Utilities/DonationsManager.swift
#	SessionUIKit/Components/SwiftUI/DonationCTAModal.swift
#	SessionUtilitiesKit/Dependency Injection/Dependencies.swift
• Updated the code to handle a bad url as a bad url error instead of an unknown error
• Fixed an issue where all rooms for a SOGS would be polled instead of just the ones the user had joined
• Fixed an issue where we would needlessly try to start community pollers once for every room
• Fixed an issue where a group in an invalid state could prevent push notification subscriptions
• Fixed an issue where the group poller would poll every 3 seconds indefinitely for groups with no messages
• Added a log to debug an attachment download issue
• Added a value to track the number of concurrent
• Fixed an issue where we could try to process reactions for a community message after failing to insert the message
• Fixed an issue where a dedupe record could incorrectly be inserted for a community message which failed to be handled
• Fixed an issue where the network would be started in the notification service extension needlessly (now defer until actually needed)
• Removed a test log
• Fixed regression which broke group polling
• Added the unique constraint back to the display picture download job (fixing a duplicate job error causing queue starvation issues)
• Fixed a race condition where some blocking jobs that require the user to exist could run before we can detect whether the user exists
• Fixed a bug where `FetchablePair` wasn't handling `DatabaseValueConvertible` correctly
• Fixed a couple of bugs in the JobRunner where jobDependencies may not be handled correctly
• Fixed a bug where display pictures could be prioritised over attachments where there is no `activeThreadId` (in that case they will be prioritised by timestamp)
• Added an optimisation to avoid updating the priority context if it's already set to the current value (could happen when returning to the conversation screen from it's settings screen)
• Further tweaked the sorting so downloads for the current conversation are prioritised over display pictures for the conversation list
• Fixed the unique constraint on the new `uniqueHashValue` column on the Job table
• Added additional logs to try to made debugging some database failure cases easier
• Tweaked some logs to suppress false warnings
• Tweaked some logic to source some additional pro data via the SessionProManager rather than using inline logic
• (Probably) Fixed a bug where the pro badge could incorrectly show in the "Note to Self" title
• Removed the GRDB usage from SessionNetworkingKit
• Replaced the Session-GRDB-swift fork SPM dependency with the (more) official SQLCipher/GRDB.swift SPM dependency
• Updated to the latest GRDB (7.10.0)
• Fixed an issue so task cancellation is correctly propagated to database queries
• Fixed a bug where trying to schedule an auto-download the users display picture was happening in a read query instead of a write
• Fixed a bug where the network instance could be incorrectly created when receiving a PN
• Fixed an issue where notification messages would only be processed on launch and not on return from background
• Fixed an edge case where a notification may not be shown when received while backgrounding the app
• Fixed an issue where the `DisappearingMessagesJob` could needlessly schedule additional jobs
• Fixed an issue where the home screen wouldn't update message snippets when returning from the background
• Updated to the latest libSession
• Fixed an incorrect donations URL
• Fixed failing unit tests
@mpretty-cyro
mpretty-cyro merged commit f076e37 into session-foundation:dev Mar 27, 2026
1 check passed
@mpretty-cyro
mpretty-cyro deleted the fix/database-issues branch March 27, 2026 04:34
@mpretty-cyro mpretty-cyro mentioned this pull request Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Jira This ticket is being tracked in Jira

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants