pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wilm Hoyer <W.Hoyer@dental-vision.de>
To: Pavel Biryukov <79166341370@yandex.ru>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: AW: posgres 12 bug (partitioned table)
Date: Wed, 12 Aug 2020 09:35:04 +0000
Message-ID: <0765c3d6a42b4aa182febf866b5ab338@dental-vision.de> (raw)
In-Reply-To: <52371597219372@mail.yandex.ru>
References: <141051591267657@mail.yandex.ru>
	<1251598.1591289850@sss.pgh.pa.us>
	<CA+TgmoaN0kQa3nxToHtD8nRymSnUYaj4XL3zKq8Q_0AUJcQNPQ@mail.gmail.com>
	<3398357.1597160032@sss.pgh.pa.us>
	<1058041597161586@mail.yandex.ru>
	<20200811172241.izeyvksgevbtvhcd@alap3.anarazel.de>
	<24981597170121@mail.yandex.ru>
	<20200811183940.z6hvnu4uptkhugom@alap3.anarazel.de>
	<52371597219372@mail.yandex.ru>

Hi,

while the request for returning xmin of partitioned tables is still valid, i’d like to add some information and a possible workaround.

On 2020-08-11 21:31:52 +0300, Pavel Biryukov wrote:
 Entity Framework is an ORM for .Net (and .Net Core). It has different providers
 for different databases (NpgSql for Postgres). It uses Optimistic concurrency.
 The common use case is to use xmin as "concurrency token".

 In code we make "var e = new Entity();", "dbContext.Add(e)" and
 "dbContext.SaveChanges()" (smth like that), and EF Core constructs sql for us,
 classical ORM;

 When new row is inserted, EF makes an insert with "RETURNING xmin" to keep it
 as concurrency token for further updates (update is made like "where id = [id]
 AND xmin=[xmin]" to be sure the row hasn't been updated by other clients).

Neither the Entity Framework, nor npgsql rely on the column xmin. Both don’t know about this column in their codebase.
In the case oft he EF i’m sure that this holds true for all versions, since it is designed as DBMS independant, and as such will never know anything about a PostgreSQL specific column.
Also you can use any ADO.Net provider to connect to a concrete DBMS – i for example use dotConnect for PostgreSQL because it provided more features and less bugs as Npgsql at the time of  decission.
As for Npgsql i have only checked that the current HEAD has no reference to xmin in its source code.

With that in mind, i assume the OP included the column xmin in his Entity Model by himself and set the ConcurrencyMode to fixed for that column.
As xmin is a system column that the EF should never try to update (PostgreSQL will reject this attempt, i think), i’d suggest using a self defined column (row_version for example) and either use triggers on update and insert to increment its value (works even with updates outside of EF) or let the EF do the increment.

Regards
Wilm Hoyer.





view thread (3+ messages)  latest in thread

Message-ID: <0765c3d6a42b4aa182febf866b5ab338@dental-vision.de>
Permalink:  ../0765c3d6a42b4aa182febf866b5ab338@dental-vision.de/
Also on:    postgresql.org/message-id/0765c3d6a42b4aa182febf866b5ab338@dental-vision.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: W.Hoyer@dental-vision.de, 79166341370@yandex.ru, andres@anarazel.de, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: AW: posgres 12 bug (partitioned table)
  In-Reply-To: <0765c3d6a42b4aa182febf866b5ab338@dental-vision.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox