EntitiyFramework and Update

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

EntitiyFramework and Update

Roman Patutin

Hi All,

 

I created simple WinForms application that work with FireBird database. Database contain only one table with one record with four fields (id, firstname, secondanme, email).  For emulate a real program flow I start 3 concurrent query for table. Each query update own field (first for email, second for firstname, third for lastname). After starting program I've got exception with message "lock conflict on no wait transaction".

 

For testing purpose I changed database from FireBird to MySql and this exceptions is gone. Configuration for DbContext is the same, I just changed connection string.

 

How I can fix this behavior for FireBird net provider and and switch it close to MySql.

 

FireBird version: 2.5

FirebirdSql.Data.FirebirdClient: 4.10

 

--

Roman Patutin

 


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: EntitiyFramework and Update

Jiří Činčura-2
When the two transactions update same record *at the same time*, there's
nothing you can do it. One will fail. You can minimize that keeping the
transactions as short as possible. Comparing TX handling with MySQL is
wrong; I guess you used MyISAM tables, where TXs are virtually
non-existent. Try any other real DB and you'll get the same problem.

--
Mgr. Jiří Činčura
Independent IT Specialist


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: EntitiyFramework and Update

Roman Patutin
I added one more db connection into app. This time it was PostgreSql and Postgres worked with same behavior as MySql. I don't know is Postgres real db or not, but it allows to change different fields in one record for concurrent queries.

May be I just can't correctly describe the problem. Jiri, I put archive with source code into google drive https://drive.google.com/file/d/0B8UZY3a6pO3iTkRHZ1NIQVlrS3M/view?usp=sharing . Can you review my code, may be I just lost some specific configuration part or something similar.

--
Roman Patutin

-----Original Message-----
From: Jiří Činčura [mailto:[hidden email]]
Sent: Wednesday, October 26, 2016 7:37 AM
To: [hidden email]
Subject: Re: [Firebird-net-provider] EntitiyFramework and Update

When the two transactions update same record *at the same time*, there's nothing you can do it. One will fail. You can minimize that keeping the transactions as short as possible. Comparing TX handling with MySQL is wrong; I guess you used MyISAM tables, where TXs are virtually non-existent. Try any other real DB and you'll get the same problem.

--
Mgr. Jiří Činčura
Independent IT Specialist





------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: EntitiyFramework and Update

Jiří Činčura-2
There's really nothing EF related. You can try it with multiple console
windows with multiple transactions together. It's fundamental way how
transactions work.

--
Mgr. Jiří Činčura
Independent IT Specialist


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: EntitiyFramework and Update

Gerdus van Zyl
I suspect the default transaction option might not be the same in firebird and other databases.
Try setting the IsolationLevel to SERIALIZABLE on the transaction.

On Wed, Oct 26, 2016 at 10:19 AM, Jiří Činčura <[hidden email]> wrote:
There's really nothing EF related. You can try it with multiple console
windows with multiple transactions together. It's fundamental way how
transactions work.

--
Mgr. Jiří Činčura
Independent IT Specialist


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider



--
------------------------------------------------------------------------
Gerdus van Zyl

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
zab
Reply | Threaded
Open this post in threaded view
|

Re: EntitiyFramework and Update

zab
FB.NET doesn't wait on locks, it returns immediately with exception.
All other known for me  are waiting on locks. That's the behavior you
observe.
You need to override creation of transaction. You should use
FbTransaction with TBP in which you specify waiting option and
timeout.

On 26 October 2016 at 12:27, Gerdus van Zyl <[hidden email]> wrote:

> I suspect the default transaction option might not be the same in firebird
> and other databases.
> Try setting the IsolationLevel to SERIALIZABLE on the transaction.
>
> On Wed, Oct 26, 2016 at 10:19 AM, Jiří Činčura <[hidden email]> wrote:
>>
>> There's really nothing EF related. You can try it with multiple console
>> windows with multiple transactions together. It's fundamental way how
>> transactions work.
>>
>> --
>> Mgr. Jiří Činčura
>> Independent IT Specialist
>>
>>
>>
>> ------------------------------------------------------------------------------
>> The Command Line: Reinvented for Modern Developers
>> Did the resurgence of CLI tooling catch you by surprise?
>> Reconnect with the command line and become more productive.
>> Learn the new .NET and ASP.NET CLI. Get your free copy!
>> http://sdm.link/telerik
>> _______________________________________________
>> Firebird-net-provider mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
>
>
>
>
> --
> ------------------------------------------------------------------------
> Gerdus van Zyl
> www.infireal.com
>
> ------------------------------------------------------------------------------
> The Command Line: Reinvented for Modern Developers
> Did the resurgence of CLI tooling catch you by surprise?
> Reconnect with the command line and become more productive.
> Learn the new .NET and ASP.NET CLI. Get your free copy!
> http://sdm.link/telerik
> _______________________________________________
> Firebird-net-provider mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
>

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider