Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching indexed field in child document panics #2924

Closed
AndrewSisley opened this issue Aug 19, 2024 · 2 comments · Fixed by #2947
Closed

Fetching indexed field in child document panics #2924

AndrewSisley opened this issue Aug 19, 2024 · 2 comments · Fixed by #2947
Assignees
Labels
area/query Related to the query component bug Something isn't working
Milestone

Comments

@AndrewSisley
Copy link
Contributor

The following setup panics. It does not panic when reward_id is removed from the query. It does not panic when the index is removed from ActionRequirement.

Schema:

type ActionRequirement @index(unique: true, fields: ["action_id", "reward_id"], name: "actionId_rewardId")  {
  count: Int
  isPreReq: Boolean # @default(false)
  action: Action @relation(name: "actionActionRequirements")
  reward: Reward @relation(name: "rewardActionRequirements")
  createdAt: DateTime # @default(now())
  oldId: String
}

type Reward {
  name: String @index(unique: true) # @unique
  description: String
  value: Int
  limit: Int
  tiers: [RewardTier] @relation(name: "rewardRewardTiers")
  priority: Int
  enabled: Boolean # @default(true)
  actionRequirements: [ActionRequirement] @relation(name: "rewardActionRequirements")
  playerRewards: [PlayerReward] @relation(name: "rewardPlayerRewards")
  rewardGroup: [String] # [ENUM] RewardGroup
  createdAt: DateTime # @default(now())
  oldId: String
}

Query:

query {
  Reward(filter: {name: {_eq: "FOLLOW_TWITTER"}}) {
    _deleted
    _docID
    id: _docID
    createdAt
    description
    enabled
    limit
    name
    priority
    rewardGroup
    value
    oldId
    actionRequirements {
      id: _docID
      _docID
      action_id
      count
      createdAt
      isPreReq
      oldId
      reward_id
    }
  }}

Panic (was reported via http client, so original panic is lost):

panic: Unclosed iterator at time of Txn.Discard.
github.com/sourcenetwork/badger/v4.(Txn).Discard
github.com/sourcenetwork/badger/v4@v4.2.1-0.20231113215945-a63444ca5276/txn.go:524
github.com/sourcenetwork/badger/v4.(Txn).Commit
github.com/sourcenetwork/badger/v4@v4.2.1-0.20231113215945-a63444ca5276/txn.go:665
github.com/sourcenetwork/defradb/datastore/badger/v4.(txn).commit
github.com/sourcenetwork/defradb/datastore/badger/v4/datastore.go:765
github.com/sourcenetwork/defradb/datastore/badger/v4.(txn).Commit
github.com/sourcenetwork/defradb/datastore/badger/v4/datastore.go:761
github.com/sourcenetwork/defradb/datastore.(txn).Commit
github.com/sourcenetwork/defradb/datastore/txn.go:106
github.com/sourcenetwork/defradb/internal/db.(db).ExecRequest
github.com/sourcenetwork/defradb/internal/db/store.go:38
github.com/sourcenetwork/defradb/http.(*storeHandler).ExecRequest
github.com/sourcenetwork/defradb/http/handler_store.go:302
net/http.HandlerFunc.ServeHTTP
net/http/server.go:2171

@AndrewSisley AndrewSisley added bug Something isn't working area/query Related to the query component labels Aug 19, 2024
@fredcarle
Copy link
Collaborator

This panic happens in the CI as well:

=== FAIL: tests/integration/index TestQueryWithIndexOnManyToOne_MultipleViaOneToMany (0.19s)
Aug 20 01:42:49.902 INF tests.integration  database=badger-in-memory client=go mutationType=collection-save databaseDir="" badgerEncryption=true skipNetworkTests=false changeDetector.Enabled=false changeDetector.SetupOnly=false changeDetector.SourceBranch=develop changeDetector.TargetBranch="" changeDetector.Repository=https://github.com/sourcenetwork/defradb.git
Aug 20 01:42:50.060 INF db Closing DefraDB process...
Aug 20 01:42:50.088 INF db Successfully closed running process
panic: Unclosed iterator at time of Txn.Discard.
	panic: Unclosed iterator at time of Txn.Discard. [recovered]
	panic: Unclosed iterator at time of Txn.Discard.

goroutine 730931 [running]:
testing.tRunner.func1.2({0x6560f60, 0x87e2ff0})
	/opt/hostedtoolcache/go/1.21.3/x64/src/testing/testing.go:1545 +0x366
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.21.3/x64/src/testing/testing.go:1548 +0x630
panic({0x6560f60?, 0x87e2ff0?})
	/opt/hostedtoolcache/go/1.21.3/x64/src/runtime/panic.go:920 +0x270
github.com/sourcenetwork/badger/v4.(*Txn).Discard(0xc00191ed00)
	/home/runner/go/pkg/mod/github.com/sourcenetwork/badger/v4@v4.2.1-0.20231113215945-a63444ca5276/txn.go:524 +0x1fe
github.com/sourcenetwork/defradb/datastore/badger/v4.(*txn).discard(...)
	/home/runner/work/defradb/defradb/datastore/badger/v4/datastore.go:780
github.com/sourcenetwork/defradb/datastore/badger/v4.(*txn).Discard(0xc0040c3b00, {0x4ed6d5?, 0xc003b13e78?})
	/home/runner/work/defradb/defradb/datastore/badger/v4/datastore.go:776 +0x1c5
github.com/sourcenetwork/defradb/datastore.(*txn).Discard(0xc002798780, {0x8834840, 0xc00210b2f0})
	/home/runner/work/defradb/defradb/datastore/txn.go:125 +0xb5
panic({0x6560f60?, 0x87e2ff0?})
	/opt/hostedtoolcache/go/1.21.3/x64/src/runtime/panic.go:920 +0x270
github.com/sourcenetwork/badger/v4.(*Txn).Discard(0xc00191ed00)
	/home/runner/go/pkg/mod/github.com/sourcenetwork/badger/v4@v4.2.1-0.20231113215945-a63444ca5276/txn.go:524 +0x1fe
github.com/sourcenetwork/badger/v4.(*Txn).Commit(0xc00191ed00)
	/home/runner/go/pkg/mod/github.com/sourcenetwork/badger/v4@v4.2.1-0.20231113215945-a63444ca5276/txn.go:665 +0x17f
github.com/sourcenetwork/defradb/datastore/badger/v4.(*txn).commit(0xc0040c3b00)
	/home/runner/work/defradb/defradb/datastore/badger/v4/datastore.go:765 +0x98
github.com/sourcenetwork/defradb/datastore/badger/v4.(*txn).Commit(0xc0040c3b00, {0x0?, 0x0?})
	/home/runner/work/defradb/defradb/datastore/badger/v4/datastore.go:761 +0x198
github.com/sourcenetwork/defradb/datastore.(*txn).Commit(0xc002798780, {0x8834840, 0xc00210b2f0})
	/home/runner/work/defradb/defradb/datastore/txn.go:106 +0xa9
github.com/sourcenetwork/defradb/internal/db.(*db).ExecRequest(0x0?, {0x8834840, 0xc00210b140}, {0x6fb80d0, 0x5f})
	/home/runner/work/defradb/defradb/internal/db/store.go:38 +0x36f
github.com/sourcenetwork/defradb/tests/integration.executeRequest(0xc00164d8c0, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x6fb80d0, 0x5f}, 0xc002763d40, ...})
	/home/runner/work/defradb/defradb/tests/integration/utils.go:1708 +0x372
github.com/sourcenetwork/defradb/tests/integration.performAction(0xc00164d8c0, 0x0?, {0x6b8f380?, 0xc0013a1110?})
	/home/runner/work/defradb/defradb/tests/integration/utils.go:336 +0x1347
github.com/sourcenetwork/defradb/tests/integration.executeTestCase({0x88347d0?, 0xc597fc0}, {0x888a338?, 0xc00d451380?}, {0xc002763dd0, 0x3, 0x3}, {{0x0, 0x0}, {0xc002b3af50, ...}, ...}, ...)
	/home/runner/work/defradb/defradb/tests/integration/utils.go:226 +0x1276
github.com/sourcenetwork/defradb/tests/integration.ExecuteTestCase({0x888a338?, 0xc00d451380}, {{0x0, 0x0}, {0xc002b3af50, 0x5, 0x5}, {0x0, {0x0, 0x0, ...}}, ...})
	/home/runner/work/defradb/defradb/tests/integration/utils.go:180 +0xade
github.com/sourcenetwork/defradb/tests/integration/index.TestQueryWithIndexOnManyToOne_MultipleViaOneToMany(0x0?)
	/home/runner/work/defradb/defradb/tests/integration/index/query_with_relation_filter_test.go:1018 +0xb88
testing.tRunner(0xc00d451380, 0x72573e0)
	/opt/hostedtoolcache/go/1.21.3/x64/src/testing/testing.go:1595 +0x239
created by testing.(*T).Run in goroutine 1
	/opt/hostedtoolcache/go/1.21.3/x64/src/testing/testing.go:1648 +0x82b

@islamaliev islamaliev self-assigned this Aug 20, 2024
@islamaliev
Copy link
Contributor

I'll look into this shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants