frappe / books

Free Accounting Software
https://frappe.io/books
GNU Affero General Public License v3.0
2.68k stars 614 forks source link

🐛 [Bug] - Database error #861

Closed njmulsqb closed 4 months ago

njmulsqb commented 4 months ago

Current Behavior

Getting this error while using frappe. Submitting purchase payments is not updating the records and corresponding invoice is still unpaid.

image

Info

Error: DatabaseError: SqliteError select name, symbol from Currency order by created desc - database disk image is malformed

Stack:

SqliteError: select `name`, `symbol` from `Currency` order by `created` desc - database disk image is malformed
    at Client_BetterSQLite3._query (/Applications/Frappe Books.app/Contents/Resources/app.asar/node_modules/knex/lib/dialects/better-sqlite3/index.js:34:40)
    at executeQuery (/Applications/Frappe Books.app/Contents/Resources/app.asar/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)
    at Client_BetterSQLite3.query (/Applications/Frappe Books.app/Contents/Resources/app.asar/node_modules/knex/lib/client.js:146:12)
    at Runner.query (/Applications/Frappe Books.app/Contents/Resources/app.asar/node_modules/knex/lib/execution/runner.js:123:36)
    at ensureConnectionCallback (/Applications/Frappe Books.app/Contents/Resources/app.asar/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)
    at Runner.ensureConnection (/Applications/Frappe Books.app/Contents/Resources/app.asar/node_modules/knex/lib/execution/runner.js:300:20)
    at Runner.run (/Applications/Frappe Books.app/Contents/Resources/app.asar/node_modules/knex/lib/execution/runner.js:30:19)
    at _DatabaseCore.getAll (/Applications/Frappe Books.app/Contents/backend/database/core.ts:287:13)
    at DatabaseManager.call (/Applications/Frappe Books.app/Contents/backend/database/manager.ts:147:22)
    at /Applications/Frappe Books.app/Contents/main/registerIpcMainActionListeners.ts:238:16

Version: 0.21.2 Platform: darwin Path: /index.html Language: - Country: pk

Isaac-GC commented 4 months ago

Hi @njmulsqb, is this database saved in a place where it is sync'd using Google Drive, Microsoft OneDrive, or some other sort of cloud sync solution?

njmulsqb commented 4 months ago

Hi @njmulsqb, is this database saved in a place where it is sync'd using Google Drive, Microsoft OneDrive, or some other sort of cloud sync solution?

Yes. Pcloud. Earliet it was on onedrive without any issues.

Isaac-GC commented 4 months ago

Unfortunately, this is not a frappe books issue, but a cloud sync issue with the sqlite database

I have encountered similar issues to this using Google Drive, Owncloud, and Dropbox, and unfortunately don't have any workarounds that I've found to work. Heck, even using Microsoft OneDrive to sync Microsoft Word documents (which is heavily supported) -> I've had the same issues with word documents being corrupted and/or wrong versions being saved that overwrite the desired changes.

I do recommend backing up the database to a cloud sync service such as PCloud or OneDrive. However, due to the nature of how cloud syncing works, actively using a sqlite database with a cloud sync service is not recommended due to the high potential for the database to be corrupted (as seen above)

Here's a similar situation: https://stackoverflow.com/questions/78048531/how-to-sync-sqlite-database-with-icloud

Please note that there is future work planned to support other databases (Mysql, PostgreSQL, etc) that could potentially mitigate the need for cloud syncing a sqlite database


Closing this issue as the issue is due to cloud sync conflicts and not anything caused by/in frappe books itself

njmulsqb commented 4 months ago

@Isaac-GC what's the solution to this corrupted DB file? How can I get it to work again?

Isaac-GC commented 4 months ago

I'm not too sure with PCloud, but if it's like other cloud sync systems, you may be prompted to resolve a conflict with the database. If that doesn't work, try restoring the most recent historical version.