Bug 281542 - sysutils/bacula15-server: update_postgresql_tables fails to upgrade database
Summary: sysutils/bacula15-server: update_postgresql_tables fails to upgrade database
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Dan Langille
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-16 18:27 UTC by Danny McGrath
Modified: 2024-09-25 11:05 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (dvl)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Danny McGrath 2024-09-16 18:27:30 UTC
It would appear that Bacula 9 is due to be EOL'd at the end of the month, but I am noticing that Dan Langille's patches[1] to the upgrade scripts don't appear to be applied. I have tested his provided patches[2][3], and found them to work.

It is worth noting that the upgrade did appear to fail on me until I installed the pg_trgm extension in the system via the postgres-contrib package, so there may be some extra steps for people coming from 9.x to 15.x that find this during searches. Just be sure to also run[4]:

  CREATE EXTENSION pg_trgm;

The Bacula ML thread[5] had a discussion on it a while back, but I am not sure why it was never included.

Anyway, hopefully it helps future travellers and upgradees! :)

---
[1]: https://dan.langille.org/2023/11/23/bacula-moving-from-9-x-to-13-x-and-upgrading-the-postgresql-database/
[2]: https://github.com/dlangille/bacula-community/commit/0200b1461310b4f5d4cdb89aedaa2ca9c1e1ad77
[3]: https://github.com/dlangille/bacula-community/commit/716952b15b71be44f152bfb522666514422acc95
[4]: https://dba.stackexchange.com/questions/165300/how-to-install-the-additional-module-pg-trgm
[5]: https://sourceforge.net/p/bacula/mailman/bacula-users/thread/bc615327-20eb-4084-9bd9-e66bb85c04a7%40app.fastmail.com/#msg54707411
Comment 1 Danny McGrath 2024-09-16 18:31:24 UTC
And apologies to Dan Langille, whom I appear to have inadvertantly made an assignee that is responsible for this bug, when I merely wanted to ping them about it.

Any ideas how to do this properly would be appreciated! :) #GarrIDontKnowWhatImDoing
Comment 2 Dan Langille freebsd_committer freebsd_triage 2024-09-16 18:58:41 UTC
Checking my exentions:

bacula=# select * from pg_extension ;
  oid   | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition 
--------+---------+----------+--------------+----------------+------------+-----------+--------------
  13964 | plpgsql |       10 |           11 | f              | 1.0        |           | 
 809681 | pg_trgm |       10 |         2200 | t              | 1.6        |           | 
(2 rows)

bacula=# 


pg_trgm is not familiar to me.

plpgsql is there for FreshPorts stored procedures.
Comment 3 Dan Langille freebsd_committer freebsd_triage 2024-09-16 19:00:34 UTC
And I already use postgresql-contrib for various reasons (mostly FreshPorts).
Comment 4 Dan Langille freebsd_committer freebsd_triage 2024-09-16 19:07:55 UTC
You went from 9 to 15, that's a bigger jump.

Perhaps 9-13, then 13-15 might have been smoother.

To be clear this should work?

  CREATE EXTENSION pg_trgm;

(might need to install postgressql15-contrib (or whatever version))

patch update_bacula_tables using [2] & [3]

proceed as shown in [1]

If that's the case, I'll patch bacula15-server with [2] and [3]
Comment 5 Dan Langille freebsd_committer freebsd_triage 2024-09-16 19:09:38 UTC
Interesting:

bacula=# select * from version ;
 versionid 
-----------
      1026
      1026
(2 rows)

bacula=#
Comment 6 Danny McGrath 2024-09-16 20:35:57 UTC
(In reply to Dan Langille from comment #2)

I currently show the same on 15.x:

bacula=# select * from pg_extension ;
  oid  | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition 
-------+---------+----------+--------------+----------------+------------+-----------+--------------
 13915 | plpgsql |       10 |           11 | f              | 1.0        |           | 
 86134 | pg_trgm |       10 |         2200 | t              | 1.6        |           | 
(2 rows)

All I know is that when I didn't do it, the upgrade script went all the way through but spit out some warnings, compared to it being totally broken with the original upstream patch. It was complaining about version being 1024 instead of expected 14, or something weird (forget).

However at the end of the script, the director wouldn't even start for me until I installed contrib. I had already run the sql and created the extension, but I can't be sure if that step was necessary or if it would have been implicit somehow.

Currently I get 3 idential versions returned:

bacula=# select * from version;
 versionid 
-----------
      1026
      1026
      1026
(3 rows)

I still have the snapshot around until it is (atd) destroyed on Friday, plus various periodic ones, so I can always see about running any tests. Otherwise, I just went from 9 to 15 because 13 seemed like it was going to be about the same experience.
Comment 7 Danny McGrath 2024-09-16 20:47:07 UTC
Ah, apparently I forgot that I had seen the error in the syslog:

16-Sep 17:51 bacula-dir JobId 0: Fatal error: Version error for database "bacula". Wanted 1026, got 1024
16-Sep 17:51 bacula-dir JobId 0: Fatal error: Could not open Catalog "MyCatalog", database "bacula".
16-Sep 17:51 bacula-dir JobId 0: Fatal error: Version error for database "bacula". Wanted 1026, got 1024
16-Sep 17:51 bacula-dir ERROR TERMINATION
Please correct configuration file: /usr/local/etc/bacula/bacula-dir.conf

After restoring the DB dump, having the extension created and then running the patched upgreade script again, that error went away and the system started up just fine.
Comment 8 Dan Langille freebsd_committer freebsd_triage 2024-09-16 20:58:16 UTC
Let's see if useful information comes from:


https://sourceforge.net/p/bacula/mailman/message/58817212/
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-09-17 13:47:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7ebb2c9f2a6b891374686f5ca137ab4cc5db73e7

commit 7ebb2c9f2a6b891374686f5ca137ab4cc5db73e7
Author:     Dan Langille <dvl@FreeBSD.org>
AuthorDate: 2024-09-17 13:40:50 +0000
Commit:     Dan Langille <dvl@FreeBSD.org>
CommitDate: 2024-09-17 13:46:48 +0000

    sysutils/bacula15-server: patch to fix upgrade script

    With upcoming removal of bacula9 and bacula11, let's make this work.

    These patches have been submitted upstream but not released:

    * https://github.com/dlangille/bacula-community/commit/0200b1461310b4f5d4cdb89aedaa2ca9c1e1ad77
    * https://github.com/dlangille/bacula-community/commit/716952b15b71be44f152bfb522666514422acc95

    While here, remove Makefile.old committed during 9df94c4d9d1c50f758e9be67e51060a14527e2cc

    PR:             281542

 sysutils/bacula15-server/Makefile                  |   2 +-
 sysutils/bacula15-server/Makefile.old (gone)       | 207 ---------------------
 ...ch-src_cats_update__postgresql__tables.in (new) |  50 +++++
 3 files changed, 51 insertions(+), 208 deletions(-)
Comment 10 Dan Langille freebsd_committer freebsd_triage 2024-09-25 11:05:54 UTC
Thank you.


OSZAR »