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

sql: add support for concurrency token column #108268

Closed
giangpham712 opened this issue Aug 7, 2023 · 5 comments
Closed

sql: add support for concurrency token column #108268

giangpham712 opened this issue Aug 7, 2023 · 5 comments
Labels
A-tools-efcore C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@giangpham712
Copy link

giangpham712 commented Aug 7, 2023

Is your feature request related to a problem? Please describe.
Entity Framework Core supports the concept of optimistic concurrency - a property on your entity is designated as a concurrency token, and EF Core detects concurrent modifications by checking whether that token has changed since the entity was read.

In PostgreSQL, the xmin holds the ID of the latest updating transaction. Since this value automatically gets updated every time the row is changed, it is ideal for use as a concurrency token.

https://www.npgsql.org/efcore/modeling/concurrency.html?tabs=data-annotations

This xmin column doesn't exist in CockroachDB

Additional context

This issue affects some tests in efcore.pg library

Jira issue: CRDB-30401

@giangpham712 giangpham712 added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Aug 7, 2023
@blathers-crl
Copy link

blathers-crl bot commented Aug 7, 2023

Hello, I am Blathers. I am here to help you get the issue triaged.

I was unable to automatically find someone to ping.

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-untriaged blathers was unable to find an owner labels Aug 7, 2023
@yuzefovich yuzefovich removed the X-blathers-untriaged blathers was unable to find an owner label Aug 7, 2023
@github-project-automation github-project-automation bot moved this to Triage in SQL Queries Aug 7, 2023
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Aug 7, 2023
@fqazi
Copy link
Collaborator

fqazi commented Aug 8, 2023

@giangpham712 Would crdb_internal_mvcc_timestamp be sufficient here? It's a timestamp each row has for when it was last modified. We can't support the full Postgres equivalent here, since it is leaky and specific to their implementation.

@rafiss
Copy link
Collaborator

rafiss commented Aug 9, 2023

Closing as a duplicate of #33296, but I don't think we will work on this soon.

@rafiss rafiss closed this as completed Aug 9, 2023
@github-project-automation github-project-automation bot moved this from Triage to Done in SQL Queries Aug 9, 2023
@giangpham712
Copy link
Author

@fqazi There are several challenges with using crdb_internal_mvcc_timestamp.

One issue I'm having right now is this SQL

INSERT INTO "Owners" ("Id", "Name")
VALUES ('GIANG', 'Giang')
RETURNING crdb_internal_mvcc_timestamp;

is returning error column "crdb_internal_mvcc_timestamp" does not exist

@fqazi
Copy link
Collaborator

fqazi commented Aug 17, 2023

@giangpham712 So, we can get equivalent behaviour by using SHOW COMMIT TIMESTAMP or cluster_logical_timestamp(). The first option is preferred because of performance reasons. See: #79591

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tools-efcore C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
Archived in project
Development

No branches or pull requests

4 participants