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

Aberta
#193 0 comentários 0 reações 0 responsáveis Ver no GitHub

@NicklasBlidmo já está trabalhando nisso.

Desde 26/10/2026.

  • #194 de @NicklasBlidmo — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
52/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
docker, postgresql, python
Domínio
backend, databases

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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).

Linguagem predominante
Python
Estrelas
55
Forks
25
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de MerginMaps/db-sync

Todas as issues de MerginMaps/db-sync

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.