A delete in a later mutation of a transaction is lost on @count uid predicates (the earlier set is committed)

Abierto
#9,896 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 10 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
databases

Línea de trabajo

Start in posting/list.go at MutableLayer.insertPosting, where a DEL of the transaction's own pending SET removes it and leaves an empty layer, then read LocalCache.UpdateDeltasAndDiscardLists in posting/lists.go, which skips storing empty deltas. Reproduce with two AddMutationWithIndex calls on a [uid] @count @reverse predicate, with txn.Update() between them, then CommitToDisk. Done when the forward, reverse and count lists are all empty after commit.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Version: v25.5.1 and main e95fc2652.

Repro: schema knows: [uid] @reverse @count .; nodes 0x1, 0x2.

  1. POST /mutate (no commitNow): { set { <0x1> <knows> <0x2> . } }; note start_ts.
  2. POST /mutate?startTs=<start_ts>: { delete { <0x1> <knows> <0x2> . } }.
  3. POST /commit?startTs=<start_ts> with the keys and preds.
  4. { q(func: uid(0x1)) { knows { uid } count(knows) } } returns knows: [0x2], count 1; ~knows of 0x2 holds
    0x1. Expected: no edge. The same two operations in one mutation, or without @count, leave nothing.

Cause: for a count-indexed list, MutableLayer.insertPosting (posting/list.go) handles a DEL of the
transaction's own pending SET by removing the SET from currentEntries (no DEL posting is added, to keep counts
right). The layer is then empty and marshals to zero bytes. LocalCache.UpdateDeltasAndDiscardLists
(posting/lists.go) stores a list's delta only if len(data) > 0, so the delta written after the first mutation (the
SET) is kept and committed by CommitToDisk. The reverse list takes the same path.

Fix: when the transaction's mutation layer for the list exists and is empty, delete the stored delta:

if len(data) > 0 {
    lc.deltas[key] = data
} else if pl.mutationEmptied(lc.startTs) { // layer present, no posting left
    delete(lc.deltas, key)
}

with func (l *List) mutationEmptied(startTs uint64) bool { l.RLock(); defer l.RUnlock(); pl := l.mutationMap.get(startTs); return pl != nil && len(pl.Postings) == 0 }.
Test: a SET then a DEL of one uid edge as two AddMutationWithIndex calls with txn.Update() between, on
[uid] @count @reverse, then CommitToDisk: forward, reverse and count lists empty.

Lenguaje dominante
Go
Estrellas
21.8k
Forks
1.6k
Merge medio
11 d 7 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dgraph-io/dgraph

Todos los issues de dgraph-io/dgraph

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.