Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres issue w/ fresh install #760

Closed
marker5a opened this issue Jul 3, 2023 · 7 comments
Closed

Postgres issue w/ fresh install #760

marker5a opened this issue Jul 3, 2023 · 7 comments

Comments

@marker5a
Copy link
Contributor

marker5a commented Jul 3, 2023

I setup a fresh postgres14 instance w/ an empty schema and connected a fresh install of brewtarget to the database through the settings page. After connecting successfully and presumably setting up the schema and init data, it prompted me to restart.

After exiting, Brewtarget will no longer startup and it returns the following assertion log:

[13:26:36.135] (1dtmv05kg0) INFO : Starting Brewtarget v 3.0.9 (app name "brewtarget" ) on "Arch Linux" [main.cpp:195]
[13:26:36.135] (1dtmv05kg0) INFO : Built at 2023-07-03 16:48:40 (UTC) on Linux-5.15.94-1-lts for Linux-5.15.94-1-lts with GNU compiler [main.cpp:198]
[13:26:36.135] (1dtmv05kg0) INFO : Log directory: "/home/marker5a" [main.cpp:201]
[13:26:36.135] (1dtmv05kg0) INFO : Using Qt runtime v 5.15.10 (compiled against Qt v 5.15.10 ) [main.cpp:202]
[13:26:36.135] (1dtmv05kg0) INFO : Configuration directory: "/home/marker5a/.config/brewtarget" [main.cpp:203]
[13:26:36.135] (1dtmv05kg0) INFO : Data directory: "/home/marker5a/.config/brewtarget" [main.cpp:204]
[13:26:36.135] (1dtmv05kg0) INFO : void {anonymous}::initResourceDir(QDir&) Determined resource directory is "/usr/share/brewtarget" [Application.cpp:342]
[13:26:36.135] (1dtmv05kg0) INFO : Resource directory: "/usr/share/brewtarget" [main.cpp:205]
[13:26:37.077] (1dtmv05kg0) INFO : bool Database::load() Known DB drivers: ("QIBASE", "QSQLITE", "QSQLITE3", "QMARIADB", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7", "QTDS", "QTDS7") [database/Database.cpp:638]
[13:26:37.109] (1dtmv05kg0) INFO : bool Database::impl::loadPgSQL(Database&) PostgreSQL version QVariant(QString, "PostgreSQL 14.8 (Debian 14.8-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit") [database/Database.cpp:386]
[13:26:37.115] (1dtmv05kg0) INFO : bool Database::impl::updateSchema(Database&, bool*) Schema version in DB: 10 , current schema version in code: 10 [database/Database.cpp:399]
[13:26:37.152] (1dtmv05kg0) ERROR : void ObjectStore::impl::wrapAndUnmapAsNeeded(const ObjectStore::TableDefinition&, const ObjectStore::TableField&, QVariant&) Unexpected type # 2 = int in QVariant for property fermentationStages , field type FieldType # 2 : ( "ObjectStore::FieldType::UInt" ) , value QVariant(int, 1) , table recipe , column fermentation_stages [database/ObjectStore.cpp:699]
[13:26:37.154] (1dtmv05kg0) 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# 0x00007FD5ECE605BF in /usr/lib/libc.so.6
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# 0x000056514D45DA3F in brewtarget
11# 0x00007FD5ECE605BF in /usr/lib/libc.so.6
12# MainWindow::instance() in brewtarget
13# Application::run() in brewtarget
14# main in brewtarget
15# 0x00007FD5ECDF7850 in /usr/lib/libc.so.6
16# __libc_start_main in /usr/lib/libc.so.6
17# _start in brewtarget
[database/ObjectStore.cpp:704]
[13:26:37.154] (1dtmv05kg0) ERROR : ASSERT: "false" in file /media/build_environment/yaourt/yaourt-tmp-marker5a/aur-brewtarget/src/brewtarget-3.0.9/src/database/ObjectStore.cpp, line 706 [database/ObjectStore.cpp:706]
Aborted (core dumped)

From looking at the code, it looks to just be a typecast issue... I changed it on my working copy and it seems fine...


diff --git a/src/database/ObjectStoreTyped.cpp b/src/database/ObjectStoreTyped.cpp
index 91093c1f..f9f0e259 100644
--- a/src/database/ObjectStoreTyped.cpp
+++ b/src/database/ObjectStoreTyped.cpp
@@ -563,7 +563,7 @@ namespace {
          {ObjectStore::FieldType::Date,   "date",                PropertyNames::Recipe::date                },
          {ObjectStore::FieldType::Double, "efficiency",          PropertyNames::Recipe::efficiency_pct      },
          {ObjectStore::FieldType::Int,    "equipment_id",        PropertyNames::Recipe::equipmentId,          nullptr,                &PRIMARY_TABLE<Equipment>},
-         {ObjectStore::FieldType::UInt,   "fermentation_stages", PropertyNames::Recipe::fermentationStages  },
+         {ObjectStore::FieldType::Int,   "fermentation_stages", PropertyNames::Recipe::fermentationStages  },
          {ObjectStore::FieldType::Double, "fg",                  PropertyNames::Recipe::fg                  },
          {ObjectStore::FieldType::Bool,   "forced_carb",         PropertyNames::Recipe::forcedCarbonation   },
          {ObjectStore::FieldType::Double, "keg_priming_factor",  PropertyNames::Recipe::kegPrimingFactor    },

@matty0ung
Copy link
Contributor

Ah, good spot, and, yes, that's a good fix. (Alternatively, if we wanted to be super pedantic about the fact that there should never be a negative number of fermentation stages, then, in model/Recipe.h, we could make fermentationStages an unsigned int property, with the corresponding changes to its getter and setter, but I'm not sure if that would be worth the hassle.)

AFAICT this is a property that we don't currently expose in the UI, but I'm hoping/expecting to change that as part of the BeerJSON work.

@matty0ung
Copy link
Contributor

If you want to do a PR, I'll happily approve it.

Otherwise I'll include the fix in whatever the next commit is.

@marker5a
Copy link
Contributor Author

marker5a commented Jul 3, 2023 via email

@matty0ung
Copy link
Contributor

PS: I do half expect you to find other PostgreSQL issues, because it's a bit less fast-and-loose about things than SQLite. They should all be fixable though!

@marker5a
Copy link
Contributor Author

marker5a commented Jul 3, 2023 via email

@marker5a
Copy link
Contributor Author

marker5a commented Jul 3, 2023

Should be fixed in PR #762

@marker5a marker5a closed this as completed Jul 3, 2023
@matty0ung
Copy link
Contributor

This fix is included in in https://github.com/Brewtarget/brewtarget/releases/tag/v3.0.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants