anatol / pacoloco

Caching proxy server for Arch Linux pacman
MIT License
199 stars 30 forks source link

exits with "no such table" #64

Closed HarHarLinks closed 1 year ago

HarHarLinks commented 1 year ago

i'm running with docker compose.

tonight at the scheduled prefetch time, pacoloco exited with code 1.

this is the end of the log:

pacoloco  | prefetch.go:255: Starting prefetching routine...
pacoloco  | prefetch.go:182: Cleaning the db...
pacoloco  | prefetch.go:217: Db cleaned.
pacoloco  | prefetch.go:261: Starting prefetching packages...
pacoloco  | prefetch_db.go:196: no such table: mirror_packages
Focshole commented 1 year ago

What did your pacoloco.yaml contain? I cannot figure out what happened otherwise. I'd guess it was due to a prefetch routine with no previous packages requests ever but I don't know. Maybe that issue is due to the fact that the db had not been created this far.

HarHarLinks commented 1 year ago

pacoloco.yaml:

port: 9129
cache_dir: /var/cache/pacoloco
purge_files_after: 360000 # 360000 seconds or 100 hours, 0 to disable
download_timeout: 3600 # download will timeout after 3600 seconds
repos:
  archlinux:
    urls:
      - [snip]
      - http://mirrors.kernel.org/archlinux
  quarry:
    url: http://pkgbuild.com/~anatolik/quarry/x86_64
  sublime:
    url: https://download.sublimetext.com/arch/stable/x86_64
  herecura:
    url: https://repo.herecura.eu/herecura/x86_64
#  archlinux-reflector:
#    mirrorlist: /etc/pacman.d/reflector_mirrorlist # Be careful! Check that pacoloco URL is NOT included in that file!
# http_proxy: http://foo.company.com:8989
user_agent: Pacoloco/1.2
prefetch: # optional section, add it if you want to enable prefetching
  cron: 0 0 3 * * * * # standard cron expression (https://en.wikipedia.org/wiki/Cron#CRON_expression) to define how frequently prefetch, see https://github.com/gorhill/cronexpr#implementation for documentation.
  ttl_unaccessed_in_days: 30  # defaults to 30, set it to a higher value than the number of consecutive days you don't update your systems
  # It deletes and stop prefetch packages(and db links) when not downloaded after ttl_unaccessed_in_days days that it had been updated.
  ttl_unupdated_in_days: 300 # defaults to 300, it deletes and stop prefetch packages which hadn't been either updated upstream or requested for ttl_unupdated_in_days.

cache/sqlite-pkg-cache.db:

sqlite> .schema
CREATE TABLE `packages` (`package_name` text NOT NULL,`version` text NOT NULL,`arch` text NOT NULL,`repo_name` text NOT NULL,`last_time_downloaded` datetime NOT NULL,`last_time_repo_updated` datetime NOT NULL,PRIMARY KEY (`package_name`,`arch`,`repo_name`));
CREATE TABLE `mirror_dbs` (`url` text NOT NULL,`repo_name` text NOT NULL,`last_time_downloaded` datetime NOT NULL,PRIMARY KEY (`url`,`repo_name`));

I did previously update once through pacoloco successfully, some files exist in cache/pkgs.

Focshole commented 1 year ago

Ok, I see what happened. The prefetching routine got invoked with no saved mirrors. Could you please check that you had no entries in mirror_dbs?

Focshole commented 1 year ago

Ok, it is probably ok to fail in this situation, it shouldn't do a fatal failure. Updated to do a soft failure (aka, just end the prefetching).

HarHarLinks commented 1 year ago

Ok, I see what happened. The prefetching routine got invoked with no saved mirrors. Could you please check that you had no entries in mirror_dbs?

it's currently not empty:

sqlite> select * from mirror_dbs;
/repo/herecura/herecura.db|herecura|2023-02-25 17:24:14.52841227+01:00
/repo/archlinux/core/os/x86_64/core.db|archlinux|2023-02-25 17:29:38.402540223+01:00
/repo/archlinux/multilib/os/x86_64/multilib.db|archlinux|2023-02-25 17:29:38.422815185+01:00
/repo/archlinux/extra/os/x86_64/extra.db|archlinux|2023-02-25 17:29:38.482848738+01:00
/repo/archlinux/community/os/x86_64/community.db|archlinux|2023-02-25 17:29:38.591550906+01:00

i set the prefetch cron to just now to test with your branch plus #66 and it succeeded.

I'll reopen should I notice it failing again.