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

Đang mở
#193 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@NicklasBlidmo đang làm issue này rồi.

Từ ngày 26/10/2026.

  • #194 của @NicklasBlidmo — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
52/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, postgresql, python
Lĩnh vực
backend, databases

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
55
Fork
25
Merge trung bình
3 ngày 22 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của MerginMaps/db-sync

Tất cả issue của MerginMaps/db-sync

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.