Updating to Pihole 5 failed

Hi, Team.
At the time of updating to Pihole 5 pihole-FTL service failed to restart.

Debug Token:

https://tricorder.pi-hole.net/w05gxaokfv

sudo mv /etc/pihole/gravity.db /etc/pihole/gravity.db_ori

sudo pihole -g -r
> [✓] Storing downloaded domains in new gravity database
>   [✓] Building tree
>   [✓] Swapping databases
>   [i] Number of gravity domains: 87262 (84821 unique domains)
>   [i] Number of exact blacklisted domains: 1
>   [i] Number of regex blacklist filters: 16
>   [i] Number of exact whitelisted domains: 4
>   [i] Number of regex whitelist filters: 0
>   [✓] Flushing DNS cache
>   [✓] Cleaning up stray matter
>   [✗] Job for pihole-FTL.service failed because a timeout was exceeded.
> See "systemctl status pihole-FTL.service" and "journalctl -xe" for details.
> 
>   [✗] DNS service is NOT running

Some data from pihole-FTL.log:

> [2020-05-23 14:56:37.461 17733] Finished config file parsing
> [2020-05-23 14:56:37.482 17733] Database version is 3
> [2020-05-23 14:56:37.483 17733] Updating long-term database to version 4
> [2020-05-23 14:56:37.567 17733] SQLite3 message: abort at 32 in [UPDATE network SET numQueries = (SELECT SUM(numQueries) FROM network WHERE hwaddr = '1') WHERE id = 6300829;]: NOT NULL constraint failed: network.numQueries (1299)
> [2020-05-23 14:56:37.567 17733] ERROR: SQL query "UPDATE network SET numQueries = (SELECT SUM(numQueries) FROM network WHERE hwaddr = '1') WHERE id = 6300829;" failed: constraint failed
> [2020-05-23 14:56:37.567 17733] Encountered error while trying to close database: database is locked
> [2020-05-23 14:56:37.567 17733] dbquery("DELETE FROM network WHERE hwaddr = '1' AND id != 6300829;") called but database is not available!
> [2020-05-23 14:56:37.568 17733] dbquery("UPDATE network SET firstSeen = (SELECT MIN(firstSeen) FROM network WHERE hwaddr = '1') WHERE id = 6300830;") called but database is not available!
> [2020-05-23 14:56:37.568 17733] dbquery("UPDATE network SET numQueries = (SELECT SUM(numQueries) FROM network WHERE hwaddr = '1') WHERE id = 6300830;") called but database is not available!
> [2020-05-23 14:56:37.568 17733] dbquery("DELETE FROM network WHERE hwaddr = '1' AND id != 6300830;") called but database is not available!
> [2020-05-23 14:56:37.568 17733] dbquery("UPDATE network SET firstSeen = (SELECT MIN(firstSeen) FROM network WHERE hwaddr = '1') WHERE id = 6300830;") called but database is not available!
> [2020-05-23 14:56:37.568 17733] dbquery("UPDATE network SET numQueries = (SELECT SUM(numQueries) FROM network WHERE hwaddr = '1') WHERE id = 6300830;") called but database is not available!

What is the output of the following command from the Pi terminal:

ls -lha /etc/pihole

pi@80ov-rasp:~ $ ls -lha /etc/pihole

total 357M
drwxrwxr-x   3 pihole pihole 4.0K May 23 14:56 .
drwxr-xr-x 104 root   root   4.0K May 23 09:48 ..
-rw-r--r--   1 root   root   2.9K Feb  5  2019 adlists.list.old
-rw-r--r--   1 root   root     27 May 23 09:24 black.list
-rw-r--r--   1 pihole pihole    0 May 23 14:56 dhcp.leases
-rw-r--r--   1 root   root    596 May 23 09:48 dns-servers.conf
-rw-r--r--   1 root   root      7 Feb 26  2019 ftlbranch
-rw-r--r--   1 root   root     14 May 23 12:21 GitHubVersions
-rw-rw-r--   1 pihole pihole 5.0M May 23 14:56 gravity.db
-rw-rw-r--   1 pihole pihole 5.0M May 23 10:06 gravity.db_ori
-rw-r--r--   1 root   root   1.9M May 23 09:24 gravity.list
-rw-r--r--   1 root   root   1.1K May 23 09:48 install.log
-rw-r--r--   1 root   root   1.1M May 23 14:56 list.0.raw.githubusercontent.com.domains
-rw-------   1 root   root   581K May 22 23:56 list.1.mirror1.malwaredomains.com.domains
-rw-------   1 root   root   624K Feb 29 00:15 list.2.sysctl.org.domains
-rw-r--r--   1 root   root      0 May 23 14:56 list.3.zeustracker.abuse.ch.domains
-rw-------   1 root   root    613 Feb 29 00:15 list.4.s3.amazonaws.com.domains
-rw-------   1 root   root    43K Feb 29 00:15 list.5.s3.amazonaws.com.domains
-rw-r--r--   1 root   root   1.9M May 23 09:24 list.preEventHorizon
-rw-r--r--   1 root   root     20 May 23 21:20 localbranches
-rw-r--r--   1 root   root     46 May 23 14:56 local.list
-rw-r--r--   1 root   root     37 May 23 21:20 localversions
-rw-r--r--   1 root   root    234 May 23 09:48 logrotate
-rw-r--r--   1 pihole pihole 2.4M May 23 09:26 macvendor.db
drwxr-xr-x   2 root   root   4.0K May 23 14:56 migration_backup
-rw-r--r--   1 root   root    384 Mar  4  2019 mmotti-regex.list
-rw-rw-r--   1 pihole pihole   15 May 23 09:48 pihole-FTL.conf
-rw-r--r--   1 pihole pihole 339M May 23 14:56 pihole-FTL.db
-rw-r--r--   1 root   root      1 Mar  4  2019 regex.list.bak
-rw-r--r--   1 root   root    420 May 23 09:48 setupVars.conf
-rw-r--r--   1 root   root    420 May 23 09:48 setupVars.conf.update.bak

This points to an error in the pihole-FTL database, since that is where the network information is stored.

Try these steps to resolve - all reversible.

sudo service pihole-FTL stop

sudo mv /etc/pihole/pihole-FTL.db /etc/pihole/pihole-FTL-old.db

sudo service pihole-FTL start

pi@80ov-rasp:~ $ systemctl status pihole-FTL.service
● pihole-FTL.service - LSB: pihole-FTL daemon
Loaded: loaded (/etc/init.d/pihole-FTL; generated; vendor pres Active: active (exited) since Sat 2020-05-23 22:33:59 +05; 32s Docs: man:systemd-sysv-generator(8)
Process: 27378 ExecStart=/etc/init.d/pihole-FTL start

Bug fixed. Pihole works, thanks. The case can be closed.