Bulk loader: add --preserve-schema flag to error instead of auto-converting uid predicates to [uid]
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 74/100
Hướng nghiên cứu
Bắt đầu trong dgraph/cmd/bulk/reduce.go tại phần phát hiện xung đột UID hiện có và đọc dgraph/cmd/bulk/schema.go, đặc biệt là setSchemaAsList. Xem xét testBulkSingleUid trong systest/bulk_live/common/bulk_live_cases.go và thêm một phiên bản tương ứng cho strict mode. Hoàn tất khi dgraph bulk chấp nhận --preserve-schema, báo lỗi kèm predicate và subject UID đối với các xung đột scalar, đồng thời mặc định vẫn giữ nguyên hành vi cảnh báo và mở rộng hiện tại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The bulk loader silently rewrites a predicate's schema from uid to [uid] when it encounters more than one UID for a subject/predicate pair. This proposal adds a --preserve-schema flag so users can opt into strict behavior: fail the load with a clear error instead of widening the schema.
Current behavior
Given this schema:
<somepred>: uid .
and RDF like:
_:abc <somepred> _:123 .
_:abc <somepred> _:456 .
the bulk loader detects the conflict in the reduce phase, prints a warning, and forces the schema to [uid]:
https://github.com/dgraph-io/dgraph/blob/main/dgraph/cmd/bulk/reduce.go#L876-L891
This behavior is deliberate. It came from #3659, which fixed a data-loss bug: before that change, extra UIDs on a scalar uid predicate were silently dropped. Forcing the schema to a list was the conservative choice (keep all the data, let the user sort it out once the cluster is up). The problem is there's no way to opt out. Users who treat their schema file as the source of truth only discover the rewrite after the load completes, and the warning names the predicate but is easy to miss in bulk loader output.
Note this is a bulk-loader-only behavior. The live loader never modifies an existing schema; with <somepred>: uid already defined, live-loaded mutations follow scalar semantics (last write wins).
Proposal
Add a --preserve-schema flag to dgraph bulk (default false, preserving current behavior):
-
--preserve-schema=false(default): current behavior. Warn and widen the predicate to a list. -
--preserve-schema=true: the schema file is authoritative. When the reducer finds more than one UID for a scalaruidpredicate, fail the load with an error naming the predicate and the subject UID, e.g.:predicate <somepred> is defined as uid (not a list), but subject 0x2 has 2 values; rerun without --preserve-schema to widen the schema to [uid], or fix the input data
Implementation should be small: the detection already exists in reduce.go, and setSchemaAsList in dgraph/cmd/bulk/schema.go is only called from that one site. The strict path just returns an error instead.
Scope notes
- The check runs in the reduce phase over merged posting lists, so the original RDF line is no longer available. We can report the predicate and subject UID, but per-line attribution would require map-phase tracking across shards. I'd keep that out of scope for the first pass.
- The original request also floated a "keep the scalar schema and last-write-wins" mode. I'd skip that too: which value wins is nondeterministic in a map/reduce load, so it's a footgun. Error-or-widen covers the real use cases.
testBulkSingleUidin systest/bulk_live/common/bulk_live_cases.go locks in the current force-to-list behavior and should gain a strict-mode counterpart.
References
- Original fix that introduced the auto-widening: #3659
- 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
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dgraph-io/dgraph
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 10 ngày
-
Broken links in the docsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 10 ngày
-
Stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
dgraph-io/dgraph#9811 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 10 ngày
-
Stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
dgraph-io/dgraph#9810 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 10 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 10 ngày
Tất cả issue của dgraph-io/dgraph
Issue tương tự
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Đang mởenhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
DaoCloud/DaoCloud-docs#7839 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support AlienVault OTX API keysĐang mởType: Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
projectdiscovery/urlfinder#167 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
peterstace/simplefeatures#726 ·
-
area: import bug go good first issue priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fukubie/StockLlama#69 ·
-
Add `rumpty firewall create|rm`Đang mởenhancement help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
cloverworks-hq/rumpty-cli#95 ·
Maintainer thường phản hồi trong vòng 1 ngày