Skip to content

FIRESTORE INTERNAL ASSERTION FAILED – Failed to commit transaction xxxxxx. Corruption: not an sstable (bad magic number) #14860

Open
@DRK1004

Description

@DRK1004

Description

We are seeing a fatal crash in our iOS production app when using Firestore. The error points to a corruption issue in Firestore’s internal LevelDB storage layer.

Fatal Exception: NSInternalInconsistencyException
FIRESTORE INTERNAL ASSERTION FAILED: Failed to commit transaction: <LevelDbTransaction ExecuteQuery: 0 changes (0 bytes):> Failed: Corruption: not an sstable (bad magic number) (expected status.ok())

# Crashlytics - Stack trace
# Application: com.xxxxxxxxxx
# Platform: apple
# Version: XXXXXXX
# Issue: 2b310d601e1cd930d0fbec3312936e3e
# Session: 55d76a6552544fdaaa44c721a0eed7d2_DNE_0_v2
# Date: Tue May 06 2025 02:46:26 GMT-0500 (Central Daylight Time)

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x83f20 __exceptionPreprocess
1  libobjc.A.dylib                0x172b8 objc_exception_throw
2  Foundation                     0x6de934 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:]
3  XXXXXXX                      0x18b5328 firebase::firestore::util::ObjcThrowHandler(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
4  XXXXXXX                      0x18b4d74 firebase::firestore::util::Throw(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
5  XXXXXXX                      0x1900210 firebase::firestore::util::internal::FailAssertion(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const*)
6  XXXXXXX                      0x19002a0 firebase::firestore::util::internal::FailAssertion(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, char const*)
7  XXXXXXX                      0x1932cdc firebase::firestore::local::LevelDbTransaction::Commit()
8  XXXXXXX                      0x19296dc firebase::firestore::local::LevelDbPersistence::RunInternal(absl::lts_20240116::string_view, std::__1::function<void ()>)
9  XXXXXXX                      0x193f4d0 firebase::firestore::local::LocalStore::ExecuteQuery(firebase::firestore::core::Query const&, bool)
10 XXXXXXX                      0x198c5b0 firebase::firestore::core::SyncEngine::InitializeViewAndComputeSnapshot(firebase::firestore::core::Query const&, int, firebase::firestore::nanopb::ByteString)
11 XXXXXXX                      0x198c0d0 firebase::firestore::core::SyncEngine::Listen(firebase::firestore::core::Query, bool)
12 XXXXXXX                      0x18b27b4 firebase::firestore::core::EventManager::AddQueryListener(std::__1::shared_ptr<firebase::firestore::core::QueryListener>)
13 XXXXXXX                      0x18d6c5c std::__1::__function::__func<firebase::firestore::core::FirestoreClient::ListenToQuery(firebase::firestore::core::Query, firebase::firestore::core::ListenOptions, std::__1::shared_ptr<firebase::firestore::core::EventListener<firebase::firestore::core::ViewSnapshot>>&&)::$_11, std::__1::allocator<firebase::firestore::core::FirestoreClient::ListenToQuery(firebase::firestore::core::Query, firebase::firestore::core::ListenOptions, std::__1::shared_ptr<firebase::firestore::core::EventListener<firebase::firestore::core::ViewSnapshot>>&&)::$_11>, void ()>::operator()()
14 XXXXXXX                      0x1879d0c firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&)
15 XXXXXXX                      0x199999c firebase::firestore::util::Task::ExecuteAndRelease()
16 libdispatch.dylib              0x3dd4 _dispatch_client_callout
17 libdispatch.dylib              0xb400 _dispatch_lane_serial_drain
18 libdispatch.dylib              0xbf30 _dispatch_lane_invoke
19 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh
20 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread
21 libsystem_pthread.dylib        0x4934 _pthread_wqthread
22 libsystem_pthread.dylib        0x10cc start_wqthread

Since its happening in production environment, so no clear reproduction steps are available but seems related to disk persistence/levelDB corruption. We have exception handling in our mobile app code but seems its not being caught. We would request following information:

  1. How can we detect and handle this LevelDB corruption gracefully. Does firestore report or throw any error that could be caught?
  2. Are there known causes for this corruption or known fixes in newer SDK versions ?

This issue leads to a fatal crash, affecting user experience. We would appreciate guidance on mitigation or recovery strategies.

Reproducing the issue

Since its happening in production environment, so no clear reproduction steps are available.

Firebase SDK Version

10.25.0

Xcode Version

16.2

Installation Method

Swift Package Manager

Firebase Product(s)

Database

Targeted Platforms

iOS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions