posting: rollup commits parent and split KVs in separate transactions, leaving crash windows

Abierto
#9,862 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

Línea de trabajo

Start with posting/writer.go and trace List.Rollup writes through the callers in posting/mvcc.go and posting/index.go. Check how TxnWriter.Write uses Badger transactions and how finite readTs rollups preserve distinct timestamps. Done means retained and new split parts are committed at newMinTs, while the parent and removed split tombstones are committed together at parentVersion, with historical reads preserved.

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

Descripción

Summary

List.Rollup returns the parent posting list plus its split parts as separate KVs, and TxnWriter.Write (posting/writer.go) commits each KV in its own Badger transaction. A crash between those commits can leave on-disk state that the parent doesn't agree with. This has been the case since multi-part posting lists landed (#3105). It isn't new.

Crash windows

The KVs are sorted by key, so the parent (DefaultPrefix) is written before any split key (ByteSplit). Badger replays a strict prefix after a crash, so the parent can survive without the KVs that follow it.

  1. Parent written, new split part not written. The parent at newMinTs+1 references a part with a new startUid that has no version yet. readListPart does a txn.Get at the parent's version, gets key-not-found, and reads of that list fail. This is the more serious case.
  2. Parent written, removed-split tombstones not written. With #9825, rollup writes BitEmptyPosting tombstones for splits the parent no longer references. If the crash lands before those commit, the old split payload stays the latest value for its key. The new parent doesn't list it, so no later rollup will rediscover it and the space leaks indefinitely (same outcome as #9824, but only on a crash).

Proposed fix

Group the rollup's writes by version instead of committing per KV:

  • Write retained/new split parts at newMinTs first. They're invisible to readers still resolving the old parent, so this is safe on its own.
  • Then commit the parent and all removed-split tombstones in a single transaction at parentVersion (they already share that version).

Keep the distinct timestamps for finite readTs rollups. Collapsing everything to one version would break historical reads at newMinTs.

This needs a TxnWriter API (or a rollup-specific writer) that can commit several KVs in one CommitAt, plus updating the callers in posting/mvcc.go and posting/index.go.

References

  • #9825 (CodeRabbit raised the tombstone case in review)
  • #9824
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.