Error connecting to database /etc/pihole/gravity.db: Unable to open database: unable to open database file

Pihole v6 beta, on Proxmox Debian 10 as a container

Right after running "pihole - up" ()pdated all 3 FTL web and Core)
I got errors "Error connecting to database /etc/pihole/gravity.db: Unable to open database: unable to open database file"

I tried the following

pihole -g

Error: in prepare, no such table: info
[i] Neutrino emissions detected...
[i] Storing gravity database in /etc/pihole/gravity.db
[✓] Pulling blocklist source list into range
[i] No source list found, or it is empty

[✓] Preparing new gravity database
[i] Creating new gravity databases...
[✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
[✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.

pihole -r


[i] Repair option selected
  [i] Performing reconfiguration, skipping download of local repos
  [✓] Resetting repository within /etc/.pihole...
  [✓] Resetting repository within /var/www/html/admin...
  [i] Checking for / installing Required dependencies for Pi-hole software...
  [✓] Checking for cron
  [✓] Checking for curl
  [✓] Checking for iputils-ping
  [✓] Checking for psmisc
  [✓] Checking for sudo
  [✓] Checking for unzip
  [✓] Checking for libcap2-bin
  [✓] Checking for dns-root-data
  [✓] Checking for libcap2
  [✓] Checking for netcat-openbsd
  [✓] Checking for procps
  [✓] Checking for jq
  [✓] Checking for lshw
  [✓] Checking for bash-completion

  [✓] Checking for user 'pihole'

  [i] FTL Checks...

  [✓] Detected x86_64 architecture
  [i] Checksum of installed binary matches remote. No need to download!
  [✓] Installing scripts from /etc/.pihole

  [i] Installing configs from /etc/.pihole...

  [✓] Installing latest Cron script

  [i] Installing latest logrotate script...
        [i] Existing logrotate file found. No changes made.
  [✓] man pages installed and database updated
  [i] Testing if systemd-resolved is enabled
  [i] Systemd-resolved does not need to be restarted
Error: in prepare, no such table: info
  [i] Restarting services...
  [✓] Enabling pihole-FTL service to start on reboot...
  [✓] Restarting pihole-FTL service...
Error: in prepare, no such table: info
  [✓] Deleting existing list cache
  [i] Neutrino emissions detected...
  [i] Storing gravity database in /etc/pihole/gravity.db
  [✓] Pulling blocklist source list into range
  [i] No source list found, or it is empty


  [✓] Preparing new gravity database
  [i] Creating new gravity databases...
  [✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
  Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
   [✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.

ls -lh /etc/pihole groups pihole

ls: cannot access 'groups': No such file or directory
ls: cannot access 'pihole': No such file or directory
/etc/pihole:
total 14M
-rw-rw---- 1 pihole pihole   65 Mar  6 19:11 adlists.list
-rw-rw---- 1 pihole pihole   65 Feb  1 00:35 adlists.list.old
drwxr-xr-x 2 pihole pihole 4.0K Mar  6 19:02 config_backups
-rw-rw---- 1 pihole pihole    0 Feb  1 00:16 custom.list.bck
-rw-rw---- 1 pihole pihole    0 Feb  1 00:16 dhcp.leases
-rw-rw---- 1 pihole pihole  651 Mar  6 19:37 dns-servers.conf
-rw-rw---- 1 pihole pihole 5.4K Mar  6 19:02 dnsmasq.conf
-rw-rw---- 1 pihole pihole   15 Feb  1 00:24 ftlbranch
-rw-rw---- 1 pihole pihole    0 Mar  6 18:49 gravity.db
-rw-r--r-- 1 pihole pihole 100K Mar  6 19:37 gravity.db_temp
drwxr-xr-x 2 pihole pihole 4.0K Feb  1 00:35 hosts
-rw-rw---- 1 pihole pihole  408 Mar  6 19:37 install.log
-rw-rw---- 1 pihole pihole   65 Feb 22 00:30 local.list
-rw-r--r-- 1 root   root    241 Feb  1 00:16 logrotate
-rw-rw---- 1 pihole pihole 3.0M Mar  6 19:18 macvendor.db
drwxr-xr-x 2 pihole pihole 4.0K Feb  1 00:16 migration_backup
-rw-rw---- 1 pihole pihole  146 Mar  6 19:02 pihole-FTL.conf.bck
-rw-rw-r-- 1 pihole pihole 9.6M Mar  6 19:37 pihole-FTL.db
-rw-rw-r-- 1 pihole pihole  32K Mar  6 20:04 pihole-FTL.db-shm
-rw-rw-r-- 1 pihole pihole 765K Mar  6 20:04 pihole-FTL.db-wal
-rw-rw---- 1 pihole pihole  46K Mar  6 19:02 pihole.toml
-rw-rw---- 1 pihole pihole  441 Mar  6 19:02 setupVars.conf.old
-rw-rw---- 1 pihole pihole  709 Feb  1 00:35 tls.crt
-rw-rw---- 1 pihole pihole  997 Feb  1 00:35 tls.pem
-rw-rw---- 1 pihole pihole  733 Feb  1 00:35 tls_ca.crt
-rw-rw---- 1 pihole pihole  375 Mar  6 19:13 versions

root@DC:/etc/pihole# pihole -v

Core
    Version is v5.17.3-295-g0635ea74 (Latest: null)
    Branch is development-v6
    Hash is 0635ea74 (Latest: 0635ea74)
Web
    Version is v5.19-680-gf79a4046 (Latest: null)
    Branch is development-v6
    Hash is f79a4046 (Latest: f79a4046)
FTL
    Version is vDev-93d01d9 (Latest: null)
    Branch is development-v6
    Hash is 93d01d9c (Latest: 93d01d9c)

cd /etc/.pihole

git status

On branch development-v6
Your branch is up to date with 'origin/development-v6'.

nothing to commit, working tree clean

I see there is an update for Web

# pihole -v
Core
    Version is v5.17.3-295-g0635ea74 (Latest: null)
    Branch is development-v6
    Hash is 0635ea74 (Latest: 0635ea74)
Web
    Version is v5.19-680-gf79a4046 (Latest: null)
    Branch is development-v6
    Hash is f79a4046 (Latest: 00304273)
FTL
    Version is vDev-93d01d9 (Latest: null)
    Branch is development-v6
    Hash is 93d01d9c (Latest: 93d01d9c) 

#pihole -up
  [✓] Update local cache of available packages
  [✓] Checking for git
  [✓] Checking for iproute2
  [✓] Checking for dialog
  [✓] Checking for ca-certificates

  [i] Checking for updates...
  [i] Pi-hole Core:     up to date
  [i] Web Interface:    update available
  [i] Checksum of installed binary matches remote. No need to download!
  [i] FTL:              up to date
  [i] Warning: You are using FTL from a custom branch (development-v6) and might be missing future releases.

  [i] Pi-hole Web Admin files out of date, updating local repo.
  [✓] Check for existing repository in /var/www/html/admin
  [✓] Update repo in /var/www/html/admin

  [i] If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'
  [i] Local version file information updated.

and again


# pihole -g
Error: in prepare, no such table: info
  [i] Neutrino emissions detected...
  [i] Storing gravity database in /etc/pihole/gravity.db
  [✓] Pulling blocklist source list into range
  [i] No source list found, or it is empty


  [✓] Preparing new gravity database
  [i] Creating new gravity databases...
  [✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity.db_temp
  Parse error near line 11: no such table: OLD.group
Parse error near line 12: no such table: OLD.domain_audit
Parse error near line 14: no such table: OLD.domainlist
Parse error near line 15: no such table: OLD.domainlist_by_group
Parse error near line 16: no such table: OLD.domainlist_by_group
Parse error near line 18: no such table: OLD.adlist
Parse error near line 19: no such table: OLD.adlist_by_group
Parse error near line 20: no such table: OLD.adlist_by_group
Parse error near line 22: no such table: OLD.client
Parse error near line 23: no such table: OLD.client_by_group
Parse error near line 24: no such table: OLD.client_by_group
   [✗] Unable to create gravity database. Please try again later. If the problem persists, please contact support.
root@DC:~# pihole -v
Core
    Version is v5.17.3-295-g0635ea74 (Latest: null)
    Branch is development-v6
    Hash is 0635ea74 (Latest: 0635ea74)
Web
    Version is v5.19-682-g00304273 (Latest: null)
    Branch is development-v6
    Hash is 00304273 (Latest: 00304273)
FTL
    Version is vDev-93d01d9 (Latest: null)
    Branch is development-v6
    Hash is 93d01d9c (Latest: 93d01d9

This issue happened suddenly after the pihole update

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

Your gravity database is completely empty (no data, no tables, nothing).

Please, try to create a new database with pihole -g -r recreate and report the result.

Yes it is empty, that is the issue.

There was activity before the error. so something happened to the database during "pihole -up"

pihole -g should be the only command that is run after an update...

root@p6beta:~# pihole -g -r recreate
[i] Recreating gravity database from migration backup.../opt/pihole/gravity.sh: line 848: popd: /root: Permission denied
root@p6beta:~# sudo pihole -g -r recreate
[i] Recreating gravity database from migration backup...rm: cannot remove '/etc/pihole/gravity.db': No such file or directory
/opt/pihole/gravity.sh: line 848: popd: /root: Permission denied

Do I have to just scrap this pihole?