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

Aperta
#9,870 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 10 giorni

@aliassar ci sta già lavorando.

Dal 4/11/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
21.8k
Fork
1.6k
Merge medio
11g 7h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dgraph-io/dgraph

Tutte le issue di dgraph-io/dgraph

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.