fix(restore): max uid lease ignores uids that only appear as edge targets

オープン
#9,870 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

2026年11月4日 から。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go

調査の方向性

Start at processKV in worker/restore_map.go (around line 339), where maxUid is taken from the parsed key, and trace how the map phase writes its output and where the uid lease is bumped after restore. The gap is that uids inside uid-edge posting list values are never decoded, so a fix means decoding those values and folding them into maxUid; the alternative manifest approach is described in the issue. Done means a restore lease covers a node that appears only as an edge target, verified against the example <0x1> <friend> _:new . case. Note the author has not reproduced it end to end, so confirm the behaviour before changing it.

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

説明

area/backup kind/bug

Description

After a restore, Zero's uid lease is bumped to the max uid the restore map phase saw. That max only covers uids that appear in keys, so a node that exists only as the target of a uid edge isn't counted. Zero can then hand that uid to a new node, and the new node silently inherits the restored incoming edges.

This affects both the online /admin restore and dgraph restore -z (once #9869 lands, since before that the offline path didn't bump the uid lease at all).

Root cause

In the map phase, processKV takes the max uid from the parsed key:

https://github.com/dgraph-io/dgraph/blob/1714bf3c3c038656fd7802b9571cb708dffa528e/worker/restore_map.go#L339

The object uids inside uid-edge posting lists are never looked at. A uid only shows up in a key if the node has at least one outgoing predicate, or if the incoming edge's predicate has @reverse.

Example

<0x1> <friend> _:new .

If _:new gets no predicates of its own and friend has no @reverse, its uid lives only in the posting list value of <0x1> <friend>. The newest node usually holds the highest uid, so this isn't a rare corner case. After restoring a backup taken at this point, the lease ends up below _:new's uid, and the next blank node assigned that uid picks up the friend edge from 0x1. Nothing reports an error.

I found this by reading the code while reviewing #9869 and haven't reproduced it end to end yet.

Possible fix

Decode uid posting values in the map phase and fold their uids into maxUid. That adds work proportional to the number of uid edges in the backup. A cheaper option would be to record Zero's max leased uid in the backup manifest when the backup is taken and bump to that on restore, but older backups wouldn't have it.

主要言語
Go
スター
21.8k
フォーク
1.6k
平均マージ
11日 7時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

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

dgraph-io/dgraph のほかの issue

dgraph-io/dgraph の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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