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

bug: Panic with unique composite index on relation with filter on relation #3016

Closed
islamaliev opened this issue Sep 17, 2024 · 0 comments · Fixed by #3020
Closed

bug: Panic with unique composite index on relation with filter on relation #3016

islamaliev opened this issue Sep 17, 2024 · 0 comments · Fixed by #3020
Assignees
Labels
area/query Related to the query component bug Something isn't working
Milestone

Comments

@islamaliev
Copy link
Contributor

Reported by @david-on-github

With this schema

type Foo {
  id: String
  bars: [Bar] @relation(name: "foobars")
}

type Bar @index(unique: true, includes: [{ name: "foo_id" }, { name: "id" }], name: "test_unqiue") {
  id: String
  foo: Foo @relation(name: "foobars")
}

Create some docs for them
Then try to query with a filter on the child relation

query {
  Foo {
    _docID
    bars(filter: { foo_id: {_eq: "bae-7eda71ae-2b1c-5ee8-9b21-d8e28b2bf8a3"} }) {
      _docID
      foo_id
    }
  }
}

Results in this panic.

panic: runtime error: invalid memory address or nil pointer dereference
 
 -> github.com/sourcenetwork/defradb/internal/db/fetcher.(*indexPrefixIterator).Close
 ->   github.com/sourcenetwork/defradb/internal/db/fetcher/indexer_iterators.go:144

    github.com/sourcenetwork/defradb/internal/db/fetcher.(*IndexFetcher).Close
      github.com/sourcenetwork/defradb/internal/db/fetcher/indexer.go:215
    github.com/sourcenetwork/defradb/internal/lens.(*lensedFetcher).Close
      github.com/sourcenetwork/defradb/internal/lens/fetcher.go:192
    github.com/sourcenetwork/defradb/internal/planner.(*scanNode).Close
      github.com/sourcenetwork/defradb/internal/planner/scan.go:229
    github.com/sourcenetwork/defradb/internal/planner.(*invertibleTypeJoin).Close
      github.com/sourcenetwork/defradb/internal/planner/type_join.go:491
    github.com/sourcenetwork/defradb/internal/planner.(*typeIndexJoin).Close
      github.com/sourcenetwork/defradb/internal/planner/type_join.go:132
    github.com/sourcenetwork/defradb/internal/planner.(*selectNode).Close
      github.com/sourcenetwork/defradb/internal/planner/select.go:189
    github.com/sourcenetwork/defradb/internal/planner.(*selectTopNode).Close
      github.com/sourcenetwork/defradb/internal/planner/select.go:89
    github.com/sourcenetwork/defradb/internal/planner.(*invertibleTypeJoin).Close
      github.com/sourcenetwork/defradb/internal/planner/type_join.go:495
    github.com/sourcenetwork/defradb/internal/planner.(*typeIndexJoin).Close
      github.com/sourcenetwork/defradb/internal/planner/type_join.go:132
    github.com/sourcenetwork/defradb/internal/planner.(*selectNode).Close
      github.com/sourcenetwork/defradb/internal/planner/select.go:189
    github.com/sourcenetwork/defradb/internal/planner.(*selectTopNode).Close
      github.com/sourcenetwork/defradb/internal/planner/select.go:89
    github.com/sourcenetwork/defradb/internal/planner.(*operationNode).Close
      github.com/sourcenetwork/defradb/internal/planner/operation.go:66
    github.com/sourcenetwork/defradb/internal/planner.(*Planner).RunRequest.func1
      github.com/sourcenetwork/defradb/internal/planner/planner.go:515
    github.com/sourcenetwork/defradb/internal/planner.(*Planner).RunRequest
      github.com/sourcenetwork/defradb/internal/planner/planner.go:545
    github.com/sourcenetwork/defradb/internal/db.(*db).execRequest
      github.com/sourcenetwork/defradb/internal/db/request.go:53
    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:311
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/go-chi/chi/v5.(*Mux).routeHTTP
      github.com/go-chi/chi/[email protected]/mux.go:459
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/go-chi/chi/v5.(*Mux).ServeHTTP
      github.com/go-chi/chi/[email protected]/mux.go:73
    github.com/sourcenetwork/defradb/http.(*Router).ServeHTTP
      github.com/sourcenetwork/defradb/http/router.go:67
    github.com/go-chi/chi/v5.(*Mux).routeHTTP
      github.com/go-chi/chi/[email protected]/mux.go:459
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/sourcenetwork/defradb/http.AuthMiddleware.func1
      github.com/sourcenetwork/defradb/http/auth.go:57
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/sourcenetwork/defradb/http.TransactionMiddleware.func1
      github.com/sourcenetwork/defradb/http/middleware.go:83
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/sourcenetwork/defradb/http.NewHandler.func1.ApiMiddleware.1.1
      github.com/sourcenetwork/defradb/http/middleware.go:71
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/go-chi/chi/v5.(*Mux).ServeHTTP
      github.com/go-chi/chi/[email protected]/mux.go:73
    github.com/go-chi/chi/v5.(*Mux).Mount.func1
      github.com/go-chi/chi/[email protected]/mux.go:327
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/go-chi/chi/v5.(*Mux).routeHTTP
      github.com/go-chi/chi/[email protected]/mux.go:459
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/go-chi/chi/v5.(*Mux).ServeHTTP
      github.com/go-chi/chi/[email protected]/mux.go:73
    github.com/sourcenetwork/defradb/http.(*Handler).ServeHTTP
      github.com/sourcenetwork/defradb/http/handler.go:107
    github.com/go-chi/chi/v5.(*Mux).routeHTTP
      github.com/go-chi/chi/[email protected]/mux.go:459
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/go-chi/cors.(*Cors).Handler-fm.(*Cors).Handler.func1
      github.com/go-chi/[email protected]/cors.go:228
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/go-chi/chi/v5/middleware.Recoverer.func1
      github.com/go-chi/chi/[email protected]/middleware/recoverer.go:45
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/sourcenetwork/defradb/http.NewServer.RequestLogger.func2.1
      github.com/go-chi/chi/[email protected]/middleware/logger.go:55
    net/http.HandlerFunc.ServeHTTP
      net/http/server.go:2171
    github.com/go-chi/chi/v5.(*Mux).ServeHTTP
      github.com/go-chi/chi/[email protected]/mux.go:90
    net/http.serverHandler.ServeHTTP
      net/http/server.go:3142
    net/http.(*conn).serve
      net/http/server.go:2044
    created by net/http.(*Server).Serve in goroutine 75
      net/http/server.go:3290
@islamaliev islamaliev added bug Something isn't working area/query Related to the query component labels Sep 17, 2024
@islamaliev islamaliev added this to the DefraDB v0.14 milestone Sep 17, 2024
@islamaliev islamaliev self-assigned this Sep 17, 2024
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.

1 participant