Finalize archives into a compact file at the final path

オープン
#382 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@ArpitaSamanta10 がすでに取り組んでいます。

2026年11月19日 から。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, sqlite
領域
database

調査の方向性

Start with Archive and ArchiveManifest in morango/sync/archive.py, then read spec §3.5 and the implementation plan's Task 21. Run the relevant tests in tests/testapp/tests/sync/test_archive.py, including the Windows-marked rename test. Done means finalize records completed_at, reclaims space, removes temporary state and the alias, renames the partial file, and leaves discard harmless afterward.

索引モデルが issue の本文から書いたものです。

説明

DEV: backend P0 - critical TAG: new feature

Overview

A completed archive becomes a compact file at its final path, and all temporary files and locks are removed. This issue is part of milestone M5 (archive).

Background & Motivation

During export, morango writes the archive to <path>.partial. The final path must exist only when the export completed. A reader can then trust that a file at the final path is a complete archive.

The dequeue step moves rows from Buffer to Store in the archive. This leaves free pages in the file. VACUUM reclaims them, but it needs up to twice the file size in free space. The target disk does not always have this space. The archive uses incremental auto-vacuum instead, which reclaims pages in place.

Design: spec. Plan: implementation plan, Task 21.

Description & Expected Outcomes

The archive keeps its manifest as a typed value. A write of a new manifest replaces all manifest entries.

When the archive is finalized, the archive records completed_at in the manifest and reclaims free pages. Then the archive closes its connection and removes the archive alias. It renames <path>.partial to <path> and releases the archive lock.

After finalization, a call to discard does nothing. The final file stays in place.

Deliverables & Contracts

The feature delivers these capabilities:

  • Archive.write_manifest(manifest) replaces all manifest entries.
  • Archive.manifest returns the current manifest value.
  • Archive.finalize() produces the final file and cleans up all temporary state.
Acceptance Criteria
  • After finalize, path exists, and <path>.partial, <path>.partial-journal and <path>.lock do not exist.
  • After finalize, the archive alias is not in connections.databases, and finalized is True.
  • A reopened archive shows completed_at set, and all other manifest fields are unchanged.
  • If 5,000 buffer rows are inserted and deleted before finalize, the final file is smaller than the partial file before finalize.
  • A call to discard after finalize does not change or delete the final file.
  • The rename test passes in the windows tox environment.

Technical Pointers & Architecture

  • Target Components / Context: morango/sync/archive.py (Archive, ArchiveManifest).
  • Related Patterns: Spec §3.5 describes the finalize sequence.
  • Data Model & Schema Considerations: Uses ArchiveManifestEntry rows from #376. No new schema.
  • Resilience & Failure Modes: If finalization fails, the export fails. The caller calls close(), which discards the partial file. There is no resume before Phase 3.

Notes & Tradeoffs

  • Dependencies: Blocked by: #377 (ArchiveManifest value object), #378 (Archive.create and discard), #379 (archive lock). Blocks: #383.
  • Testing Requirements: Unit tests in tests/testapp/tests/sync/test_archive.py. Mark the rename test with @pytest.mark.windows.
  • Tradeoffs & Alternatives Considered: The spec rejects VACUUM at finalize because of its free-space cost.
  • Compatibility & Migrations: auto_vacuum=INCREMENTAL is set when the archive is created, before any table exists (#378).

Metadata

  • Complexity: Medium
  • Target Branch: release-v0.9.x

AI Usage

Drafted with Claude (Claude Code) from the approved design spec and implementation plan. The author reviewed the requirements, and the code references were checked against the release-v0.9.x codebase.

主要言語
Python
スター
15
フォーク
27
平均マージ
6日 44分
マージ済み PR(30日)
13

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

learningequality/morango のほかの issue

learningequality/morango の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。