apache / arrow

Apache Arrow is the universal columnar format and multi-language toolbox for fast data interchange and in-memory analytics
https://arrow.apache.org/
Apache License 2.0
14.63k stars 3.56k forks source link

[Java][FlightRPC] Java arrow flight server stuck in reader.getDescriptor() #44771

Open billyean opened 3 days ago

billyean commented 3 days ago

Describe the usage question you have. Please include as many useful details as possible.

Arrow version: 15. Client: C++ Server: Java I have a Java arrow flight server that uses doExchange to read the context, my server code is as follows, I have identified in multiple thread environment, in the tests many calls would stuck at the line FlightDescriptor descriptor = reader.getDescriptor(); in the second time(Which means the first call in the same thread usually is not blocked), and which makes the following requests also stucks.

        log.info("Start to call doExchange.........");
        // Trying to
        try (BufferAllocator allocator = allocatorPool.submit(
            () -> this.allocator.newChildAllocator("exchange", 0, Long.MAX_VALUE)).get()) {
            FlightDescriptor descriptor = reader.getDescriptor();
            List<String> path = descriptor.getPath();
            String type = path.get(0);
            String funcSignature = path.get(1);
           ...

The client code is as follows

std::vector<std::shared_ptr<RecordBatch>> UDFClient::Call(
    const std::vector<std::string>& paths,
    std::shared_ptr<RecordBatch>& batch) const {
  // Create a FlightDescriptor using a path
  FlightDescriptor descriptor = FlightDescriptor::Path(paths);
  auto exchange_result = Client_->DoExchange(descriptor);
  if (!exchange_result.ok()) {
    throw std::runtime_error("Do exchange descriptor: "
            + exchange_result.status().ToString());
  }
  auto exchange = std::move(exchange_result.ValueUnsafe());
  ...

I understand reader.getDescriptor(); is a blocking call that will use future to wait the descriptor sent. Since doExchange in the server has been called, I assume the client auto exchange_result = Client_->DoExchange(descriptor); has been received. I can't figure what could make reader.getDescriptor(); stuck, I am reporting this to the community that want to know is this a bug or there is something I did wrong. Thank you

Component(s)

C++, FlightRPC, Java

billyean commented 1 day ago

Can anyone take a look at this issue? Thank you.