Skip to content

deadlock when closing connections #241

@thomasrynnetopaz

Description

@thomasrynnetopaz

Our test suite opens and closes many in memory duckdb databases.

Since upgrading to duckdb 1.3.0 we sometimes have a deadlock situation where threads are blocked.

We believe this is because DuckdDBConnection#close calls

  1. connRefLock.lock()
  2. resultRefLock.lock() - via DuckDBPreparedStatement.close & DuckDBResultSet.close()

Whereas DuckDBResultSet#next() calls fetchChunk(), which then calls

  1. resultRefLock.lock()
  2. connRefLock.lock()

If the timing is wrong one thread could lock connRefLock and wait on resultRefLock while another locks resultRefLock and waits on connRefLock

I think the fix would be to swap the ordering of locks in fetchChunk

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions