mtanneryd / ef-bulk-operations

Bulk operations for Entity Framework 6
Apache License 2.0
80 stars 30 forks source link

BulkInsert is not thread safety #16

Closed simai4 closed 5 years ago

simai4 commented 5 years ago

Helloy, @mtanneryd.

If I execute many BulkInsert in one table in many threads (parrallel executing BulkInsert), I have Exception("More id values generated than we had entities. Something went wrong, try again.").

It happens because the increment of the primary key (user integer) and the number of inserted records are compared, but they may differ when the insertion is parallel.

mtanneryd commented 5 years ago

Hi!

Thanks for your feedback. Which version are you using?

simai4 commented 5 years ago

Hi, I'm using 1.2.2 version.

komrados commented 5 years ago

Hi, I'm also experiencing this problem at version 1.2.3

mtanneryd commented 5 years ago

When you say "user integer", exactly what do you mean? Have you defined your own type?

mtanneryd commented 5 years ago

Thinking about this a bit more and reading the original bug report by simai4 again, I realize that I need to replace the "select ident...." based way of matching generated primary keys with the merge-based variant. I'll try to get it fixed and tested before the weekend.

Thanks for the valuable feedback!