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

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

Maintainer thường phản hồi trong vòng 10 ngày

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

Từ ngày 4/11/2026.

Đá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
38/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go

Hướng nghiên cứu

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.

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

Mô tả

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.

Ngôn ngữ chính
Go
Star
21.8k
Fork
1.6k
Merge trung bình
11 ngày 7 giờ
Pull request đã merge (30 ngày)
5

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 dgraph-io/dgraph

Tất cả issue của dgraph-io/dgraph

Issue tương tự

Thêm issue về Go

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.