Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock with READ ONLY READ COMMITTED NO RECORD_VERSION WAIT transaction [CORE5340] #5615

Closed
firebird-automations opened this issue Aug 28, 2016 · 11 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Gabor Boros (gaborboros)

Attachments:
READ_DEADLOCK.pas

The result of the attached example is:

deadlock
-read conflicts with concurrent update
-concurrent transaction number is 2

@firebird-automations
Copy link
Collaborator Author

Modified by: Gabor Boros (gaborboros)

Attachment: READ_DEADLOCK.pas [ 13007 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Locks are owned by attachments and attachment cannot wait for itself (it will cause an infinite deadlock), so conflict error is raised immediately if both lock requests belong to the same owner. This is a design limitation rather than a bug.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

I'm wondering what you expected from this test case? The only alternative is to hang your application forever "waiting" for the first transaction.

@firebird-automations
Copy link
Collaborator Author

Commented by: Gabor Boros (gaborboros)

So, cannot use two transactions (in this example a reader and a writer) in same attachment in same time by design? "raised immediately"? For me with the attached example exception raised after ~10 seconds (come from DeadlockTimeout in firebird.conf?).

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Yes, this is by design. Two conflicting transactions cannot wait for each other inside a single attachment. Deadlock is really detected after the DeadlockTimeout interval.

@firebird-automations
Copy link
Collaborator Author

Commented by: Gabor Boros (gaborboros)

Yes, for me the WAIT transaction means wait "forever" (and continue if the concurrent transaction committed/rollbacked). Which works if the reader and writer transaction separated to two attachments. For the WAIT transaction MON$TRANSACTIONS.MON$LOCK_TIMEOUT value is -1 and Language Reference say "-1 - wait forever".

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

With two separate attachments, you can "unblock" the waiting transaction by committing / rolling back the blocking transaction. It's impossible if they both belong to the same attachment. In this case WAIT = HANG and the engine detects this signaling a deadlock.

@firebird-automations
Copy link
Collaborator Author

Commented by: Gabor Boros (gaborboros)

Is this "by design" documented somewhere or trivial for everybody except me? :-) Please close this issue...

@firebird-automations
Copy link
Collaborator Author

Commented by: Attila Molnár (e_pluribus_unum)

Hi Gábor!

http://firebirdsql.org/file/documentation/drivers_documentation/python/3.3.0/thread-safety-overview.html

Definition of "Thread-Safety"

Currently, the highest level of concurrency supported by any version of the Firebird client library is thread-safety at the connection level.

When we say that the Firebird client library is thread-safe at the connection level, we mean that it is safe to use a particular connection in only one thread at a time, although the same connection can be manipulated by different threads in a serial fashion, and different connections can be manipulated by different threads in parallel.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

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

No branches or pull requests

1 participant