Brewtarget / brewtarget

Main brewtarget source code repository.
GNU General Public License v3.0
313 stars 134 forks source link

Restoring database from another version of Brewtarget (self-compiled version 2.0.4 from 2018 codebase) on MacOS 11.7.8 causes application to fail to load on Brewtarget 3.0.9 on Linux Mint 21.1 #766

Closed rstanton00 closed 1 year ago

rstanton00 commented 1 year ago

I recently installed Brewtarget on a laptop running Linux Mint 21.1. I had previously been running Brewtarget on a MBPro with 11.7.8. I exported my database from there and attempted to restore it into the Linux Mint Brewtarget, so that I would have all my recipes along with self-added ingredients and styles. After restarting Brewtarget, I find the application can no longer successfully launch. Below is my terminal output. Unfortunately, I don't know enough about the application to debug what's going wrong on my own. I'd be happy to attach the database backup/export if there's a way to attach a file to an issue and work with anyone on finding out what the issue is.

ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table brewnote ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table equipment ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table fermentable ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table hop ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table instruction ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table fermentable_in_inventory ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table hop_in_inventory ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table misc_in_inventory ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table yeast_in_inventory ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table mash ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table mashstep ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table misc ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table recipe ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table salt ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table style ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table water ObjectStore::ObjectStore(const TypeLookup&, const ObjectStore::TableDefinition&, const JunctionTableDefinitions&) Construct of object store for primary table yeast void PersistentSettings::initialise(QString) Qt-proposed directories for user-specific configuration files are: ("/home/me/.config/brewtarget", "/etc/xdg/xdg-mate/brewtarget", "/etc/xdg/brewtarget") void PersistentSettings::initialise(QString) Preferred writeable directory for user-specific configuration files is: "/home/me/.config/brewtarget" void PersistentSettings::initialise(QString) Persistent settings file: "/home/me/.config/brewtarget/brewtargetPersistentSettings.conf" int main(int, char*) Persistent Settings initialised bool Logging::setDirectory(std::optional, Logging::PersistNewDirectory) bool Logging::setDirectory(std::optional, Logging::PersistNewDirectory) Logging to specified directory: "/home/me/.config/brewtarget" bool {anonymous}::openLogFile() Logging to file "/home/me/.config/brewtarget/brewtarget.log" [14:10:10.802] (1dod70lshs) INFO : Starting Brewtarget v 3.0.9 (app name "brewtarget" ) on "Linux Mint 21.1" [main.cpp:195] [14:10:10.802] (1dod70lshs) INFO : Built at Mon May 15 02:57:36 UTC 2023 on linux for linux with gcc compiler [main.cpp:198] [14:10:10.802] (1dod70lshs) INFO : Log directory: "/home/me/.config/brewtarget" [main.cpp:201] [14:10:10.802] (1dod70lshs) INFO : Using Qt runtime v 5.15.3 (compiled against Qt v 5.15.3 ) [main.cpp:202] [14:10:10.802] (1dod70lshs) INFO : Configuration directory: "/home/me/.config/brewtarget" [main.cpp:203] [14:10:10.802] (1dod70lshs) INFO : Data directory: "/home/me/.config/brewtarget" [main.cpp:204] [14:10:10.802] (1dod70lshs) INFO : void {anonymous}::initResourceDir(QDir&) Determined resource directory is "/usr/share/brewtarget" [Application.cpp:342] [14:10:10.802] (1dod70lshs) INFO : Resource directory: "/usr/share/brewtarget" [main.cpp:205] [14:10:10.868] (1dod70lshs) INFO : bool Database::load() Known DB drivers: ("QSQLITE") [database/Database.cpp:638] [14:10:10.868] (1dod70lshs) INFO : bool Database::impl::loadSQLite(Database&) dbFileName = " /home/me/.config/brewtarget/database.sqlite " dataDbFileName=" /usr/bin/../share/brewtarget/default_db.sqlite " [database/Database.cpp:251] [14:10:10.868] (1dod70lshs) INFO : bool Database::impl::loadSQLite(Database&) SQLite version QVariant(QString, "3.37.2") [database/Database.cpp:303] [14:10:10.869] (1dod70lshs) INFO : bool Database::impl::updateSchema(Database&, bool) Schema version in DB: 10 , current schema version in code: 10 [database/Database.cpp:399] [14:10:10.885] (1dod70lshs) ERROR : void ObjectStore::impl::wrapAndUnmapAsNeeded(const ObjectStore::TableDefinition&, const ObjectStore::TableField&, QVariant&) Unexpected type # 10 = QString in QVariant for property forcedCarbonation , field type FieldType # 0 : ( "ObjectStore::FieldType::Bool" ) , value QVariant(QString, "false") , table recipe , column forced_carb [database/ObjectStore.cpp:697] [14:10:10.886] (1dod70lshs) ERROR : void ObjectStore::impl::wrapAndUnmapAsNeeded(const ObjectStore::TableDefinition&, const ObjectStore::TableField&, QVariant&) Call stack is: Stacktrace: 0# Logging::getStackTrace() in brewtarget 1# ObjectStore::impl::wrapAndUnmapAsNeeded(ObjectStore::TableDefinition const&, ObjectStore::TableField const&, QVariant&) in brewtarget 2# ObjectStore::loadAll(Database) in brewtarget 3# __pthread_once_slow at ./nptl/pthread_once.c:118 4# ObjectStoreTyped::getInstance() in brewtarget 5# BtTreeModel::BtTreeModel(BtTreeView, BtTreeModel::TypeMasks) in brewtarget 6# BtTreeView::BtTreeView(QWidget, BtTreeModel::TypeMasks) in brewtarget 7# RecipeTreeView::RecipeTreeView(QWidget) in brewtarget 8# Ui_mainWindow::setupUi(QMainWindow) in brewtarget 9# MainWindow::MainWindow(QWidget) in brewtarget 10# 0x00005604FFC6AFA2 in brewtarget 11# __pthread_once_slow at ./nptl/pthread_once.c:118 12# MainWindow::instance() in brewtarget 13# Application::run() in brewtarget 14# main in brewtarget 15# libc_start_call_main at ../sysdeps/nptl/libc_start_call_main.h:58 16# libc_start_main at ../csu/libc-start.c:379 17# _start in brewtarget [database/ObjectStore.cpp:702] [14:10:10.886] (1dod70lshs) ERROR : ASSERT: "false" in file ../src/database/ObjectStore.cpp, line 704 [database/ObjectStore.cpp:704] Aborted (core dumped)

matty0ung commented 1 year ago

Sorry to hear you're having problems. It looks like the error message is saying that it found an unexpected value in the database. Specifically, it was trying to read the forced_carb column on the recipe table and it found the string "false" when it was expecting to get a boolean (ie ON/OFF) value of 0 or 1.

Do you know what version of Brewtarget you were running on the Mac?

If you want to attach your database file (see https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/attaching-files for how), I'd be happy to take a more detailed look.

matty0ung commented 1 year ago

The short-term fix will be just to edit the database to change false to 0 in the row or rows affected. (If you're comfortable using a tool such as DB Browser for SQLite can do this yourself, otherwise we can fix the file when you attach it to the issue.)

Longer term, I'll look at enhancing the code so that it can automatically recover from this sort of problem. It's because the SQLite database does not have a native boolean type and also does not enforce data types. Normally, it just stores true / false in an integer column as 0 / 1 and everything just works. However, it will also let you store strings in an integer column(!).

matty0ung commented 1 year ago

Should be fixed by https://github.com/Brewtarget/brewtarget/pull/767, but please re-open if not.

matty0ung commented 9 months ago

This should be fixed in https://github.com/Brewtarget/brewtarget/releases/tag/v3.0.10, but please re-open if not.