How do I delete all of type plus associated types?

If I have the following schema:

type ParentObject {
  id: ID!
  childObjects: [ChildObject!] @hasInverse(field: parent)
}

type ChildObject {
  id: ID!
  parent: ParentObject! @hasInverse(field: childObjects)
}

What would be the most efficient way to delete all ParentObjects with their associated .childObjects?

Looks like the answer is to use this:

In DQL or GraphQL?

Your schema, is it a fixed parenting? e.g. ParentObject will never be a child of ChildObject.
ParentObject will always be the beginning of your modeling? It will have a nested infinite relation? or limited to two objects?

Fixed parenting. I actually have a tree of objects:

A:
– B:
-----C
– B:
A:
– B:

query doesn’t need to be GraphQL, just need a way to delete the tree of objects.

EDIT: looks like I need to use an upsert like this: How to bulk delete nodes or cascade delete nodes? - #2 by MichelDiz

EDIT: seemed to work:

1 Like

These txn logs feels pretty ugly. We should fix this.
This happens because it’s shared, right?
Can you open an issue for this? please.

This is using Ratel to perform an upsert on 21.03 standalone image running in local Docker.

You’re talking about the \u0000 stuff?

Yes. Do you have ACL? multitenancy I mean tho.

I don’t think so, I’m just running the image with no flags in the Docker desktop app:

Warning: This standalone version is meant for quickstart purposes only.

         It is NOT RECOMMENDED for production environments.

2022/10/03 23:26:04 Listening on :8000...

[Sentry] 2022/10/03 23:26:05 Integration installed: ContextifyFrames

[Sentry] 2022/10/03 23:26:05 Integration installed: Environment

[Sentry] 2022/10/03 23:26:05 Integration installed: Modules

[Sentry] 2022/10/03 23:26:05 Integration installed: IgnoreErrors

[Sentry] 2022/10/03 23:26:05 Integration installed: ContextifyFrames

[Sentry] 2022/10/03 23:26:05 Integration installed: Environment

[Sentry] 2022/10/03 23:26:05 Integration installed: Modules

[Sentry] 2022/10/03 23:26:05 Integration installed: IgnoreErrors

[Sentry] 2022/10/03 23:26:07 Integration installed: ContextifyFrames

[Sentry] 2022/10/03 23:26:07 Integration installed: Environment

[Sentry] 2022/10/03 23:26:07 Integration installed: Modules

[Sentry] 2022/10/03 23:26:07 Integration installed: IgnoreErrors

[Sentry] 2022/10/03 23:26:07 Integration installed: ContextifyFrames

[Sentry] 2022/10/03 23:26:07 Integration installed: Environment

[Sentry] 2022/10/03 23:26:07 Integration installed: Modules

[Sentry] 2022/10/03 23:26:07 Integration installed: IgnoreErrors

I1003 23:26:07.319859      25 sentry_integration.go:48] This instance of Dgraph will send anonymous reports of panics back to Dgraph Labs via Sentry. No confidential information is sent. These reports help improve Dgraph. To opt-out, restart your instance with the --telemetry "sentry=false;" flag. For more info, see https://dgraph.io/docs/howto/#data-handling.

I1003 23:26:07.454793      35 sentry_integration.go:48] This instance of Dgraph will send anonymous reports of panics back to Dgraph Labs via Sentry. No confidential information is sent. These reports help improve Dgraph. To opt-out, restart your instance with the --telemetry "sentry=false;" flag. For more info, see https://dgraph.io/docs/howto/#data-handling.

I1003 23:26:07.691338      25 init.go:110] 


Dgraph version   : v21.03.0

Dgraph codename  : rocket

Dgraph SHA-256   : b4e4c77011e2938e9da197395dbce91d0c6ebb83d383b190f5b70201836a773f

Commit SHA-1     : a77bbe8ae

Commit timestamp : 2021-04-07 21:36:38 +0530

Branch           : HEAD

Go version       : go1.16.2

jemalloc enabled : true


For Dgraph official documentation, visit https://dgraph.io/docs.

For discussions about Dgraph     , visit http://discuss.dgraph.io.

For fully-managed Dgraph Cloud   , visit https://dgraph.io/cloud.


Licensed variously under the Apache Public License 2.0 and Dgraph Community License.

Copyright 2015-2021 Dgraph Labs, Inc.



I1003 23:26:07.693716      25 run.go:756] x.Config: {PortOffset:0 Limit:query-timeout=0ms; txn-abort-after=5m; max-retries=-1; max-pending-queries=10000; query-edge=1000000; mutations-nquad=1000000; disallow-drop=false; mutations=allow; normalize-node=10000 LimitMutationsNquad:1000000 LimitQueryEdge:1000000 BlockClusterWideDrop:false LimitNormalizeNode:10000 QueryTimeout:0s MaxRetries:-1 GraphQL:lambda-url=; introspection=true; debug=false; extensions=true; poll-interval=1s GraphQLDebug:false}

I1003 23:26:07.694469      25 run.go:757] x.WorkerConfig: {TmpDir:t ExportPath:export Trace:ratio=0.01; jaeger=; datadog= MyAddr: ZeroAddr:[localhost:5080] TLSClientConfig:<nil> TLSServerConfig:<nil> Raft:learner=false; snapshot-after-entries=10000; snapshot-after-duration=30m; pending-proposals=256; idx=; group= Badger:{Dir: ValueDir: SyncWrites:false NumVersionsToKeep:1 ReadOnly:false Logger:0xc00017ea00 Compression:1 InMemory:false MetricsEnabled:true NumGoroutines:8 MemTableSize:67108864 BaseTableSize:2097152 BaseLevelSize:10485760 LevelSizeMultiplier:10 TableSizeMultiplier:2 MaxLevels:7 VLogPercentile:0 ValueThreshold:1048576 NumMemtables:5 BlockSize:4096 BloomFalsePositive:0.01 BlockCacheSize:697932185 IndexCacheSize:375809638 NumLevelZeroTables:5 NumLevelZeroTablesStall:15 ValueLogFileSize:1073741823 ValueLogMaxEntries:1000000 NumCompactors:4 CompactL0OnClose:false LmaxCompaction:false ZSTDCompressionLevel:0 VerifyValueChecksum:false EncryptionKey:[] EncryptionKeyRotationDuration:240h0m0s BypassLockGuard:false ChecksumVerificationMode:0 DetectConflicts:true NamespaceOffset:-1 managedTxns:false maxBatchCount:0 maxBatchSize:0 maxValueThreshold:0} WhiteListedIPRanges:[{Lower:0.0.0.0 Upper:255.255.255.255}] StrictMutations:false AclEnabled:false HmacSecret:**** AbortOlderThan:5m0s ProposedGroupId:0 StartTime:2022-10-03 23:26:06.8472053 +0000 UTC m=+0.567541201 Ludicrous:enabled=false; concurrency=2000 LudicrousEnabled:false Security:whitelist=0.0.0.0/0; token= EncryptionKey:**** LogRequest:0 HardSync:false Audit:false}

I1003 23:26:07.697568      25 run.go:758] worker.Config: {PostingDir:p WALDir:w MutationsMode:0 AuthToken: HmacSecret:**** AccessJwtTtl:0s RefreshJwtTtl:0s CachePercentage:0,65,35 CacheMb:1024 Audit:<nil> ChangeDataConf:file=; kafka=; sasl_user=; sasl_password=; ca_cert=; client_cert=; client_key=;}

I1003 23:26:07.711255      25 log.go:295] Found file: 2 First Index: 30001

I1003 23:26:07.720718      25 storage.go:125] Init Raft Storage with snap: 30059, first: 30060, last: 36046

I1003 23:26:07.722568      25 server_state.go:141] Opening postings BadgerDB with options: {Dir:p ValueDir:p SyncWrites:false NumVersionsToKeep:2147483647 ReadOnly:false Logger:0x32c8038 Compression:1 InMemory:false MetricsEnabled:true NumGoroutines:8 MemTableSize:67108864 BaseTableSize:2097152 BaseLevelSize:10485760 LevelSizeMultiplier:10 TableSizeMultiplier:2 MaxLevels:7 VLogPercentile:0 ValueThreshold:1048576 NumMemtables:5 BlockSize:4096 BloomFalsePositive:0.01 BlockCacheSize:697932185 IndexCacheSize:375809638 NumLevelZeroTables:5 NumLevelZeroTablesStall:15 ValueLogFileSize:1073741823 ValueLogMaxEntries:1000000 NumCompactors:4 CompactL0OnClose:false LmaxCompaction:false ZSTDCompressionLevel:0 VerifyValueChecksum:false EncryptionKey:[] EncryptionKeyRotationDuration:240h0m0s BypassLockGuard:false ChecksumVerificationMode:0 DetectConflicts:false NamespaceOffset:1 managedTxns:false maxBatchCount:0 maxBatchSize:0 maxValueThreshold:0}

I1003 23:26:07.829086      25 log.go:34] All 3 tables opened in 9ms

I1003 23:26:07.833264      25 log.go:34] Discard stats nextEmptySlot: 0

I1003 23:26:07.833415      25 log.go:34] Set nextTxnTs to 820121

I1003 23:26:07.845650      25 log.go:34] Deleting empty file: p/000083.vlog

I1003 23:26:07.875747      25 groups.go:99] Current Raft Id: 0x8

I1003 23:26:07.875810      25 groups.go:115] Sending member request to Zero: id:8 addr:"localhost:7080" 

I1003 23:26:07.876128      25 run.go:568] Bringing up GraphQL HTTP API at 0.0.0.0:8080/graphql

I1003 23:26:07.876156      25 run.go:569] Bringing up GraphQL HTTP admin API at 0.0.0.0:8080/admin

I1003 23:26:07.876181      25 run.go:596] gRPC server started.  Listening on port 9080

I1003 23:26:07.876181      25 worker.go:111] Worker listening at address: [::]:7080

I1003 23:26:07.876203      25 run.go:597] HTTP server started.  Listening on port 8080

E1003 23:26:07.876265      25 groups.go:1177] Error during SubscribeForUpdates for prefix "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15dgraph.graphql.schema\x00": Unable to find any servers for group: 1. closer err: <nil>

I1003 23:26:07.880291      35 init.go:110] 


Dgraph version   : v21.03.0

Dgraph codename  : rocket

Dgraph SHA-256   : b4e4c77011e2938e9da197395dbce91d0c6ebb83d383b190f5b70201836a773f

Commit SHA-1     : a77bbe8ae

Commit timestamp : 2021-04-07 21:36:38 +0530

Branch           : HEAD

Go version       : go1.16.2

jemalloc enabled : true


For Dgraph official documentation, visit https://dgraph.io/docs.

For discussions about Dgraph     , visit http://discuss.dgraph.io.

For fully-managed Dgraph Cloud   , visit https://dgraph.io/cloud.


Licensed variously under the Apache Public License 2.0 and Dgraph Community License.

Copyright 2015-2021 Dgraph Labs, Inc.

I’ll DM full logs to you

The logs aren’t needed. What I need is to reproduce locally. And find out if other versions are the same.