apache / arrow-flight-sql-postgresql

Apache Arrow Flight SQL adapter for PostgreSQL
https://arrow.apache.org/flight-sql-postgresql/
Apache License 2.0
64 stars 9 forks source link

read/write wait logic may be deadlock #163

Closed kou closed 8 months ago

kou commented 8 months ago

If we can't read/write any data, the current logic waits until any readable data/write space is available. For example, here is the read wait workflow:

  1. read() -> 0 bytes read
  2. wait()
    1. Check the current readable size in a shared buffer
    2. Loop
      1. Check the current readable size in a shared buffer
      2. Compare 2.ii.a with 2.i

We don't acquire a lock between 1. and 2.i. If new data is arrived between 1. and 2.i, the new data isn't detected. It may cause a deadlock.