Skip to content

flightsql.BaseServer does not exhaust channel in case of an error writing StreamChunks in DoGet #435

@arnoldwakim

Description

@arnoldwakim

Describe the bug, including details regarding any error messages, version, and platform.

arrow-go/v18.3.1 on linux/x86-64

Hey everyone,

As this is my first time discussing on this repository, kindly forgive me in case of a mistake.

While exploring Arrow Flight SQL servers with DuckDB, I came across an issue.

Let's assume we have a Flight SQL client that sends SQL queries to a FlightSQL server, while the data is being streamed here (sqlite example), if the client receives a non handled SIGINT, the communication between server and client stops (without a cancel request), and the server catches the error here.
However, I still have an arrow array somewhere buffered in memory (server side) and the record reader that has not been released and therefore I still have arrow arrays in the wild waiting to be freed.

When modifying the source code here, while checking for an error adding a for loop that exhaust the channel to release the StreamChunk resolves the issue.

func exhaustChannelAndReleaseStreamChunks(cc <-chan flight.StreamChunk) {
	for chunk := range cc {
		chunk.Data.Release()
	}
}
if err = wr.WriteWithAppMetadata(chunk.Data, chunk.AppMetadata); err != nil {
    exhaustChannelAndReleaseStreamChunks(cc)
    return err
}

Did I misunderstand something?
I can take care of the PR if need be.
I've been testing that manually. Do you think I can test the behaviour rigorously?

Thank you for your time.

Component(s)

flight/flightsql

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions