GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fixed potential deadlock in FbConnectionPoolManager by Howaner · Pull Request #1076 · FirebirdSQL/NETProvider

Conversation

@Howaner

@Howaner Howaner commented Oct 14, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Our ASP.NET Core application has been crashing about once a week lately with a lot of open threads and a deadlock when using the FbConnection.OpenAsync() function.

I now found the following deadlock:

  1. Pool.PrunePool(): Parallel.ForEach(release, x => x.Release()); is the main deadlock cause.
  2. Release() can call the Pool.ReleaseConnection() method and this method locks the same lock
  3. So now, PrunePool() is already locking the _syncRoot lock and ReleaseConnection() wants to lock the _syncRoot lock
  4. But PrunePool() is waiting for Release() to complete => Deadlock

The FbConnectionInternal.Disconnect() method is already called in different places without locking the _syncRoot lock, so I assume it can be called outside the lock.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Franz Reiter
Fixed potential deadlock in FbConnectionPoolManager
84d0385
@Howaner

Howaner commented Nov 10, 2022

Copy link
Copy Markdown
Author

@cincuranet Is there a chance to integrate this into upstream? Is there anything else I need to do?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cincuranet

cincuranet commented Nov 10, 2022

Copy link
Copy Markdown
Member

I need to review the PR first. Currently busy.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fdcastel

fdcastel commented Jul 11, 2023

Copy link
Copy Markdown
Member

@Howaner do you have a reproductible test case which shows the problem?

Maybe adding a test case to this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Howaner

Howaner commented Jul 12, 2023

Copy link
Copy Markdown
Author

@fdcastel It is a race condition and therefore quite difficult to trigger. I tried to reproduce it in a test project today but I failed.
The race condition occurs when using the Firebird library in an application where many things happen simultaneously.
Our application crashed every few weeks due to this bug and since we changed this few lines, the deadlock has no longer occurred.

I'm really surprised that the bug doesn't already occur much more often with other people. Probably only a few people make many simultaneous requests with Firebird.

fdcastel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fdcastel

fdcastel commented Jul 12, 2023

Copy link
Copy Markdown
Member

I understand. Surely they are a hell to reproduce.

Thank you for you feedback. Much appreciated.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@willibrandon

willibrandon commented Jul 27, 2023

Copy link
Copy Markdown
Contributor

I too have started hitting this issue in our test projects after updating to version 9.1.1.0. I'll try and see if I can write a minimal reproducible test case.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fdcastel

fdcastel commented Oct 25, 2024

Copy link
Copy Markdown
Member

@willibrandon, @Howaner Have you had any success reproducing the issue?

@Howaner, if I understand correctly, you've been running a fork of this project in production with this PR applied. Have you never encountered any further errors since applying it?

@willibrandon, would you be able to try the same approach?

While I understand the changes @Howaner made in this PR, it's challenging to approve them based solely on verbal explanations (no offense intended, please). As engineers, I trust you both will understand.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@willibrandon

willibrandon commented Oct 25, 2024

Copy link
Copy Markdown
Contributor

We saw this issue pop up in our test runs after updating the data provider version for the first time in a decade. I was not successful reproducing this issue however, and have not seen the it reoccur since.

@PaladinMattt - Do you recall the last time you saw this one?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaladinMattt

PaladinMattt commented Oct 25, 2024

Copy link
Copy Markdown

It has been some time since I've noticed it. If my memory serves me correctly, it mainly happened during debugging, when calling FbConnection.ClearAllPools();, but I don't recalling seeing this issue for a few months now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cincuranet

cincuranet commented Nov 4, 2026

Copy link
Copy Markdown
Member

I'm looking at the PR now, with the help of various AI models, and I'm not convinced the fix fixes what it claims to fix. Moreover it also slightly changes the ordering of concurrent operations and that brings other new questions.

I'm not saying the bug is not there, far from it, but a dump when the deadlock happens would help to pinpoint the exact constellation of threads, etc.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Howaner @cincuranet @fdcastel @willibrandon @PaladinMattt
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.