signalapp / Signal-Desktop

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

Database error after upgrade to 6.30 #6597

Closed rafiifar closed 1 year ago

rafiifar commented 1 year ago

Bug Description

After upgrading to version 6.30 signal-desktop on Windows 11, the application does not want to start. It started performing application optimization and then returned errors:

  1. First one:
Database startup error:

Error: TypeError: Cannot read properties of null (reading 'type')
    at getPeerIdFromConversation ([REDACTED]\ts\sql\migrations\89-call-history.js:68:20)
    at [REDACTED]\ts\sql\migrations\89-call-history.js:211:22
    at sqliteTransaction ([REDACTED]\node_modules\@signalapp\better-sqlite3\lib\methods\transaction.js:65:24)
    at updateToSchemaVersion89 ([REDACTED]\ts\sql\migrations\89-call-history.js:301:5)
    at updateSchema ([REDACTED]\ts\sql\migrations\index.js:1755:5)
    at Object.initialize ([REDACTED]\ts\sql\Server.js:413:40)
    at MessagePort.<anonymous> ([REDACTED]\ts\sql\mainWorker.js:73:35)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:735:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
    at Worker.<anonymous> ([REDACTED]\ts\sql\main.js:62:26)
    at Worker.emit (node:events:513:28)
    at MessagePort.<anonymous> (node:internal/worker:234:53)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:735:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
  1. Second one:
    
    Unhandled Promise Rejection

Error: Not initialized at MainSQL.close ([REDACTED]\ts\sql\main.js:103:13) at BrowserWindow. ([REDACTED]\app\main.js:674:15)



### Steps to Reproduce

1.  Upgrade application to newest version through the UI prompt about new version
2.  Try to run application

Actual Result:

Errors like mentioned above.

Expected Result:

The application should start

### Platform Info

Signal Version:
Actually it is in 6.30

Operating System:
Windows 11 Pro 22H2

Linked Device Version:
iOS 16.6

### Link to Debug Log
Unable to get debug logs. Application does not start
indutny-signal commented 1 year ago

Sorry about this. We are working on a fix.

DerErnie commented 1 year ago

Had the same problem. Unfortunately after a reboot and another start of the app my whole message database got erased while asked for a new sync with mobile phone. Please stop the auto-update until this is fixed!

PC: Windows 10, Version 22H2, Build 19045.2728, Windows Feature Experience Pack 120.2212.4190.0 Phone: iOS 15.7.8

itkfm commented 1 year ago

Furthermore, “Copy error and quit” doesn’t even do the first half of its job…

image

itkfm commented 1 year ago

Furthermore, “Copy error and quit” doesn’t even do the first half of its job…

Errata: Sorry, it fails the 2nd half as well. Better rename it to “Go to background and burn one CPU core at 100%”

Vzaa commented 1 year ago

I think I have the same problem on Ubuntu 22.04 after the update. I don't know if there's way to change log levels to gather more info, but this is what I see when I run signal-desktop which ends in a SIGTRAP:

$ 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 undefined
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":"2023-09-07T15:46:05.586Z","msg":"app.ready: hour cycle preference: UnknownPreference"}
{"level":30,"time":"2023-09-07T15:46:05.587Z","msg":"app.ready: preferred system locales: en-US, en"}
{"level":30,"time":"2023-09-07T15:46:05.587Z","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":"2023-09-07T15:46:05.587Z","msg":"locale: Preferred locales:  en-US, en"}
{"level":30,"time":"2023-09-07T15:46:05.588Z","msg":"locale: Matched locale: en"}
{"level":40,"time":"2023-09-07T15:46:05.602Z","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":"2023-09-07T15:46:05.603Z","msg":"locale: Text info direction for en: ltr"}
{"level":30,"time":"2023-09-07T15:46:05.603Z","msg":"app ready"}
{"level":30,"time":"2023-09-07T15:46:05.604Z","msg":"starting version 6.30.0"}
{"level":30,"time":"2023-09-07T15:46:05.604Z","msg":"media access status [object Undefined] [object Undefined]"}
{"level":30,"time":"2023-09-07T15:46:05.605Z","msg":"got fast theme-setting value dark"}
{"level":30,"time":"2023-09-07T15:46:05.606Z","msg":"got fast theme-setting value dark"}
{"level":30,"time":"2023-09-07T15:46:05.606Z","msg":"got fast spellcheck setting true"}
{"level":30,"time":"2023-09-07T15:46:05.606Z","msg":"getSystemTraySetting had no flags and did no DB lookups. Returning DoNotUseSystemTray"}
{"level":30,"time":"2023-09-07T15:46:05.606Z","msg":"Initializing BrowserWindow config: {\"show\":false,\"width\":954,\"height\":1057,\"minWidth\":300,\"minHeight\":200,\"autoHideMenuBar\":true,\"titleBarStyle\":\"default\",\"titleBarOverlay\":false,\"backgroundColor\":\"#121212\",\"webPreferences\":{\"devTools\":false,\"spellcheck\":true,\"enableBlinkFeatures\":\"CSSPseudoDir,CSSLogical\",\"nodeIntegration\":false,\"nodeIntegrationInWorker\":false,\"sandbox\":false,\"contextIsolation\":true,\"preload\":\"[REDACTED]/preload.bundle.js\",\"backgroundThrottling\":true,\"enablePreferredSizeMode\":true,\"disableBlinkFeatures\":\"Accelerated2dCanvas,AcceleratedSmallCanvases\"},\"icon\":\"[REDACTED]/images/signal-logo-desktop-linux.png\",\"x\":3,\"y\":19}"}
{"level":30,"time":"2023-09-07T15:46:05.619Z","msg":"spellcheck: user locales: [\"en-US\",\"en\"]"}
{"level":30,"time":"2023-09-07T15:46:05.619Z","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":"2023-09-07T15:46:05.619Z","msg":"spellcheck: setting languages to: [\"en-US\",\"en\"]"}
{"level":30,"time":"2023-09-07T15:46:05.624Z","msg":"MainSQL: updateSchema:\n  Current user_version: 91;\n  Most recent db schema: 920;\n  SQLite version: 3.39.4;\n  SQLCipher version: 4.5.3 community;\n  (deprecated) schema_version: 437;\n"}
{"level":30,"time":"2023-09-07T15:46:05.624Z","msg":"MainSQL: updateToSchemaVersion920(kyberPreKeys): Found 198 total keys"}
{"level":30,"time":"2023-09-07T15:46:05.624Z","msg":"MainSQL: updateToSchemaVersion920(signedPreKeys): Found 12 total keys"}
{"level":30,"time":"2023-09-07T15:46:05.624Z","msg":"MainSQL: updateToSchemaVersion920: Done with deletions"}
{"level":30,"time":"2023-09-07T15:46:05.624Z","msg":"MainSQL: updateToSchemaVersion920: Starting vacuum..."}
{"level":30,"time":"2023-09-07T15:46:05.871Z","msg":"got fast theme-setting value dark"}
{"level":30,"time":"2023-09-07T15:46:06.321Z","msg":"main window is ready-to-show"}
{"level":30,"time":"2023-09-07T15:46:08.606Z","msg":"sql.initialize is taking more than three seconds; showing loading dialog"}
{"level":30,"time":"2023-09-07T15:46:08.629Z","msg":"got fast theme-setting value dark"}
[1]    5743 trace trap (core dumped)  signal-desktop
trevor-signal commented 1 year ago

@Vzaa did you receive the same Database Error as others?

We'll have a fix for the error others are reporting released shortly.

Vzaa commented 1 year ago

@Vzaa did you receive the same Database Error as others?

It pretty much crashed silently for me. IIRC it crashed sometime after the "optimizing..." banner appeared while I was away. Between that and now I did try to downgrade to the previous version and it prompted me to reset data or exit saying it detected a newer version of the config files, I picked not to reset not wanting to lose my data :) I then upgraded back to 6.30 where I get the output from my previous message. I hope I did not damage my files while trying to downgrade.

Is there a way for me to gather additional info that might help at this point? For me It is doing the same thing every time :thinking:

trevor-signal commented 1 year ago

@Vzaa yours looks like a different issue: the process is crashing while the vacuum operation is ongoing 🤔 . Can you share the size of your database on disk (/home/*/.config/Signal/sql/db.sqlite), and RAM and free disk space on your computer? Sometimes vacuums can take a lot of additional space on disk during the operation.

Vzaa commented 1 year ago

@trevor-signal my ~/.config/Signal/sql/db.sqlite is 1.1G (1089478656), The system has 16 GB of system RAM and 22 GB of free space. I'm not seeing it running out of either RAM or storage when I run it :thinking:

Vzaa commented 1 year ago

@Vzaa yours looks like a different issue

It's the same on v6.30.1 so I guess it is indeed something else...

Edit: Checking strace I do see ENOMEM from an mprotect syscall:

[pid  3583] mprotect(0x27b862fbc000, 40960, PROT_READ|PROT_WRITE) = -1 ENOMEM (Cannot allocate memory)
[pid  3583] mprotect(0x27b862fbc000, 40960, PROT_READ|PROT_WRITE) = -1 ENOMEM (Cannot allocate memory)
[pid  3583] --- SIGTRAP {si_signo=SIGTRAP, si_code=SI_KERNEL} ---
trevor-signal commented 1 year ago

@rafiifar , @DerErnie , @itkfm and others who got the "cannot read properties of null" error when starting v6.30.0, please download v6.30.1 from https://signal.org/download and let us know if the issue is resolved. Thanks!

rafiifar commented 1 year ago

@trevor-signal Thank you very much. In my case, the new version solved the problem.

qtpies commented 1 year ago

Flathub stable is now on 6.30.1, solved the problem for me. Thanks! (somehow flatpak search org.signal.Signal shows the version as 6.30.0 but the actual installed version is 6.30.1)

Vzaa commented 1 year ago

Sorry to bug you @trevor-signal, but do you think I should create a new issue for the vacuum related crash?

I'll see if I can run vacuum on the db file using a separate sqlite client somehow :thinking:

DerErnie commented 1 year ago

@trevor-signal the new update works, but after losing my database on PC1 i try to not be one of the first adopters of 6.30.1 on my other pc (PC2) ;) The database of the affected pc (PC1) is gone and i synced it to my phone again because i needed Signal immediately :/ On PC1 the update to 6.30.1 works as expected :)

Is there a chance to import the database of PC2 into the affected PC1? A restore tool restored the old config.json and a big part of the attachment, but not the sqlite file.

Thanks in advance!

SoapGentoo commented 1 year ago

I'm also still seeing the same core dumped issue with 6.30.1 on Linux.

itkfm commented 1 year ago

@trevor-signal v6.30.1 resolved it, thx

Vzaa commented 1 year ago

I'll see if I can run vacuum on the db file using a separate sqlite client somehow 🤔

I managed to get it working using a build of sqlcipher 4.5.3 to modify my db.sqlite file.

If anybody reading this wants to try my method, please make sure to back up a copy of your db.sqlite first. There is a risk involved in manually modifying your files

I first ran vacuum from sqlcipher 4.5.3 (which doesn't crash, unlike signal-desktop) and then I replaced the db file. I re-ran signal-desktop with the updated db file and it crashed again at the vacuum step. Afterwards, I ran PRAGMA user_version = 920; which I looked up from https://github.com/signalapp/Signal-Desktop/blob/v6.30.1/ts/sql/migrations/920-clean-more-keys.ts#L175

So in summary doing this helped me:

$ sqlcipher db.sqlite
SQLite version 3.39.4 2022-09-29 15:55:41 (SQLCipher 4.5.3 community)
Enter ".help" for usage hints.
sqlite> PRAGMA key="x'key from config.json'";
ok
sqlite> vacuum;
sqlite> PRAGMA user_version = 920;

Maybe some one from the signal-desktop team can confirm this "fix" :thinking:

Edit: fixed a few typos and wording

literal-0x4e commented 1 year ago

At least in my case, with the 6.30.2 release the problem went away and signal-desktop is working again.

chirayudesai commented 1 year ago

At least in my case, with the 6.30.2 release the problem went away and signal-desktop is working again.

Same here. 6.30.1 wouldn't work, Trace/breakpoint trap Downgrading to 6.29.1 and restoring old data from backup worked. Upgrading to 6.30.2 also worked.

Vzaa commented 1 year ago

https://github.com/signalapp/Signal-Desktop/commit/893906eb6c90e79fdf430d423c3ed18c723f52ed moved the vacuum step to the end. So if it is going to crash, it is going to crash only once probably :)

indutny-signal commented 1 year ago

Alright, sounds like it is fixed now. Thanks everyone!

SoapGentoo commented 1 year ago

I assume if you didnt have a backup then your history is hosed?

indutny-signal commented 1 year ago

@SoapGentoo If you install 6.30.2 over without uninstalling the old version - it should work unless you already erased your database manually! Let me know if it doesn't!

SoapGentoo commented 1 year ago

I could have sworn I tried 6.30.2 earlier and it still crashed. Just tried again, and it all works now, thanks!