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

Đang mở
#9,896 0 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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/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
Lĩnh vực
databases

Hướng nghiên cứu

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.

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

Mô tả

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.

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.