Skip to content

[FCM] Recovery logic for a corrupt database#15573

Merged
paulb777 merged 5 commits intomainfrom
pb-msg-file-corrupt
Jan 6, 2026
Merged

[FCM] Recovery logic for a corrupt database#15573
paulb777 merged 5 commits intomainfrom
pb-msg-file-corrupt

Conversation

@paulb777
Copy link
Member

@paulb777 paulb777 commented Dec 3, 2025

Fix #14880. More context in discussion at #15559

@gemini-code-assist
Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@paulb777 paulb777 force-pushed the pb-msg-file-corrupt branch from 7e4798d to 3cd2386 Compare December 4, 2025 01:07
@paulb777 paulb777 requested a review from ncooke3 December 4, 2025 15:52
@paulb777 paulb777 marked this pull request as ready for review December 20, 2025 16:14
@ncooke3
Copy link
Member

ncooke3 commented Jan 6, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces important recovery logic for a corrupt database, which is a great improvement. The implementation in FIRMessagingRmqManager.m looks mostly good, but I have a few suggestions for improvement regarding error handling and code structure. Additionally, I have a question about the unit test testInitWhenDatabaseIsBrokenThenDatabaseIsDeleted. This test seems to expect an assertion and that the database file is ultimately deleted, which appears to contradict the goal of successfully recovering and recreating the database. Perhaps I'm misunderstanding the test's scenario, and I'd appreciate some clarification.

@ncooke3
Copy link
Member

ncooke3 commented Jan 6, 2026

The QS failures are a tooling issue. I think it has to do with when a PR gets force pushed to. Investigating a fix for that. It should be non-blocking for this PR.

@ncooke3 ncooke3 requested a review from leojaygoogle January 6, 2026 17:45
ncooke3 and others added 2 commits January 6, 2026 14:03
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@danger-firebase-ios danger-firebase-ios bot deleted a comment from google-oss-bot Jan 6, 2026
@ncooke3 ncooke3 mentioned this pull request Jan 6, 2026
8 tasks
@paulb777 paulb777 merged commit 1f7389b into main Jan 6, 2026
61 checks passed
@paulb777 paulb777 deleted the pb-msg-file-corrupt branch January 6, 2026 23:00
"Will delete and try to recreate it.",
path);
NSError *removeError;
if (![[NSFileManager defaultManager] removeItemAtPath:path error:&removeError]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know the exact error code SQLite returns when the database is corrupt? Deleting the database for all error codes seems a bit extreme.

Copy link
Contributor

Choose a reason for hiding this comment

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

According to #14880 , the error code is 14

Could not create RMQ database at path /var/mobile/Containers/Data/Application/372D4296-3F35-46FD-B3C9-0A20877B8378/Library/Application Support/Google/FirebaseMessaging/rmq2.sqlite, error: 14 - unable to open database file

How about updating the code to only delete the file if the result is SQLITE_CANTOPEN?
https://sqlite.org/rescode.html

(14) SQLITE_CANTOPEN
The SQLITE_CANTOPEN result code indicates that SQLite was unable to open a file. The file in question might be a primary database file or one of several temporary disk files.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry about the quick merge. Addressing feedback in #15678

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS App Crashed on app launch - Firebase SQL file not found

4 participants