Nextcloud Desktop for macOS appears frozen on startup while opening sync journal SQLite database on slow 4 KiB reads

Hello,

I am reporting a recurring issue with Nextcloud Desktop Client on macOS.

The client can appear completely frozen during startup while opening/checking the sync journal SQLite database.

The process is not crashed. It remains alive, but the main thread blocks during account/folder setup while opening the sync journal database.

The issue is reproducible when the local sync folder is on an external volume and the storage has high latency for small random reads. In this state, the tray icon does not appear and the application looks stuck.

Reading the sync journal database sequentially with dd immediately unblocks the client.

Environment:

  • Nextcloud Desktop Client: 34.0.4
  • OS: macOS 15.8.1
  • Local sync folder: /Volumes/Nextcloud
  • Sync journal database: /Volumes/Nextcloud/.sync_2f4a44904d04.db
  • Storage: external USB DAS / QNAP TR-004
  • Filesystem currently tested: HFS+ Journaled
  • The same general pattern was also observed previously before migrating the volume from APFS to HFS+.
  • FinderSyncBroker process is present but not blocked. The blocked process is the main Nextcloud application.

Observed behavior:

On startup, the main Nextcloud process remains in state U.

Example:

/Applications/Nextcloud.app/Contents/MacOS/Nextcloud U

The FinderSyncBroker process remains normal/sleeping, so this does not appear to be a Finder extension issue.

sample output:

A 5 second sample of the main Nextcloud process shows the main thread blocked in:

OCC::Application::setupAccountsAndFolders
OCC::FolderMan::setupFolders
OCC::Folder::startVfs
OCC::SyncJournalDb::open
OCC::SyncJournalDb::checkConnect
OCC::SqlDatabase::openOrCreateReadWrite
OCC::SqlDatabase::checkDb
OCC::SqlQuery::next
sqlite3_step
pread

In one sample, almost all collected samples were in pread:

4390 samples total
4389 in pread

This has now been observed with multiple client versions, including:

34.0.1
34.0.3
34.0.4

fs_usage evidence:

Running:

sudo fs_usage -w -f filesys -t 10 <nextcloud_pid>

shows repeated 4 KiB reads against the sync journal database:

RdData[A] B=0x1000 /dev/disk4s2 /Volumes/Nextcloud/.sync_2f4a44904d04.db
pread F=16 B=0x1000 O=…

B=0x1000 means 4096 bytes.

Some observed latencies for single 4 KiB reads:

0.147 s
0.227 s
0.293 s
0.235 s

So the apparent freeze is not one single permanently blocked syscall, but many small SQLite page reads accumulating into a very long startup delay.

Workaround:

While the Nextcloud client is stuck, running:

dd if=/Volumes/Nextcloud/.sync_2f4a44904d04.db of=/dev/null bs=4m

causes the client to finish startup immediately.

This has happened repeatedly. After the sequential read, the client continues startup right away.

This suggests that sequentially warming the OS page cache for the sync journal database allows the SQLite reads to complete quickly.

Expected behavior:

The desktop client should not appear dead during startup while checking/opening the sync journal database.

Possible improvements could include one or more of:

  • avoid doing this blocking database check on the main thread;
  • show a visible startup/progress state while the sync journal is being opened;
  • avoid or reduce the expensive startup access pattern;
  • detect unusually slow sync journal reads and log a clear diagnostic message;
  • consider a more sequential/cache-friendly startup path for the journal check;
  • avoid leaving the user with no tray icon and no feedback while the journal is being checked.

Actual behavior:

The UI/tray startup appears frozen until the SQLite journal reads complete.

On slow small random reads, this can take long enough that the application looks hung. The user has no useful indication of what is happening.

Additional context:

This is especially visible when the local sync folder is on an external disk and another process, such as a backup task, has recently stressed the same volume.

However, the core pattern is consistent:

Nextcloud startup

  • SyncJournalDb::open
  • SqlDatabase::checkDb
  • sqlite3_step
  • many 4 KiB pread calls
  • very slow startup / apparent freeze

The database does not appear corrupt. Manual SQLite queries can complete, and warming the database file with a sequential read immediately allows the client to continue.

The issue seems less like “SQLite is broken” and more like the client startup path is vulnerable to slow small random reads from the sync journal database, while the main thread gives no feedback and the application looks dead.

I took a quick look at the code (Disclaimer: I have personally never looked at this aspect of the client’s implementation before).

At the moment the desktop client does a PRAGMA quick_check at start-up time against the SQLite (sync) db.

I understand why this could be a performance problem, but I believe it’s somewhat necessary for robustness.

One thing that immediately stands out from a UX perspective is that, yeah, a basic indicator could at least get painted before the step starts. It wouldn’t make the UI any more responsive during slow reads, but at least would give a clue that a heavy activity is about to take place (and hopefully still is while it’s visible…).

An actual responsiveness fix would be a bigger endeavor I suspect…

That’s the client side.

I encourage you to post your findings so far into an Issue within the repo (GitHub - nextcloud/desktop: 💻 Desktop sync client for Nextcloud · GitHub) to track the matter.

Thanks for taking a look.

I agree that running a SQLite integrity check at startup can make sense for robustness. I am not arguing that the check should simply be removed.

The issue I am trying to report is more about how the desktop client behaves while that check is running.

In this case, the client appears completely frozen: no tray icon, no visible progress, and no indication that a database check is happening. From the user point of view, it looks like the application is dead.

The sample output seems to confirm that the startup is blocked during this path:

OCC::SyncJournalDb::open
OCC::SqlDatabase::checkDb
OCC::SqlQuery::next
sqlite3_step
pread

And fs_usage shows repeated 4 KiB reads from the sync journal database with relatively high latency.

So I agree that the storage layer is part of the trigger, and I also agree that a full responsiveness fix may be a bigger change.

But I think there is still a client-side issue worth tracking:

  • the check runs during startup;
  • the main visible client does not appear before or during the check;
  • there is no progress indicator;
  • there is no diagnostic message;
  • the user has no way to distinguish “checking database on slow storage” from “the app is frozen”.

A basic visible startup indicator before the SQLite check starts would already improve the situation a lot.

I will try to open an issue in the nextcloud/desktop GitHub repository with the sample and fs_usage evidence.

Thanks again for pointing out the SQLite pragma quick_check part.

I did a local test this morning and the result seems to confirm the hypothesis.

I created a small LaunchAgent on macOS that runs at user graphical session startup, before opening Nextcloud. The script waits for the sync database to be available, reads it sequentially with dd, and only then launches the Nextcloud desktop client.

The script is basically:

#!/bin/bash
DB=“/Volumes/Nextcloud/.sync_2f4a44904d04.db”

for i in {1..30}; do
if [ -f “$DB” ]; then
/bin/dd if=“$DB” of=/dev/null bs=4m >/dev/null 2>&1
break
fi
/bin/sleep 2
done

open -a Nextcloud

After rebooting the Mac this morning, Nextcloud started normally and did not get stuck in the previous state.

So the practical workaround is:

  1. wait until the external volume is mounted
  2. sequentially read the sync journal SQLite database
  3. start Nextcloud only after that

This strongly suggests that the issue is related to cold small random reads from the sync journal database during startup. When the database file is warmed in the OS page cache first, the client starts normally.

I still agree that checking the database at startup can be useful for robustness.

The problem is the current visible behavior of the desktop client while this check is running:

  • no tray icon
  • no visible progress
  • no diagnostic message
  • the app looks frozen
  • the user cannot tell whether it is checking the database or actually stuck

So I would still consider this a desktop client startup behavior issue, not simply a storage performance issue.

A simple mitigation inside the client could be to show a visible startup state before the SQLite check starts. A better mitigation could be to make this startup check less vulnerable to cold random reads, or at least log clearly that the sync journal database check is running slowly.

For now, the local workaround works reliably in my case:

read .sync_*.db sequentially first, then start Nextcloud.