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

An error issue when using both ToJson() and UpdateMany() methods or manually enabled multiple UnitOfWorks #19635

Open
1 task done
choby opened this issue Apr 27, 2024 · 2 comments

Comments

@choby
Copy link

choby commented Apr 27, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description

When there is a jsonb field on the data table and it is mapped using ToJson(), and the jsonb field has not been modified. using the UpdateMany() method will result in an error:

System.InvalidOperationException: The value of shadow key property 'ProduceTrackingCuttingRequire.Id' is unknown when attempting to save changes. This is because shadow property values cannot be preserved when the entity is not being tracked. Consider adding the property to the entity's .NET type. See https://aka.ms/efcore-docs-owned-collections for more information.

But when I use the Update() method within a loop, there is no issue.

Reproduction Steps

No response

Expected behavior

No response

Actual behavior

No response

Regression?

No response

Known Workarounds

No response

Version

8.0.5

User Interface

Angular

Database Provider

EF Core (Default)

Tiered or separate authentication server

Tiered

Operation System

Linux

Other information

No response

@choby choby added the bug label Apr 27, 2024
@choby
Copy link
Author

choby commented Apr 30, 2024

Applications often make errors after a recent upgrade to.NET 8, I found that if I used tojson() to map jsonb fields, I encountered this problem when I manually enabled multiple UnitOfWorks, and I didn't encounter this problem when I fell back on the tojson() method to HasColumnType("jsonb"). Also note that I made an http request in the UnitOfWork:

Npgsql.NpgsqlException: Exception while writing to stream
---> System.IO.IOException: Unable to write data to the transport connection: Operation canceled.
---> System.Net.Sockets.SocketException: Operation canceled
at Npgsql.Internal.NpgsqlWriteBuffer.d__32.MoveNext() at offset 282
--- End of inner exception stack trace ---
at Npgsql.Internal.NpgsqlWriteBuffer.d__32.MoveNext() at offset 682
at Npgsql.NpgsqlCommand.<g__WriteExecute|100_0>d.MoveNext() at offset 1709
at Npgsql.NpgsqlCommand.d__119.MoveNext() at offset 1155
at Npgsql.NpgsqlCommand.d__107.MoveNext() at offset 146
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.d__14.MoveNext() at offset 779
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.d__17.MoveNext() at offset 279

When this error occurs, the database fails to log the error log most of the time, Occasionally, however, the following errors are recorded:
ERROR: SAVEPOINT can only be used in transaction blocks

And this problem seems to exist only in certain scenarios, for example, I run it perfectly in debug mode on my macbook, but I run it 3-4 times out of 10 on ubuntu

pgsql: 14
system: ubuntu 22.04
.net: 8.0
efcore 8.0
efcore.pg:8.0.2
abp:8.0.5

@choby choby changed the title An error issue when using both ToJson() and UpdateMany() methods An error issue when using both ToJson() and UpdateMany() methods or manually enabled multiple UnitOfWorks Apr 30, 2024
@maliming
Copy link
Member

maliming commented May 2, 2024

hi

This doesn't seem to be related to abp.

If you can reproduce this problem with some code or a simple project, Please share them,

Thanks.

@maliming maliming removed the bug label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants