Bug 39460 - Debian package install broken in 24.11 if no database change included in package (e.g. 24.11.03-2)
Summary: Debian package install broken in 24.11 if no database change included in pack...
Status: Passed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Installation and upgrade (command-line installer) (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 - low blocker
Assignee: David Cook
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords: rel_22_11_candidate, rel_23_11_candidate, rel_24_05_candidate
Depends on: 34088
Blocks:
  Show dependency treegraph
 
Reported: 2025-03-26 03:13 UTC by Igor A. Sychev
Modified: 2025-04-02 15:15 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.03
Circulation function:


Attachments
Bug 39460: Fix koha-upgrade-schema when no DB change needed (2.12 KB, patch)
2025-04-01 01:55 UTC, David Cook
Details | Diff | Splinter Review
Bug 39460: Fix koha-upgrade-schema when no DB change needed (2.19 KB, patch)
2025-04-01 07:06 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 39460: Fix koha-upgrade-schema when no DB change needed (2.25 KB, patch)
2025-04-01 16:29 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Igor A. Sychev 2025-03-26 03:13:23 UTC
Настраивается пакет koha-common (24.11.03-2) …
Upgrading database schema for koha3
dpkg: ошибка при обработке пакета koha-common (--configure):
 installed koha-common package post-installation script subprocess returned error exit status 1
При обработке следующих пакетов произошли ошибки:
 koha-common
E: Sub-process /usr/bin/dpkg returned an error code (1)
Comment 1 David Cook 2025-03-26 04:01:23 UTC
There isn't really a bug description here. Rather, it sounds like you could use some support. I suggest one of the options available at https://koha-community.org/support/
Comment 2 Igor A. Sychev 2025-03-26 07:26:41 UTC
The error occurred during the update.
apt upgrade
...
Setting up koha-common (24.11.03-2) ...
Upgrading database schema for koha3
dpkg: error processing package koha-common (--configure):
 installed koha-common package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 koha-common
E: Sub-process /usr/bin/dpkg returned an error code (1)
Comment 3 David Cook 2025-03-31 23:41:40 UTC
This isn't a valid bug report. Please consult the support link posted previously.
Comment 4 David Cook 2025-03-31 23:47:40 UTC
Someone else seems to be having the same problem: https://chat.koha-community.org/koha-community/pl/h1gk86f5t7dw3m4w35huwdcd7o
Comment 5 David Cook 2025-04-01 00:08:45 UTC
Since there are 2 people reporting errors here I thought I'd take a deeper look. Decided to take a KTD from a custom 23.11.x to the Koha community released 24.11.03-2.

Upgrading database schema for kohadev
/usr/sbin/koha-upgrade-schema: 44: /kohadevbox/koha/installer/data/mysql/needs_update.pl: not found
dpkg: error processing package koha-common (--configure):
 installed koha-common package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 koha-common
E: Sub-process /usr/bin/dpkg returned an error code (1)

--

But... that's because my Koha git repo is still on 23.11.x, so let me try that again using the tag v24.11.03-2

Upgrading database schema for kohadev
Use of uninitialized value $pref in string eq at /kohadevbox/koha/installer/data/mysql/db_revs/231200005.pl line 89.
0E0
Upgrade to 23.12.00.000  [00:06:57]: Increase DBRev for 23.12
<Lots of valid upgrade lines...>
Upgrade to 24.11.03.000  [00:07:07]: Koha 24.11.03 release
Enabling plugins on node rabbit@kohadevbox:
rabbitmq_stomp
The following plugins have been configured:
  rabbitmq_stomp
Applying plugin configuration to rabbit@kohadevbox...
Plugin configuration unchanged.
 * Restarting RabbitMQ Messaging Server rabbitmq-server                                                                                                                                                                               [ OK ]
Restarting memcached: memcached.

--

It's looking OK to me.
Comment 6 David Cook 2025-04-01 00:18:18 UTC
I think I might be reproducing the problem now...

After a fine install for koha-common, I upgraded koha-l10n to 24.11.03-2.

Then I re-installed koha-common 24.11.03-2 and now I'm getting the error:

Preparing to unpack .../koha-common_24.11.03-2_all.deb ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of stop.
Unpacking koha-common (24.11.03-2) over (24.11.03-2) ...
Setting up koha-common (24.11.03-2) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Upgrading database schema for kohadev
dpkg: error processing package koha-common (--configure):
 installed koha-common package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 koha-common
E: Sub-process /usr/bin/dpkg returned an error code (1)
Comment 7 David Cook 2025-04-01 00:23:05 UTC
root@kohadevbox:koha$ koha-upgrade-schema kohadev
Upgrading database schema for kohadev
root@kohadevbox:koha$ echo $?
1

As I said on Mattermost, I had a feeling that "koha-upgrade-schema INSTANCE" was probably silently failing, and that appears to be the case.
Comment 8 David Cook 2025-04-01 00:35:32 UTC
Apologies for the delay on this one, Igor. 

This kind of issue does require additional information. Luckily, someone on Mattermost provided some extra information, which gave me an idea, and I was able to reproduce the problem on my system.

I can confirm it's from bug 34088, since tweaking "installer/data/mysql/needs_update.pl" to not return an exit code of 1 fixed the problem.

Now I can run "dpkg --configure koha-common" and it completes successfully. 

A workaround would be to do this:

1. vi /usr/share/koha/intranet/cgi-bin/installer/data/mysql/needs_update.pl
2. Perform the following change:
-exit !Koha::Installer->needs_update;
+Koha::Installer->needs_update;
+exit;
3. dpkg --configure koha-common
4. apt-get install koha-common
5. Confirm that everything is fine now

That should get your system back into a healthy state, while we work on resolving the deeper problem...
Comment 9 David Cook 2025-04-01 01:55:40 UTC
Created attachment 180084 [details] [review]
Bug 39460: Fix koha-upgrade-schema when no DB change needed

This patch fixes koha-upgrade-schema so that it returns an exit
code of 0 whether or not a DB change is needed. This is important
so that koha-common.postinst proceeds correctly even when there
is no DB change needed (e.g. for 24.11.03-2)

Test plan:
0. Apply the patch
1. cp debian/scripts/koha-upgrade-schema /usr/sbin/koha-upgrade-schema
2. dpkg-reconfigure koha-common
3. Note the process completes correctly
4. koha-upgrade-schema kohadev
5. Note following text appears very quickly:
Upgrading database schema for kohadev
No database change required
6. koha-mysql kohadev
update systempreferences set value = '24.1102000' where variable = 'Version';
7. Clear memcached
8. koha-upgrade-schema kohadev
9. Note that it applies the 24.11.03 database upgrade
Comment 10 Jonathan Druart 2025-04-01 07:06:13 UTC
Created attachment 180085 [details] [review]
Bug 39460: Fix koha-upgrade-schema when no DB change needed

This patch fixes koha-upgrade-schema so that it returns an exit
code of 0 whether or not a DB change is needed. This is important
so that koha-common.postinst proceeds correctly even when there
is no DB change needed (e.g. for 24.11.03-2)

Test plan:
0. Apply the patch
1. cp debian/scripts/koha-upgrade-schema /usr/sbin/koha-upgrade-schema
2. dpkg-reconfigure koha-common
3. Note the process completes correctly
4. koha-upgrade-schema kohadev
5. Note following text appears very quickly:
Upgrading database schema for kohadev
No database change required
6. koha-mysql kohadev
update systempreferences set value = '24.1102000' where variable = 'Version';
7. Clear memcached
8. koha-upgrade-schema kohadev
9. Note that it applies the 24.11.03 database upgrade

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 11 Martin Renvoize (ashimema) 2025-04-01 16:29:20 UTC
Created attachment 180223 [details] [review]
Bug 39460: Fix koha-upgrade-schema when no DB change needed

This patch fixes koha-upgrade-schema so that it returns an exit
code of 0 whether or not a DB change is needed. This is important
so that koha-common.postinst proceeds correctly even when there
is no DB change needed (e.g. for 24.11.03-2)

Test plan:
0. Apply the patch
1. cp debian/scripts/koha-upgrade-schema /usr/sbin/koha-upgrade-schema
2. dpkg-reconfigure koha-common
3. Note the process completes correctly
4. koha-upgrade-schema kohadev
5. Note following text appears very quickly:
Upgrading database schema for kohadev
No database change required
6. koha-mysql kohadev
update systempreferences set value = '24.1102000' where variable = 'Version';
7. Clear memcached
8. koha-upgrade-schema kohadev
9. Note that it applies the 24.11.03 database upgrade

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 12 Paul Derscheid 2025-04-02 15:15:06 UTC
Nice work David!

Pushed to 24.11.x for 24.11.03 (24.11.03-3)