OPNsense Forum

Archive => 19.7 Legacy Series => Topic started by: mapsware on February 14, 2020, 09:33:57 pm

Title: SOLVED Upgrade failed pkg-static: sqlite error: database disk image is malformed
Post by: mapsware on February 14, 2020, 09:33:57 pm
I am upgrading from 19.7.9-i386 to 19.7.10-i386

At the end of the OPNsense update I noticed the following error messages

pkg-static: sqlite error while executing iterator in file pkgdb_iterator.c:1080: database disk image is malformed
pkg-static: sqlite error while executing INSERT OR REPLACE INTO files (path, sha256, package_id) VALUES (?1, ?2, ?3) in file pkgdb.c:1832: database disk image is malformed

This it's the log of the upgrade process (errors at the bottom)

Code: [Select]
***GOT REQUEST TO UPGRADE: all***
Updating OPNsense repository catalogue...
OPNsense repository is up to date.
All repositories are up to date.
Updating OPNsense repository catalogue...
OPNsense repository is up to date.
All repositories are up to date.
Checking for upgrades (56 candidates): .......... done
Processing candidates (56 candidates): .......... done
The following 57 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
openssl102: 1.0.2u

Installed packages to be UPGRADED:
unbound: 1.9.5 -> 1.9.6
sudo: 1.8.29 -> 1.8.30
strongswan: 5.8.1 -> 5.8.2_1
readline: 8.0.0 -> 8.0.1
python37: 3.7.5_1 -> 3.7.6
py37-urllib3: 1.25.6,1 -> 1.25.7,1
py37-sqlite3: 3.7.5_7 -> 3.7.6_7
py37-six: 1.12.0 -> 1.13.0
py37-setuptools: 41.4.0 -> 44.0.0
py37-chardet: 3.0.4_2 -> 3.0.4_3
py37-certifi: 2019.9.11 -> 2019.11.28
php72-zlib: 7.2.25 -> 7.2.26
php72-xml: 7.2.25 -> 7.2.26
php72-sqlite3: 7.2.25 -> 7.2.26
php72-sockets: 7.2.25 -> 7.2.26
php72-simplexml: 7.2.25 -> 7.2.26
php72-session: 7.2.25 -> 7.2.26
php72-phpseclib: 2.0.21 -> 2.0.23
php72-pdo: 7.2.25 -> 7.2.26
php72-openssl: 7.2.25 -> 7.2.26
php72-ldap: 7.2.25 -> 7.2.26
php72-json: 7.2.25 -> 7.2.26
php72-hash: 7.2.25 -> 7.2.26
php72-gettext: 7.2.25 -> 7.2.26
php72-filter: 7.2.25 -> 7.2.26
php72-dom: 7.2.25 -> 7.2.26
php72-curl: 7.2.25 -> 7.2.26
php72-ctype: 7.2.25 -> 7.2.26
php72: 7.2.25 -> 7.2.26
pftop: 0.7_8 -> 0.7_9
os-dyndns: 1.18 -> 1.18_1
opnsense: 19.7.8 -> 19.7.10_1
openssh-portable: 8.0.p1_1,1 -> 8.1.p1,1
liblz4: 1.9.2,1 -> 1.9.2_1,1
libedit: 3.1.20190324,1 -> 3.1.20191211,1
isc-dhcp44-server: 4.4.1_4 -> 4.4.2
isc-dhcp44-relay: 4.4.1 -> 4.4.2
e2fsprogs-libuuid: 1.45.3 -> 1.45.5
cyrus-sasl: 2.1.27 -> 2.1.27_1
curl: 7.67.0 -> 7.68.0
ca_root_nss: 3.48 -> 3.49.1

Installed packages to be REINSTALLED:
wpa_supplicant-2.9 (options changed)
syslog-ng324-3.24.1 (direct dependency changed: openssl102)
squid-4.9 (direct dependency changed: krb5)
py37-cryptography-2.6.1 (direct dependency changed: openssl102)
opnsense-update-19.7.7 (direct dependency changed: openssl102)
openvpn-2.4.8 (direct dependency changed: openssl102)
openldap-sasl-client-2.4.48 (direct dependency changed: cyrus-sasl)
ntp-4.2.8p13_6 (direct dependency changed: openssl102)
mpd5-5.8_10 (direct dependency changed: openssl102)
monit-5.26.0 (direct dependency changed: openssl102)
lighttpd-1.4.54 (direct dependency changed: openssl102)
libevent-2.1.11 (direct dependency changed: openssl102)
ldns-1.7.1_1 (direct dependency changed: openssl102)
krb5-1.17.1 (direct dependency changed: openssl102)
hostapd-2.9 (direct dependency changed: openssl102)

Number of packages to be installed: 1
Number of packages to be upgraded: 41
Number of packages to be reinstalled: 15

The process will require 9 MiB more space.
42 MiB to be downloaded.
[1/57] Fetching wpa_supplicant-2.9.txz: .......... done
[2/57] Fetching unbound-1.9.6.txz: .......... done
[3/57] Fetching syslog-ng324-3.24.1.txz: .......... done
[4/57] Fetching sudo-1.8.30.txz: .......... done
[5/57] Fetching strongswan-5.8.2_1.txz: .......... done
[6/57] Fetching squid-4.9.txz: .......... done
[7/57] Fetching readline-8.0.1.txz: .......... done
[8/57] Fetching python37-3.7.6.txz: .......... done
[9/57] Fetching py37-urllib3-1.25.7,1.txz: .......... done
[10/57] Fetching py37-sqlite3-3.7.6_7.txz: .... done
[11/57] Fetching py37-six-1.13.0.txz: ... done
[12/57] Fetching py37-setuptools-44.0.0.txz: .......... done
[13/57] Fetching py37-cryptography-2.6.1.txz: .......... done
[14/57] Fetching py37-chardet-3.0.4_3.txz: .......... done
[15/57] Fetching py37-certifi-2019.11.28.txz: .......... done
[16/57] Fetching php72-zlib-7.2.26.txz: ... done
[17/57] Fetching php72-xml-7.2.26.txz: ... done
[18/57] Fetching php72-sqlite3-7.2.26.txz: ... done
[19/57] Fetching php72-sockets-7.2.26.txz: ..... done
[20/57] Fetching php72-simplexml-7.2.26.txz: ... done
[21/57] Fetching php72-session-7.2.26.txz: ..... done
[22/57] Fetching php72-phpseclib-2.0.23.txz: .......... done
[23/57] Fetching php72-pdo-7.2.26.txz: ...... done
[24/57] Fetching php72-openssl-7.2.26.txz: ....... done
[25/57] Fetching php72-ldap-7.2.26.txz: ... done
[26/57] Fetching php72-json-7.2.26.txz: ... done
[27/57] Fetching php72-hash-7.2.26.txz: .......... done
[28/57] Fetching php72-gettext-7.2.26.txz: . done
[29/57] Fetching php72-filter-7.2.26.txz: ... done
[30/57] Fetching php72-dom-7.2.26.txz: ....... done
[31/57] Fetching php72-curl-7.2.26.txz: .... done
[32/57] Fetching php72-ctype-7.2.26.txz: . done
[33/57] Fetching php72-7.2.26.txz: .......... done
[34/57] Fetching pftop-0.7_9.txz: ........ done
[35/57] Fetching os-dyndns-1.18_1.txz: .... done
[36/57] Fetching opnsense-update-19.7.7.txz: .... done
[37/57] Fetching opnsense-19.7.10_1.txz: .......... done
[38/57] Fetching openvpn-2.4.8.txz: .......... done
[39/57] Fetching openssh-portable-8.1.p1,1.txz: .......... done
[40/57] Fetching openldap-sasl-client-2.4.48.txz: .......... done
[41/57] Fetching ntp-4.2.8p13_6.txz: .......... done
[42/57] Fetching mpd5-5.8_10.txz: .......... done
[43/57] Fetching monit-5.26.0.txz: .......... done
[44/57] Fetching lighttpd-1.4.54.txz: .......... done
[45/57] Fetching liblz4-1.9.2_1,1.txz: .......... done
[46/57] Fetching libevent-2.1.11.txz: .......... done
[47/57] Fetching libedit-3.1.20191211,1.txz: .......... done
[48/57] Fetching ldns-1.7.1_1.txz: .......... done
[49/57] Fetching krb5-1.17.1.txz: .......... done
[50/57] Fetching isc-dhcp44-server-4.4.2.txz: .......... done
[51/57] Fetching isc-dhcp44-relay-4.4.2.txz: .......... done
[52/57] Fetching hostapd-2.9.txz: .......... done
[53/57] Fetching e2fsprogs-libuuid-1.45.5.txz: ..... done
[54/57] Fetching cyrus-sasl-2.1.27_1.txz: .......... done
[55/57] Fetching curl-7.68.0.txz: .......... done
[56/57] Fetching ca_root_nss-3.49.1.txz: .......... done
[57/57] Fetching openssl102-1.0.2u.txz: .......... done
Checking integrity... done (1 conflicting)
  - openssl102-1.0.2u conflicts with openssl-1.0.2t,1 on /usr/local/bin/c_rehash
Checking integrity... done (0 conflicting)
Conflicts with the existing packages have been found.
One more solver iteration is needed to resolve them.
The following 58 package(s) will be affected (of 0 checked):

Installed packages to be REMOVED:
openssl-1.0.2t,1

New packages to be INSTALLED:
openssl102: 1.0.2u

Installed packages to be UPGRADED:
readline: 8.0.0 -> 8.0.1
python37: 3.7.5_1 -> 3.7.6
py37-setuptools: 41.4.0 -> 44.0.0
py37-six: 1.12.0 -> 1.13.0
py37-certifi: 2019.9.11 -> 2019.11.28
php72: 7.2.25 -> 7.2.26
cyrus-sasl: 2.1.27 -> 2.1.27_1
ca_root_nss: 3.48 -> 3.49.1
py37-urllib3: 1.25.6,1 -> 1.25.7,1
py37-chardet: 3.0.4_2 -> 3.0.4_3
php72-pdo: 7.2.25 -> 7.2.26
php72-json: 7.2.25 -> 7.2.26
php72-hash: 7.2.25 -> 7.2.26
liblz4: 1.9.2,1 -> 1.9.2_1,1
libedit: 3.1.20190324,1 -> 3.1.20191211,1
e2fsprogs-libuuid: 1.45.3 -> 1.45.5
curl: 7.67.0 -> 7.68.0
unbound: 1.9.5 -> 1.9.6
sudo: 1.8.29 -> 1.8.30
strongswan: 5.8.1 -> 5.8.2_1
py37-sqlite3: 3.7.5_7 -> 3.7.6_7
php72-zlib: 7.2.25 -> 7.2.26
php72-xml: 7.2.25 -> 7.2.26
php72-sqlite3: 7.2.25 -> 7.2.26
php72-sockets: 7.2.25 -> 7.2.26
php72-simplexml: 7.2.25 -> 7.2.26
php72-session: 7.2.25 -> 7.2.26
php72-phpseclib: 2.0.21 -> 2.0.23
php72-openssl: 7.2.25 -> 7.2.26
php72-ldap: 7.2.25 -> 7.2.26
php72-gettext: 7.2.25 -> 7.2.26
php72-filter: 7.2.25 -> 7.2.26
php72-dom: 7.2.25 -> 7.2.26
php72-curl: 7.2.25 -> 7.2.26
php72-ctype: 7.2.25 -> 7.2.26
pftop: 0.7_8 -> 0.7_9
openssh-portable: 8.0.p1_1,1 -> 8.1.p1,1
isc-dhcp44-server: 4.4.1_4 -> 4.4.2
isc-dhcp44-relay: 4.4.1 -> 4.4.2
os-dyndns: 1.18 -> 1.18_1
opnsense: 19.7.8 -> 19.7.10_1

Installed packages to be REINSTALLED:
py37-cryptography-2.6.1 (direct dependency changed: openssl102)
openldap-sasl-client-2.4.48 (direct dependency changed: cyrus-sasl)
libevent-2.1.11 (direct dependency changed: openssl102)
ldns-1.7.1_1 (direct dependency changed: openssl102)
krb5-1.17.1 (direct dependency changed: openssl102)
wpa_supplicant-2.9 (options changed)
syslog-ng324-3.24.1 (direct dependency changed: openssl102)
squid-4.9 (direct dependency changed: krb5)
opnsense-update-19.7.7 (direct dependency changed: openssl102)
openvpn-2.4.8 (direct dependency changed: openssl102)
ntp-4.2.8p13_6 (direct dependency changed: openssl102)
mpd5-5.8_10 (direct dependency changed: openssl102)
monit-5.26.0 (direct dependency changed: openssl102)
lighttpd-1.4.54 (direct dependency changed: openssl102)
hostapd-2.9 (direct dependency changed: openssl102)

Number of packages to be removed: 1
Number of packages to be installed: 1
Number of packages to be upgraded: 41
Number of packages to be reinstalled: 15
[1/58] Upgrading readline from 8.0.0 to 8.0.1...
[1/58] Extracting readline-8.0.1: .......... done
[2/58] Upgrading php72 from 7.2.25 to 7.2.26...
[2/58] Extracting php72-7.2.26: .......... done
[3/58] Upgrading ca_root_nss from 3.48 to 3.49.1...
[3/58] Extracting ca_root_nss-3.49.1: ...... done
[4/58] Upgrading php72-pdo from 7.2.25 to 7.2.26...
[4/58] Extracting php72-pdo-7.2.26: .......... done
[5/58] Upgrading php72-json from 7.2.25 to 7.2.26...
[5/58] Extracting php72-json-7.2.26: .......... done
[6/58] Upgrading php72-hash from 7.2.25 to 7.2.26...
[6/58] Extracting php72-hash-7.2.26: .......... done
[7/58] Upgrading sudo from 1.8.29 to 1.8.30...
[7/58] Extracting sudo-1.8.30: ......... done
[8/58] Upgrading php72-zlib from 7.2.25 to 7.2.26...
[8/58] Extracting php72-zlib-7.2.26: ....... done
[9/58] Upgrading php72-xml from 7.2.25 to 7.2.26...
[9/58] Extracting php72-xml-7.2.26: ........ done
[10/58] Upgrading php72-sqlite3 from 7.2.25 to 7.2.26...
[10/58] Extracting php72-sqlite3-7.2.26: ........ done
[11/58] Upgrading php72-sockets from 7.2.25 to 7.2.26...
[11/58] Extracting php72-sockets-7.2.26: .......... done
[12/58] Upgrading php72-simplexml from 7.2.25 to 7.2.26...
[12/58] Extracting php72-simplexml-7.2.26: ......... done
[13/58] Upgrading php72-session from 7.2.25 to 7.2.26...
[13/58] Extracting php72-session-7.2.26: .......... done
[14/58] Upgrading php72-phpseclib from 2.0.21 to 2.0.23...
[14/58] Extracting php72-phpseclib-2.0.23: ........ done
[15/58] Upgrading php72-gettext from 7.2.25 to 7.2.26...
[15/58] Extracting php72-gettext-7.2.26: ....... done
[16/58] Upgrading php72-filter from 7.2.25 to 7.2.26...
[16/58] Extracting php72-filter-7.2.26: ........ done
[17/58] Upgrading php72-dom from 7.2.25 to 7.2.26...
[17/58] Extracting php72-dom-7.2.26: .......... done
[18/58] Upgrading php72-ctype from 7.2.25 to 7.2.26...
[18/58] Extracting php72-ctype-7.2.26: ....... done
[19/58] Upgrading pftop from 0.7_8 to 0.7_9...
[19/58] Extracting pftop-0.7_9: ..... done
[20/58] Upgrading isc-dhcp44-relay from 4.4.1 to 4.4.2...
[20/58] Extracting isc-dhcp44-relay-4.4.2: ....... done
[21/58] Deinstalling openssl-1.0.2t,1...
[21/58] Deleting files for openssl-1.0.2t,1: .......... done
[22/58] Upgrading liblz4 from 1.9.2,1 to 1.9.2_1,1...
[22/58] Extracting liblz4-1.9.2_1,1: .......... done
[23/58] Upgrading e2fsprogs-libuuid from 1.45.3 to 1.45.5...
[23/58] Extracting e2fsprogs-libuuid-1.45.5: .......... done
[24/58] Installing openssl102-1.0.2u...
[24/58] Extracting openssl102-1.0.2u: .......... done
[25/58] Upgrading cyrus-sasl from 2.1.27 to 2.1.27_1...
*** Added group `cyrus' (id 60)
*** Added user `cyrus' (id 60)
[25/58] Extracting cyrus-sasl-2.1.27_1: .......... done
[26/58] Upgrading python37 from 3.7.5_1 to 3.7.6...
pkg-static: sqlite error while executing iterator in file pkgdb_iterator.c:1080: database disk image is malformed
pkg-static: sqlite error while executing INSERT OR REPLACE INTO files (path, sha256, package_id) VALUES (?1, ?2, ?3) in file pkgdb.c:1832: database disk image is malformed
Starting web GUI...done.
Generating RRD graphs...done.
***DONE***

Title: Re: Upgrade failed (pkg-static: sqlite error: database disk image is malformed)
Post by: mapsware on February 14, 2020, 09:39:37 pm
Reading this other post

I did over ten updates 19.7 -> 19.7.10 just this week for QA purposes and I haven't been running into issues.

Do an upgrade from the console, Option 12. We need an error message to diagnose this.


Cheers,
Franco

This it the output from console (still the same errors)

Code: [Select]
Fetching change log information, please wait... done

This will automatically fetch all available updates, apply them,
and reboot if necessary.

Proceed with this action? [y/N]: y

Updating OPNsense repository catalogue...
OPNsense repository is up to date.
All repositories are up to date.
Updating OPNsense repository catalogue...
OPNsense repository is up to date.
All repositories are up to date.
Checking for upgrades (33 candidates): .......... done
Processing candidates (33 candidates):
pkg-static: python37 has a missing dependency: openssl
Processing candidates (33 candidates)...pkg-static:
libevent has a missing dependency: openssl
Processing candidates (33 candidates)...pkg-static:
curl has a missing dependency: openssl
Processing candidates (33 candidates)....pkg-static:
krb5 has a missing dependency: openssl
pkg-static: openldap-sasl-client has a missing dependency: openssl
Processing candidates (33 candidates)........pkg-static:
ldns has a missing dependency: openssl
Processing candidates (33 candidates)....... done
Checking integrity... done (0 conflicting)
The following 33 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
unbound: 1.9.5 -> 1.9.6
strongswan: 5.8.1 -> 5.8.2_1
python37: 3.7.5_1 -> 3.7.6
py37-urllib3: 1.25.6,1 -> 1.25.7,1
py37-sqlite3: 3.7.5_7 -> 3.7.6_7
py37-six: 1.12.0 -> 1.13.0
py37-setuptools: 41.4.0 -> 44.0.0
py37-chardet: 3.0.4_2 -> 3.0.4_3
py37-certifi: 2019.9.11 -> 2019.11.28
php72-openssl: 7.2.25 -> 7.2.26
php72-ldap: 7.2.25 -> 7.2.26
php72-curl: 7.2.25 -> 7.2.26
os-dyndns: 1.18 -> 1.18_1
opnsense: 19.7.8 -> 19.7.10_1
openssh-portable: 8.0.p1_1,1 -> 8.1.p1,1
libedit: 3.1.20190324,1 -> 3.1.20191211,1
isc-dhcp44-server: 4.4.1_4 -> 4.4.2
curl: 7.67.0 -> 7.68.0

Installed packages to be REINSTALLED:
wpa_supplicant-2.9 (options changed)
syslog-ng324-3.24.1 (direct dependency changed: openssl102)
squid-4.9 (direct dependency changed: krb5)
py37-cryptography-2.6.1 (direct dependency changed: openssl102)
opnsense-update-19.7.7 (direct dependency changed: openssl102)
openvpn-2.4.8 (direct dependency changed: openssl102)
openldap-sasl-client-2.4.48 (direct dependency changed: cyrus-sasl)
ntp-4.2.8p13_6 (direct dependency changed: openssl102)
mpd5-5.8_10 (direct dependency changed: openssl102)
monit-5.26.0 (direct dependency changed: openssl102)
lighttpd-1.4.54 (direct dependency changed: openssl102)
libevent-2.1.11 (direct dependency changed: openssl102)
ldns-1.7.1_1 (direct dependency changed: openssl102)
krb5-1.17.1 (direct dependency changed: openssl102)
hostapd-2.9 (direct dependency changed: openssl102)

Number of packages to be upgraded: 18
Number of packages to be reinstalled: 15
[1/33] Upgrading python37 from 3.7.5_1 to 3.7.6...
pkg-static: sqlite error while executing iterator in file pkgdb_iterator.c:1080: database disk image is malformed
pkg-static: sqlite error while executing INSERT OR REPLACE INTO files (path, sha256, package_id) VALUES (?1, ?2, ?3) in file pkgdb.c:1832: database disk image is malformed
A firmware update is currently in progress.
Title: Upgrade failed (pkg-static: sqlite error: database disk image is malformed)
Post by: mapsware on February 14, 2020, 11:15:49 pm
Analyzing the error message, I see that it is sent by the "pkg" system, indicating that there is an problem with the sqlite database (malformed)

pkg-static: sqlite error while executing iterator in file pkgdb_iterator.c:1080: database disk image is malformed

I backup and proceed to verify the database of the system "pkg", this indicates that there are rows that are not in the index, so I re-index it and check again to verifying that there are no errors

Code: [Select]
root@OPNsense# cp /var/db/pkg/local.sqlite  ./local.sqlite.backup
root@OPNsense# sqlite3 /var/db/pkg/local.sqlite
SQLite version 3.30.1 2019-10-10 20:19:45
Enter ".help" for usage hints.
sqlite> .selftest
Missing SELFTEST table - default checks only
1: Expected: [ok]
1:      Got: [*** in database main ***
Multiple uses for byte 3681 of page 1482|row 3380 missing from index sqlite_autoindex_files_1|row 7439 missing from index sqlite_autoindex_files_1|row 7440 missing from index sqlite_autoindex_files_1|row 7441 missing from index sqlite_autoindex_files_1|row 15880 missing from index files_package_id|row 15880 missing from index sqlite_autoindex_files_1]
1 errors out of 1 tests
sqlite> REINDEX;
sqlite> .selftest
Missing SELFTEST table - default checks only
0 errors out of 1 tests
sqlite> .quit
root@OPNsense#

After that, I could update up to 20.1.1-i386