Skip to content

GRDB: add write and read methods #3040

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

Merged
merged 5 commits into from
May 1, 2025
Merged

Conversation

leandroalonso
Copy link
Member

📘 Part of: #2773

To unlock the power of concurrent reads, we need to use GRDB write and read methods. This is a first step in this direction.

Since there are many places that this needs to be changed, I'll raise one PR per data manager — this makes it easier to be reviewed.

To test

  1. ✅ Run the app form scratch and ensure the app works just fine
  2. Subscribe to a few podcasts
  3. Change grdb in FeatureFlag.swift to false
  4. Re-run the app
  5. ✅ Everything should be there

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

@leandroalonso leandroalonso added the [Type] Tech Debt Applies to issues involving upgrades or refactoring to maintain or enhance the codebase. label Apr 25, 2025
@leandroalonso leandroalonso requested a review from a team as a code owner April 25, 2025 13:55
@leandroalonso leandroalonso requested review from SergioEstevao and removed request for a team April 25, 2025 13:55
var startingSchemaVersion: Int32 = 0

queue.inDatabase { db in
queue.write { db in
Copy link
Member Author

@leandroalonso leandroalonso Apr 25, 2025

Choose a reason for hiding this comment

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

This call was split in two in one of the GRDB PRs as explained here.

This method is back to being a single block, which is what it should be. I had to add a method so that the crash that was happening before doesn't happen anymore.

With this change we're back at how it was before + working correctly with GRDB.

@leandroalonso leandroalonso mentioned this pull request Apr 25, 2025
20 tasks
@SergioEstevao
Copy link
Contributor

Non related to the changes above but noticed this quotes issues when testing this PR on the ServerPodcastManager+Update.swift in the cleanupDeletedEpisodes method.

let serverUuids = serverEpisodes.compactMap { $0["uuid"] as? String }.map { "\"\($0)\"" }

Copy link
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

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

Working correctly.

Installed from scratch, smoke test it and them changed the FF back and ran again.

All good! :shipit:

@leandroalonso leandroalonso merged commit f61a5da into trunk May 1, 2025
5 of 7 checks passed
@leandroalonso leandroalonso deleted the grdb/add-write-read-methods branch May 1, 2025 11:36
Copy link

sentry-io bot commented May 5, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ EXC_BREAKPOINT: Exception 6, Code 1, Subcode 7174814644 -[FMDatabase executeQuery:withArgumentsInArray:... View Issue
  • ‼️ EXC_BREAKPOINT: SJUserEpisode -[FMDatabase executeQuery:withArgumentsInArray:... View Issue
  • ‼️ EXC_BREAKPOINT: SJEpisode.autoDownloadStatus -[FMDatabase executeQuery:withArgumentsInArray:... View Issue

Did you find this useful? React with a 👍 or 👎

@leandroalonso leandroalonso added this to the 7.89 milestone May 5, 2025
@leandroalonso
Copy link
Member Author

About the Sentry error, this code hasn't even make to TestFlight yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Tech Debt Applies to issues involving upgrades or refactoring to maintain or enhance the codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants