Skip to content

Fix/leveldb transaction - #40

Merged
Yu-da-1 merged 2 commits into
feature/add-convergence-layerfrom
fix/leveldb-transaction
Nov 17, 2025
Merged

Yu-da-1 merged 2 commits into
feature/add-convergence-layerfrom
fix/leveldb-transaction

Conversation

@Yu-da-1

@Yu-da-1 Yu-da-1 commented Nov 9, 2025

Copy link
Copy Markdown
Member

Description

以前報告された「dag.add_child_node と state.apply の片方だけが成功すると整合性が崩れる」問題(コメント)に対処し、Repo の操作を「全成功か全失敗か」の一貫性で永続化できるようにした。

  • SharedLeveldb を導入し、書き込みを単一 LevelDB の WriteBatch でまとめて扱うように変更
  • LeveldbStorage / LeveldbNodeStorage がアクティブなバッチを検知してバッチ経由で書き込み、バッチが無い場合は従来通り直接書き込むようリファクタリング
    • 通常通りの書き込みはテスト用として残してある。実際開発者が使うことは不可能である
  • DagGraph にノード準備・登録・ロールバックのヘルパーを追加し、Repo 側でトランザクション前提のフローを構成可能に
  • Repo::commit_operation を段階的なステージング+一括コミットに再設計し、旧ロールバック処理を整理
  • CLI・サンプル・README を単一 store/ ディレクトリと SharedLeveldb 利用前提に更新
  • SharedLeveldb のバッチ挙動、DagGraph のロールバック、Repo のトランザクションパスを検証するテストを追加

Notes & open questions

@Yu-da-1
Yu-da-1 changed the base branch from main to feature/add-convergence-layer November 9, 2025 14:03
@Yu-da-1
Yu-da-1 marked this pull request as ready for review November 9, 2025 14:10
@Yu-da-1
Yu-da-1 requested a review from somasekimoto November 9, 2025 14:10
Comment thread src/repo.rs

#[test]
fn test_create_operation_rolls_back_on_state_failure() {
let dir = tempdir().unwrap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[should]
commit_operationのテストもっとほしいですね。
もっと別パターンのテストも書いておいた方が良いと思います。

  • それぞれ(4種類)のOperationTypeで失敗
  • state.apply失敗
  • batch_guard.commit の失敗

少なくともこの6ケースはあった方が良いかと。簡単にでも良いので

Comment thread src/repo.rs
repo.state.get_operation(&op_id).unwrap().is_none(),
"operation was persisted despite failure"
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ask]
rollback_pending_nodesのテストってないですよね?作った方が良い気がします。

@Yu-da-1
Yu-da-1 merged commit 6b84c17 into feature/add-convergence-layer Nov 17, 2025
4 checks passed
@Yu-da-1
Yu-da-1 deleted the fix/leveldb-transaction branch November 17, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants