signalapp / Signal-Desktop

A private messenger for Windows, macOS, and Linux.
https://signal.org/download
GNU Affero General Public License v3.0
14.68k stars 2.68k forks source link

Upgrade to 7.33 corrupted database; downgrade did not help #7090

Open posita opened 2 days ago

posita commented 2 days ago

Using a supported version?

Overall summary

I keep my Ubuntu system up-to-date (by the week). I am keeping Signal up-to-date with the official repository. Immediately after upgrading to 7.33 from the immediately prior version, I was presented with:

Database startup error:

Error: Error while decrypting the ciphertext provided to safeStorage.decryptString.
    at getSQLKey ([REDACTED]/app/main.js:1280:39)
    at initializeSQL ([REDACTED]/app/main.js:1329:11)
    at App.<anonymous> ([REDACTED]/app/main.js:1551:20)

App Version: 7.33.0
OS: linux

Downgrading to 7.32 and then 7.31 did not help. (The database remained corrupted.) This sounds similar to #7089, but I keep my system up-to-date. Possibly related to #7029, #7054 [EDIT: no, that's a different issue], but those involve different versions.

From the command line:

% signal-desktop
Set Windows Application User Model ID (AUMID) { AUMID: 'org.whispersystems.signal-desktop' }
NODE_ENV production
NODE_CONFIG_DIR /opt/Signal/resources/app.asar/config
NODE_CONFIG {}
ALLOW_CONFIG_MUTATIONS undefined
HOSTNAME beauregard
NODE_APP_INSTANCE undefined
SUPPRESS_NO_CONFIG_WARNING undefined
SIGNAL_ENABLE_HTTP undefined
userData: /home/<...>/.config/Signal
config/get: Successfully read user config file
config/get: Successfully read ephemeral config file
making app single instance
{"level":30,"time":"2024-11-19T23:03:32.890Z","msg":"got fast localeOverride setting null"}
{"level":30,"time":"2024-11-19T23:03:32.893Z","msg":"app.ready: hour cycle preference: UnknownPreference"}
{"level":30,"time":"2024-11-19T23:03:32.893Z","msg":"app.ready: preferred system locales: en-US, en"}
{"level":30,"time":"2024-11-19T23:03:32.894Z","msg":"locale: Supported locales: af-ZA, ar, az-AZ, bg-BG, bn-BD, bs-BA, ca, cs, da, de, el, en, es, et-EE, eu, fa-IR, fi, fr, ga-IE, gl-ES, gu-IN, he, hi-IN, hr-HR, hu, id, it, ja, ka-GE, kk-KZ, km-KH, kn-IN, ko, ky-KG, lt-LT, lv-LV, mk-MK, ml-IN, mr-IN, ms, my, nb, nl, pa-IN, pl, pt-BR, pt-PT, ro-RO, ru, sk-SK, sl-SI, sq-AL, sr, sv, sw, ta-IN, te-IN, th, tl-PH, tr, ug, uk-UA, ur, vi, yue, zh-CN, zh-HK, zh-Hant"}
{"level":30,"time":"2024-11-19T23:03:32.895Z","msg":"locale: Preferred locales: en-US, en"}
{"level":30,"time":"2024-11-19T23:03:32.895Z","msg":"locale: Locale Override: null"}
{"level":30,"time":"2024-11-19T23:03:32.898Z","msg":"locale: Matched locale: en"}
{"level":40,"time":"2024-11-19T23:03:32.969Z","msg":"intl.onWarn [@formatjs/intl] \"defaultRichTextElements\" was specified but \"message\" was not pre-compiled. \nPlease consider using \"@formatjs/cli\" to pre-compile your messages for performance.\nFor more details see https://formatjs.io/docs/getting-started/message-distribution"}
{"level":30,"time":"2024-11-19T23:03:32.972Z","msg":"locale: Text info direction for en: ltr"}
{"level":30,"time":"2024-11-19T23:03:32.975Z","msg":"getSQLKey: decrypting key"}
{"level":30,"time":"2024-11-19T23:03:32.976Z","msg":"getSystemTraySetting got value DoNotUseSystemTray"}
{"level":30,"time":"2024-11-19T23:03:32.977Z","msg":"getSystemTraySetting returning DoNotUseSystemTray"}
{"level":30,"time":"2024-11-19T23:03:32.981Z","msg":"app ready"}
{"level":30,"time":"2024-11-19T23:03:32.982Z","msg":"starting version 7.33.0"}
{"level":30,"time":"2024-11-19T23:03:32.982Z","msg":"media access status [object Undefined] [object Undefined]"}
{"level":30,"time":"2024-11-19T23:03:32.991Z","msg":"got fast theme-setting value system"}
{"level":30,"time":"2024-11-19T23:03:33.025Z","msg":"got fast theme-setting value system"}
{"level":30,"time":"2024-11-19T23:03:33.026Z","msg":"got fast spellcheck setting true"}
{"level":30,"time":"2024-11-19T23:03:33.027Z","msg":"visibleOnAnyScreen(window): x=3072, y=925, width=1536, height=803"}
{"level":30,"time":"2024-11-19T23:03:33.028Z","msg":"visibleOnAnyScreen(display #3850489720471618): x=3072, y=864, width=1536, height=864"}
{"level":30,"time":"2024-11-19T23:03:33.029Z","msg":"Initializing BrowserWindow config: {\"show\":false,\"width\":1536,\"height\":803,\"minWidth\":300,\"minHeight\":200,\"autoHideMenuBar\":false,\"titleBarStyle\":\"default\",\"backgroundColor\":\"#3a76f0\",\"webPreferences\":{\"devTools\":false,\"spellcheck\":true,\"enableBlinkFeatures\":\"CSSPseudoDir,CSSLogical\",\"enablePreferredSizeMode\":true,\"nodeIntegration\":false,\"nodeIntegrationInWorker\":false,\"sandbox\":false,\"contextIsolation\":true,\"preload\":\"[REDACTED]/preload.wrapper.js\",\"backgroundThrottling\":true,\"disableBlinkFeatures\":\"Accelerated2dCanvas,AcceleratedSmallCanvases\"},\"icon\":\"[REDACTED]/images/signal-logo-desktop-linux.png\",\"x\":3072,\"y\":925}"}
{"level":30,"time":"2024-11-19T23:03:33.256Z","msg":"spellcheck: user locales: [\"en-US\",\"en\"]"}
{"level":30,"time":"2024-11-19T23:03:33.257Z","msg":"spellcheck: available spellchecker languages: [\"af\",\"bg\",\"ca\",\"cs\",\"cy\",\"da\",\"de\",\"de-DE\",\"el\",\"en\",\"en-AU\",\"en-CA\",\"en-GB\",\"en-GB-oxendict\",\"en-US\",\"es\",\"es-419\",\"es-AR\",\"es-ES\",\"es-MX\",\"es-US\",\"et\",\"fa\",\"fo\",\"fr\",\"fr-FR\",\"he\",\"hi\",\"hr\",\"hu\",\"hy\",\"id\",\"it\",\"it-IT\",\"ko\",\"lt\",\"lv\",\"nb\",\"nl\",\"pl\",\"pt\",\"pt-BR\",\"pt-PT\",\"ro\",\"ru\",\"sh\",\"sk\",\"sl\",\"sq\",\"sr\",\"sv\",\"ta\",\"tg\",\"tr\",\"uk\",\"vi\"]"}
{"level":30,"time":"2024-11-19T23:03:33.257Z","msg":"spellcheck: setting languages to: [\"en-US\",\"en\"]"}
2024-11-19 17:03:33.526: ERROR CORE sqlcipher_page_cipher: hmac check failed for pgno=1
2024-11-19 17:03:33.526: ERROR CORE sqlite3Codec: error decrypting page 1 data: 1
2024-11-19 17:03:33.526: ERROR CORE sqlcipher_codec_ctx_set_error 1
{"level":40,"time":"2024-11-19T23:03:33.528Z","msg":"MainSQL: Database log code=26: file is not a database in \"PRAGMA journal_mode = WAL\""}
{"level":30,"time":"2024-11-19T23:03:33.529Z","msg":"MainSQL: migrateDatabase: Migration without cipher change failed"}
2024-11-19 17:03:33.529: ERROR CORE sqlcipher_cipher_ctx_key_derive: error occurred from provider kdf generating encryption key
2024-11-19 17:03:33.529: ERROR CORE sqlcipher_codec_key_derive: error occurred deriving read_ctx key
2024-11-19 17:03:33.529: ERROR CORE sqlite3Codec: error occurred during key derivation: 1
2024-11-19 17:03:33.529: ERROR CORE sqlcipher_codec_ctx_set_error 1
{"level":40,"time":"2024-11-19T23:03:33.529Z","msg":"MainSQL: Database log code=7: statement aborts at 2: [PRAGMA user_version] out of memory"}
{"level":50,"time":"2024-11-19T23:03:33.532Z","msg":"MainSQL: Database startup error: SqliteError: out of memory\n    at Database.pragma ([REDACTED]/node_modules/@signalapp/better-sqlite3/lib/methods/pragma.js:11:31)\n    at getUserVersion ([REDACTED]/ts/sql/util.js:142:13)\n    at migrateSchemaVersion ([REDACTED]/ts/sql/Server.js:415:54)\n    at openAndMigrateDatabase ([REDACTED]/ts/sql/Server.js:447:5)\n    at openAndSetUpSQLCipher ([REDACTED]/ts/sql/Server.js:469:14)\n    at initialize ([REDACTED]/ts/sql/Server.js:516:10)\n    at MessagePort.<anonymous> ([REDACTED]/ts/sql/mainWorker.js:69:41)\n    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:820:20)\n    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)"}
{"level":50,"time":"2024-11-19T23:03:33.533Z","msg":"Failed to get zoom factor {\"name\":\"SqliteError\"}"}
{"level":30,"time":"2024-11-19T23:03:33.771Z","msg":"Updating BrowserWindow config: %s {\"maximized\":false,\"autoHideMenuBar\":false,\"fullscreen\":false,\"width\":1536,\"height\":806,\"x\":3072,\"y\":924}"}
{"level":30,"time":"2024-11-19T23:03:33.774Z","msg":"config/set: Saving ephemeral config to disk"}
{"level":30,"time":"2024-11-19T23:03:33.785Z","msg":"config/set: Saved ephemeral config to disk"}
{"level":30,"time":"2024-11-19T23:03:34.338Z","msg":"got fast theme-setting value system"}
{"level":50,"time":"2024-11-19T23:03:35.797Z","msg":"sql.initialize was unsuccessful; returning early"}
{"level":30,"time":"2024-11-19T23:03:35.800Z","msg":"close event {\"readyForShutdown\":false,\"shouldQuit\":false}"}
{"level":30,"time":"2024-11-19T23:03:35.801Z","msg":"maybeRequestCloseConfirmation: Checking to see if close confirmation is needed"}
{"level":50,"time":"2024-11-19T23:03:37.803Z","msg":"onDatabaseError: Quitting application"}
{"level":30,"time":"2024-11-19T23:03:37.806Z","msg":"main window closed event"}
{"level":30,"time":"2024-11-19T23:03:37.807Z","msg":"quit event {\"hasEventBeenPrevented\":false,\"windowCount\":0,\"mainWindowExists\":false}"}
{"level":50,"time":"2024-11-19T23:03:37.809Z","msg":"Error occurred in handler for 'sql-channel:read': {\"name\":\"SqliteError\"}"}

Steps to reproduce

  1. Upgrade to 7.33?

Expected result

Not to have my database be permanently corrupted after an upgrade.

Actual result

Database was corrupted after upgrade to 7.33 and downgrading to 7.32 and 7.31 (e.g., sudo apt-get purge --auto-remove signal-desktop && sudo apt-get install signal-deskop=7.31.0) did not help. I was able to restore ~/.config/Signal from a backup, unlink, and then relink the desktop client, which allowed me to proceed. Upgrading back to 7.33 from 7.31 did not exhibit the same crash (i.e., it continued to work with the backed up database). If I didn't not have the backup, I would have lost all message history on desktop. The corresponding feature request appears largely ignored for the past six years.

Screenshots

No response

Signal version

7.33

Operating system

Ubuntu (Pop!_OS) 22.04

Version of Signal on your phone

7.36 (429)

Link to debug log

No response

ayumi-signal commented 1 day ago

Sorry about your corrupted database! That's not great, but it's fortunate you had a backup. It's not clear based on the logs what happened, and I just ran a test on Linux to migrate from 7.32 to 7.33 and wasn't able to reproduce the problem. Also it's interesting that 7.31 to 7.33 was working. Has anything changed with your system password store recently?

posita commented 1 day ago

Has anything changed with your system password store recently?

Not that I know of, but how would I know for sure? My ~/.config/Signal/config.json both pre- and post-upgrade indicates:

{
  // ...
  "safeStorageBackend": "gnome_libsecret"
}

Does that help?

ayumi-signal commented 1 day ago

Hm that is as expected. Thank you for checking it.

Shnub commented 1 day ago

I'm experiencing the same error on macOS, not after updating Signal but after migrating to a new Mac using Migration Assistant:

Database startup error:

Error: Error while decrypting the ciphertext provided to safeStorage.decryptString.
    at getSQLKey ([REDACTED]/app/main.js:1280:39)
    at initializeSQL ([REDACTED]/app/main.js:1329:11)
    at App.<anonymous> ([REDACTED]/app/main.js:1551:20)

App Version: 7.34.0
OS: darwin

The version on the new machine was 7.33.0 originally; manually replacing the app with 7.34.0 didn't change anything.

The new machine is running Sequoia 15.1. The same database on the original machine (which is running Ventura 13.7) continues to work fine.

Deleting ~/Application Support/Signal and replacing it with the folder from the original machine or from a backup yields the same error on the new machine. Only deleting and starting from scratch works normally.

I made certain the migrated/copied folder was bit-identical on the new machine, so I'm not sure this is actual database corruption. FWIW, I can copy the "corrupted" folder back to the old machine and it works fine again there.

Assistance would be greatly appreciated. Please let me know if/how I can provide further details.

Shnub commented 21 hours ago

I was able to solve my problem. Since true database corruption seemed unlikely and missing/changing keys were mentioned in other places by other users, I looked into macOS's keychain and found a different "Signal Safe Storage" key than on the original machine. Once I overwrote the new key with the old one, Signal upon launch only asked permission to use this changed keychain item, and when granted opened the existing database fine, with all messages preserved.

I don't know what caused a wrong key to be stored – unfortunately I can't tell now whether Migration Assistant migrated the existing key properly in the first place, and thus, whether this was a Signal or a Migration Assistant issue.

Edit: Also, it is now obvious that mine was a different issue from the OP's, so apologies for hijacking this thread.

posita commented 18 hours ago

I should have been clearer about my "restor[ing] ... from a backup". I copied my ~/.config/Signal directory from another instance. More specifically, I run two copies of Signal on my desktop. One from the deb repo (whose config lives at ~/.config/Signal) and one from the Flatpak repo (whose config lives at ~/.var/app/org.signal.Signal/config/Signal). I started doing this when the Flatpak version ended up corrupting databases a few weeks ago and I basically lost some message history, which was very painful for me. (Copying message history is a high-demand-but-ignored feature request.) When my apt/deb version suddenly resulted in a database error, I quit that one and the Flatpak one. Then I unlinked both from my mobile app, deleted ~/.config/Signal, copied ~/.var/app/org.signal.Signal/config/Signal into its place, and restarted/re-linked both desktop clients.

RogoTe commented 9 hours ago

I have the same problem on MacOS but with an update from Sequoia 15.1 to 15.1.1 or Signal Desktop from 7.32 to 7.33 (Signal updated right after the reboot for the MacOS update, so I am not sure what triggered it. Reverting back to 7.32 from a backup sadly did not change it.