Open Closed

Is there a known issue regarding ConcurrencyStamp and Postgresql ? #7865


User avatar
1
shreddersgr1 created
  • ABP Framework version: v8.3.0
  • UI Type: Blazor WASM
  • Database System: EF Core (PostgreSQL)
  • Exception message and full stack trace: none
  • Steps to reproduce the issue:

Hello, I'm having an issue regarding concurrencychecks and Postgres.

This is the current table values:

All these values are being generated correctly on creation because of the following code in AggregateRoot.cs (which is our base class)

This method configures the ConcurrencyStamp property as a ConcurrencyToken

What this does, is that when we update an entity, we must provide the same ConcurrencyStamp as defined in the database which works perfectly. When we don't pass the good concurrencystamp it **crashes **as expected.


The problem arises when we update any entity or aggregate.

The save method does not update the concurrencystamp in the database (autosave : true or not).

It just always returns the **same **concurrencystamp everytime. (The one that was created on entity creation).

Is that a known issue with postgres. What are the recommendations?

Thanks


4 Answer(s)
  • User Avatar
    0
    shreddersgr1 created

    related post that didn't help : https://abp.io/support/questions/6564/Updated-conncurrencyStamp-not-returned-on-updates

    I found we can map a uInt value to track concurrency on npgsql website https://www.npgsql.org/efcore/modeling/concurrency.html?tabs=fluent-api But this is very hard to implement given the abp framework forces us to use a string for concurrency checks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share your full update entity code? I will try to reproduce it.

    Thanks.

  • User Avatar
    0
    shreddersgr1 created

    I'm sorry for the mis reproduction on my part. Everything seems fine finally. It was a matter of checking all automappers. :(

    This code works fine directly from the abp framework:

    var entity = entry.Entity as IHasConcurrencyStamp;
    if (entity == null)
    {
        return;
    }
    
    Entry(entity).Property(x => x.ConcurrencyStamp).OriginalValue = entity.ConcurrencyStamp;
    entity.ConcurrencyStamp = Guid.NewGuid().ToString("N");
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great : )

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11