Sync error on Linux - database query issue

Operating system

Linux

Joplin version

3.1.24

Desktop version info

Joplin 3.1.24 (prod, linux)

Client ID: 5639202a4c1d47da85ed851c07779a4f
Sync Version: 3
Profile Version: 47
Keychain Supported: No

Revision: d581264

Backup: 1.4.2

Sync target

Joplin Server

What issue do you have?

Hi! I've recently started to have an issue where I'm not able to sync my notes on Linux. I use Joplin Desktop mostly on Windows but also I like to sync to my linux and ios device (and also Joplin terminal). On Linux Desktop I've started to get the database error below that prevents me from using the Linux Desktop app...note I am still able to sync with all of my other joplin installs.

Any guidance on my next steps? I have had this issue before and I decided to restore everything from backup which worked for a few weeks until the same thing happened again...I'm hoping there's a more elegant solution though.

Synchronizer: Error: On query
SELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`
				FROM `notes` items
				WHERE id NOT IN (
					SELECT item_id FROM sync_items WHERE sync_target = 9
				)
				AND is_conflict = 0 AND encryption_applied = 0
				ORDER BY items.updated_time DESC
				LIMIT 100
			: 
    at DatabaseDriverNode.sqliteErrorToJsError (/tmp/.mount_JoplinKY…river-node.js:23:18)
    at JoplinDatabase.sqliteErrorToJsError (/tmp/.mount_JoplinKY…b/database.js:27:30)
    at JoplinDatabase.tryCall (/tmp/.mount_JoplinKY…/database.js:130:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Note.modelSelectAll (/tmp/.mount_JoplinKY…BaseModel.js:325:28)
    at async BaseItem.itemsThatNeedSync (/tmp/.mount_JoplinKY…/BaseItem.js:611:37)
    at async Synchronizer.start (/tmp/.mount_JoplinKY…chronizer.js:521:36)
    at async Timeout.timeoutCallback [as _onTimeout] (/tmp/.mount_JoplinKY…/registry.js:125:52)

I've opened a GitHub issue for this:

It's strange that it doesn't show the error message. Is there any additional information before or after this error in the log @bak?

Oh yah, sorry, I should have looked in the log, I just turned off debugging mode and saw the error above. The log is complaining about a corrupt database. Here's more info:

2024-12-13 06:31:25: e2ee/utils: findMasterKeyPassword: Using master password
2024-12-13 06:31:25: e2ee/utils: Loaded master keys: 1
2024-12-13 06:31:26: DecryptionWorker: starting decryption...
2024-12-13 06:31:26: DecryptionWorker: completed decryption.
2024-12-13 06:31:26: useFormNote: Sync has finished and note has never been changed - reloading it
2024-12-13 06:31:26: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote 273274a039c44d94b3937793dd3e4a49)
2024-12-13 06:31:27: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote 633ae5c33a5746bd85a12778c7e73bc9)
2024-12-13 06:31:27: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote 0e591b55f56444178d2726b1f933ce1f)
2024-12-13 06:31:27: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote a2c666fc7ba447139c2b53b5581d7d0f)
2024-12-13 06:31:27: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote 3bea61307a794d9aa80ea443fdf330b1)
2024-12-13 06:31:28: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote 51d31cee13764a899d0c50746500d1a3)
2024-12-13 06:31:28: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote 14832392db0145f79a57d2415d0498ca)
2024-12-13 06:31:28: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote 4fc0147d7352402b83ed44390d9774f0)
2024-12-13 06:31:28: Synchronizer: Sync: deleteRemote: local has been deleted: (Remote 5e267279c79f4c34850b13cc543b2adf)
2024-12-13 06:31:28: Synchronizer: [error] Error: On query {"sql":"\n\t\t\t\tSELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`\n\t\t\t\tFROM `notes` items\n\t\t\t\tWHERE id NOT IN (\n\t\t\t\t\tSELECT item_id FROM sync_items WHERE sync_target = 9\n\t\t\t\t)\n\t\t\t\tAND is_conflict = 0 AND encryption_applied = 0\n\t\t\t\tORDER BY items.updated_time DESC\n\t\t\t\tLIMIT 100\n\t\t\t","params":[]}: Error: SQLITE_CORRUPT: database disk image is malformed: 
				SELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`
				FROM `notes` items
				WHERE id NOT IN (
					SELECT item_id FROM sync_items WHERE sync_target = 9
				)
				AND is_conflict = 0 AND encryption_applied = 0
				ORDER BY items.updated_time DESC
				LIMIT 100
			: 
Code: SQLITE_CORRUPT
Error: On query {"sql":"\n\t\t\t\tSELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`\n\t\t\t\tFROM `notes` items\n\t\t\t\tWHERE id NOT IN (\n\t\t\t\t\tSELECT item_id FROM sync_items WHERE sync_target = 9\n\t\t\t\t)\n\t\t\t\tAND is_conflict = 0 AND encryption_applied = 0\n\t\t\t\tORDER BY items.updated_time DESC\n\t\t\t\tLIMIT 100\n\t\t\t","params":[]}: Error: SQLITE_CORRUPT: database disk image is malformed: 
				SELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`
				FROM `notes` items
				WHERE id NOT IN (
					SELECT item_id FROM sync_items WHERE sync_target = 9
				)
				AND is_conflict = 0 AND encryption_applied = 0
				ORDER BY items.updated_time DESC
				LIMIT 100
			: 
    at DatabaseDriverNode.sqliteErrorToJsError (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database-driver-node.js:23:18)
    at JoplinDatabase.sqliteErrorToJsError (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database.js:27:30)
    at JoplinDatabase.tryCall (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database.js:130:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Note.modelSelectAll (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/BaseModel.js:325:28)
    at async BaseItem.itemsThatNeedSync (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/models/BaseItem.js:611:37)
    at async Synchronizer.start (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/Synchronizer.js:521:36)
    at async Timeout.timeoutCallback [as _onTimeout] (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/registry.js:125:52)
2024-12-13 06:31:29: SearchEngine: Updating FTS table...
2024-12-13 06:31:29: Updating items_normalized from {"updated_time":1732036043881,"id":"e6d7c6c236be4f7eb1d149679e84ae3c"}
2024-12-13 06:31:29: SearchEngine: Updated FTS table in 95ms. Inserted: 0. Deleted: 2
2024-12-13 06:31:29: ShareService: Refresh share invitations: []
2024-12-13 06:31:29: ShareService: Refreshed shares: {"items":[],"has_more":false}
2024-12-13 06:31:29: Synchronizer: Sync: finished: Synchronisation finished [1734089481495]
2024-12-13 06:31:29: Synchronizer: Operations completed: 
2024-12-13 06:31:29: Synchronizer: deleteRemote: 9
2024-12-13 06:31:29: Synchronizer: Total folders: 46
2024-12-13 06:31:29: Synchronizer: Total notes: 1213
2024-12-13 06:31:29: Synchronizer: Total resources: 2708
2024-12-13 06:31:29: Synchronizer: [warn] There was some errors:
2024-12-13 06:31:29: Synchronizer: [warn] Error: On query {"sql":"\n\t\t\t\tSELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`\n\t\t\t\tFROM `notes` items\n\t\t\t\tWHERE id NOT IN (\n\t\t\t\t\tSELECT item_id FROM sync_items WHERE sync_target = 9\n\t\t\t\t)\n\t\t\t\tAND is_conflict = 0 AND encryption_applied = 0\n\t\t\t\tORDER BY items.updated_time DESC\n\t\t\t\tLIMIT 100\n\t\t\t","params":[]}: Error: SQLITE_CORRUPT: database disk image is malformed: 
				SELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`
				FROM `notes` items
				WHERE id NOT IN (
					SELECT item_id FROM sync_items WHERE sync_target = 9
				)
				AND is_conflict = 0 AND encryption_applied = 0
				ORDER BY items.updated_time DESC
				LIMIT 100
			: 
Code: SQLITE_CORRUPT
Error: On query {"sql":"\n\t\t\t\tSELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`\n\t\t\t\tFROM `notes` items\n\t\t\t\tWHERE id NOT IN (\n\t\t\t\t\tSELECT item_id FROM sync_items WHERE sync_target = 9\n\t\t\t\t)\n\t\t\t\tAND is_conflict = 0 AND encryption_applied = 0\n\t\t\t\tORDER BY items.updated_time DESC\n\t\t\t\tLIMIT 100\n\t\t\t","params":[]}: Error: SQLITE_CORRUPT: database disk image is malformed: 
				SELECT items.`id`,items.`parent_id`,items.`title`,items.`body`,items.`created_time`,items.`updated_time`,items.`is_conflict`,items.`latitude`,items.`longitude`,items.`altitude`,items.`author`,items.`source_url`,items.`is_todo`,items.`todo_due`,items.`todo_completed`,items.`source`,items.`source_application`,items.`application_data`,items.`order`,items.`user_created_time`,items.`user_updated_time`,items.`encryption_cipher_text`,items.`encryption_applied`,items.`markup_language`,items.`is_shared`,items.`share_id`,items.`conflict_original_id`,items.`master_key_id`,items.`user_data`,items.`deleted_time`
				FROM `notes` items
				WHERE id NOT IN (
					SELECT item_id FROM sync_items WHERE sync_target = 9
				)
				AND is_conflict = 0 AND encryption_applied = 0
				ORDER BY items.updated_time DESC
				LIMIT 100
			: 
    at DatabaseDriverNode.sqliteErrorToJsError (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database-driver-node.js:23:18)
    at JoplinDatabase.sqliteErrorToJsError (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database.js:27:30)
    at JoplinDatabase.tryCall (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database.js:130:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Note.modelSelectAll (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/BaseModel.js:325:28)
    at async BaseItem.itemsThatNeedSync (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/models/BaseItem.js:611:37)
    at async Synchronizer.start (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/Synchronizer.js:521:36)
    at async Timeout.timeoutCallback [as _onTimeout] (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/registry.js:125:52)
2024-12-13 06:31:29: Could not run background sync:
2024-12-13 06:31:29: Error: Error: SQLITE_CORRUPT: database disk image is malformed: SELECT count(*) as total FROM sync_items WHERE sync_disabled = 1 AND sync_target = ? AND sync_warning_ignored = 0: 9
Code: SQLITE_CORRUPT
Error: Error: SQLITE_CORRUPT: database disk image is malformed: SELECT count(*) as total FROM sync_items WHERE sync_disabled = 1 AND sync_target = ? AND sync_warning_ignored = 0: 9
    at DatabaseDriverNode.sqliteErrorToJsError (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database-driver-node.js:23:18)
    at JoplinDatabase.sqliteErrorToJsError (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database.js:27:30)
    at JoplinDatabase.tryCall (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/database.js:130:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async BaseItem.syncDisabledItemsCount (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/models/BaseItem.js:694:19)
    at async exports.default (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/services/synchronizer/utils/checkDisabledSyncItemsNotification.js:15:27)
    at async Synchronizer.start (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/Synchronizer.js:1070:9)
    at async Timeout.timeoutCallback [as _onTimeout] (/tmp/.mount_JoplinD4WdiJ/resources/app.asar/node_modules/@joplin/lib/registry.js:125:52)
2024-12-13 06:31:29: Updating all notifications...

There's no fix for this unfortunately, you should restore from a recent backup. On recent versions of Joplin the Backup plugin should be installed so you can restore from this

ok no worries. I was able to fix by just copying over my database from Joplin-desktop on windows to my linux version and that is working. I just thought the database error was worth mentioning because it's not the first time it's happened to me, I'm not sure what causes it.

It's rare that a sqlite database gets corrupted. It could happen if you have two apps, such as cli and desktop syncing to the same profile, or if your disk is faulty

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.