Skip to content

Commit 221a0af

Browse files
morningmanclaude
andcommitted
[test](arrow-flight) Close the plain Flight SQL session in the table types suite
### What problem does this PR solve? Issue Number: None Related PR: #67899 Problem Summary: test_table_types_over_arrow_flight calls GetTableTypes through a plain Flight SQL client. authenticateBasicToken opens a Doris session in the Flight connection pool, and the suite then closed only the client and the allocator. Closing the transport does not call CloseSession, so each run left one session of the test user registered until wait_timeout. The other arrow_flight_sql_p0 suites that use a plain Flight client close their sessions. Fix: end the session in a finally block with closeSession(new CloseSessionRequest(), token), the way the drivers do, before the client and the allocator close. On a local cluster, the ArrowFlightSQL sessions in SHOW PROCESSLIST grow by two per run of the suite before this change (the framework's Flight SQL JDBC connection and the leaked one) and by one after it. ### Release note None ### Check List (For Author) - Test: Regression test - test_table_types_over_arrow_flight passes on a local cluster with this PR's FE, before and after the change; SHOW PROCESSLIST as above - Behavior changed: No - Does this need documentation: No Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1258c51 commit 221a0af

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

‎regression-test/suites/arrow_flight_sql_p0/test_table_types_over_arrow_flight.groovy‎

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.CallOption
1919
import org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.CallOptions
20+
import org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.CloseSessionRequest
2021
import org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.FlightClient
2122
import org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.Location
2223
import org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.sql.FlightSqlClient
@@ -104,32 +105,37 @@ suite("test_table_types_over_arrow_flight", "arrow_flight_sql") {
104105
config.get("extArrowFlightSqlPassword")).get()
105106
CallOption[] options = [token, CallOptions.timeout(30, TimeUnit.SECONDS)]
106107
def client = new FlightSqlClient(flight)
107-
3.times {
108-
def info = client.getTableTypes(options)
109-
assertEquals(["table_type"], info.getSchema().getFields()*.getName())
110-
assertEquals(new ArrowType.Utf8(), info.getSchema().getFields()[0].getType())
111-
assertFalse(info.getSchema().getFields()[0].isNullable())
112-
assertEquals(1, info.getEndpoints().size())
113-
def types = []
114-
flight.getStream(info.getEndpoints()[0].getTicket(), options).withCloseable { stream ->
115-
assertEquals(info.getSchema(), stream.getSchema())
116-
while (stream.next()) {
117-
def root = stream.getRoot()
118-
for (int row = 0; row < root.getRowCount(); ++row) {
119-
types.add(root.getVector("table_type").getObject(row).toString())
108+
try {
109+
3.times {
110+
def info = client.getTableTypes(options)
111+
assertEquals(["table_type"], info.getSchema().getFields()*.getName())
112+
assertEquals(new ArrowType.Utf8(), info.getSchema().getFields()[0].getType())
113+
assertFalse(info.getSchema().getFields()[0].isNullable())
114+
assertEquals(1, info.getEndpoints().size())
115+
def types = []
116+
flight.getStream(info.getEndpoints()[0].getTicket(), options).withCloseable { stream ->
117+
assertEquals(info.getSchema(), stream.getSchema())
118+
while (stream.next()) {
119+
def root = stream.getRoot()
120+
for (int row = 0; row < root.getRowCount(); ++row) {
121+
types.add(root.getVector("table_type").getObject(row).toString())
122+
}
120123
}
121124
}
125+
assertEquals(["BASE TABLE", "SYSTEM VIEW", "VIEW"], types)
122126
}
123-
assertEquals(["BASE TABLE", "SYSTEM VIEW", "VIEW"], types)
124-
}
125-
def info = client.execute("SHOW VARIABLES LIKE 'query_timeout'", options)
126-
int rows = 0
127-
flight.getStream(info.getEndpoints()[0].getTicket(), options).withCloseable { stream ->
128-
while (stream.next()) {
129-
rows += stream.getRoot().getRowCount()
127+
def info = client.execute("SHOW VARIABLES LIKE 'query_timeout'", options)
128+
int rows = 0
129+
flight.getStream(info.getEndpoints()[0].getTicket(), options).withCloseable { stream ->
130+
while (stream.next()) {
131+
rows += stream.getRoot().getRowCount()
132+
}
130133
}
134+
assertEquals(1, rows)
135+
} finally {
136+
// End the session the way the drivers do rather than leaving it to wait_timeout.
137+
flight.closeSession(new CloseSessionRequest(), token)
131138
}
132-
assertEquals(1, rows)
133139
}
134140
}
135141
}

0 commit comments

Comments
 (0)