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

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

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

まだ誰も着手していません。

評価

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

調査の方向性

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.

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

説明

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.

主要言語
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 を短くまとめたダイジェスト。