SIGTERM kills db-sync mid-pull; proposal: finish the current connection and exit between cycles

Ouverte
#193 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

@NicklasBlidmo y travaille déjà.

Depuis le 26/10/2026.

  • #194 par @NicklasBlidmo — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
52/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Active
Stack technique
docker, postgresql, python
Domaine
backend, databases

Piste de recherche

Start by reading dbsync_daemon.py and tracing dbsync_pull(), dbsync_push(), and run_daemon() to understand the cycle boundaries described in the issue. Implement the proposed SIGTERM shutdown behavior, then verify that a started pull or push can finish before the process exits and that SIGINT retains its default behavior.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

dbsync_daemon.py installs no SIGTERM handler, so a docker stop,
docker compose up -d after a rebuild, or a service manager restart ends
the process wherever it happens to be. If that is inside pull() between
"GeoPackage updated" (the checkout is at the new version) and "base
schema updated" (the changeset has been applied to the database), the
checkout and the base schema are at the same version with different
content, and the next start refuses with

The db schemas already exist but 'base' schema is not synchronized with source GPKG. Running `dbsync_deamon.py` with `--force-init` should fix the issue.

--force-init then drops and rebuilds the schemas, which loses any
not-yet-pushed database edits and any views or grants on the schemas.
We hit this in production with four projects and a routine image
rebuild (one daemon was pulling 48 files at that moment).

Proposal, implemented in the PR that follows: a SIGTERM handler that only
sets a flag; dbsync_pull()/dbsync_push() check it before each
connection; run_daemon() checks it at the top of the cycle and between
pull and push; the sleep polls it once a second. A pull or push that has
started always completes; the process exits 0 at the next boundary.
SIGINT keeps its default so ctrl+c still kills immediately. A container
needs stop_grace_period long enough for one connection's pull
(we use 150 s).

Langage dominant
Python
Étoiles
55
Forks
25
Merge moyen
3 j 22 h
PR mergées (30 j)
1

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de MerginMaps/db-sync

Toutes les issues de MerginMaps/db-sync

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.