fwojciec commented on issue #2629: URL: https://github.com/apache/arrow-adbc/issues/2629#issuecomment-2738768765
out of curiosity, why would this be still segfaulting? I'm creating a slice of records in a separate scope, retaining the individual records, and then closing all DB-related resources, before passing a slice of retained records back to the DoGet handler - am I completely misunderstanding how it's supposed to work? also, for what it's worth, _not_ closing the `Statement` in `getRecords` "solves" it. ```go package main import ( "context" "fmt" "os" "github.com/apache/arrow-adbc/go/adbc" "github.com/apache/arrow-adbc/go/adbc/drivermgr" "github.com/apache/arrow-go/v18/arrow" "github.com/apache/arrow-go/v18/arrow/flight" "github.com/apache/arrow-go/v18/arrow/ipc" ) func main() { if err := runServer(); err != nil { panic(err) } } type server struct { flight.BaseFlightServer } func getRecords(ctx context.Context) ([]arrow.Record, *arrow.Schema, error) { pgDsn := os.Getenv("POSTGRESQL_DSN") if pgDsn == "" { return nil, nil, fmt.Errorf("POSTGRESQL_DSN is not set") } var drv drivermgr.Driver db, err := drv.NewDatabase(map[string]string{ "driver": "adbc_driver_postgresql", adbc.OptionKeyURI: pgDsn, }) if err != nil { return nil, nil, err } defer db.Close() conn, err := db.Open(ctx) if err != nil { return nil, nil, err } defer conn.Close() st, err := conn.NewStatement() if err != nil { return nil, nil, err } defer st.Close() // if I comment this out I seem to prevent segfaults if err := st.SetSqlQuery("SELECT * FROM synthetic_filter_option"); err != nil { return nil, nil, err } reader, _, err := st.ExecuteQuery(ctx) if err != nil { return nil, nil, err } defer reader.Release() var records []arrow.Record for reader.Next() { rec := reader.Record() rec.Retain() records = append(records, rec) } if err := reader.Err(); err != nil { return nil, nil, err } return records, reader.Schema(), nil } func (s *server) DoGet(tkt *flight.Ticket, fs flight.FlightService_DoGetServer) error { ctx := fs.Context() records, schema, err := getRecords(ctx) if err != nil { return err } wr := flight.NewRecordWriter( fs, ipc.WithSchema(schema), ) defer wr.Close() for _, rec := range records { if err := wr.Write(rec); err != nil { return err } // need to release records here? } return nil } func runServer() error { s := flight.NewServerWithMiddleware(nil) s.Init("0.0.0.0:8816") s.RegisterFlightService(&server{}) return s.Serve() } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org