{"id":352840,"date":"2024-05-20T22:16:20","date_gmt":"2024-05-20T22:16:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=352840"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=352840","title":{"rendered":"<span>Repeatable Read \u0438\u043b\u0438 \u043a\u0430\u043a \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435 \u0432 Postgresql<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0440\u043e\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e <em>\u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435<\/em> (read skew) \u0432 postgresql, \u0438 \u043a\u0430\u043a \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 Repeatable Read \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e.<\/p>\n<h2>\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445. \u041f\u0443\u0441\u0442\u044c \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <em>users<\/em>.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">id<\/p>\n<\/td>\n<td>\n<p align=\"left\">name<\/p>\n<\/td>\n<td>\n<p align=\"left\">active<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">Alex<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2<\/p>\n<\/td>\n<td>\n<p align=\"left\">Sam<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">Felix<\/p>\n<\/td>\n<td>\n<p align=\"left\">false<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <em>printer<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 (active=true) \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <em>users<\/em> \u0438 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e.<\/p>\n<pre><code>~$ printer 1 Alex 2 Sam total:  2<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, <em>printer<\/em> \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 postgresql.<\/p>\n<pre><code>begin;  select id, name from users where active = true order by id;  id | name   ----+-------   1 | Alex   2 | Sam  select count(*) from users where active = true;  count  -------      2  commit;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <em>virus<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0440\u0443\u0448\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0443\u0442\u0438\u043b\u0438\u0442\u044b <em>printer<\/em>. \u0412\u0441\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c <em>virus<\/em>, &#8212; \u044d\u0442\u043e \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432 postgresql \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<pre><code>update users set active = not active where id = 3;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <em>printer<\/em>, \u043f\u043e\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <em>virus<\/em>, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code>~$ printer 1 Alex 2 Sam 3 Felix total:  2<\/code><\/pre>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0430\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443. \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u043b sql-\u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442 <em>virus<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 &#171;\u0432\u043a\u043b\u0438\u043d\u0438\u043b\u0441\u044f&#187; \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f sql-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 <em>printer<\/em> \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u043b \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<pre><code>printer                           virus  begin;  select id, name from users where active = true order by id;  id | name   ----+-------   1 | Alex   2 | Sam   3 | Felix                                    update users set active = not active                                   where id = 3;  select count(*) from users where active = true;  count  -------      2  commit;<\/code><\/pre>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u0430 <em>printer<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 Read Committed (\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435) &#8212; \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 postgresql, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e <code>begin<\/code>. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em>. \u0423\u0442\u0438\u043b\u0438\u0442\u0430 <em>printer<\/em> \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0430 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 <em>virus<\/em>. \u0414\u0430, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438: \u0435\u0441\u043b\u0438 \u044f\u0432\u043d\u043e \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>begin<\/code>\/<code>commit<\/code>, \u0442\u043e postgresql \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u0440\u0430\u043c\u043a\u0438 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043e\u0442 <em>virus<\/em> postgresql \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code>begin;  update users set active = not active where id = 3;  commit;<\/code><\/pre>\n<h2>\u0423\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Repeatable Read<\/h2>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Repeatable Read. \u041f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0438 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0447\u0442\u0435\u043d\u0438\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e, \u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430 <em>virus<\/em> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432 \u0441\u0438\u043b\u0430\u0445 \u043f\u043e\u043c\u0435\u0448\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 <em>printer<\/em>.<\/p>\n<pre><code>begin isolation level repeatable read;<\/code><\/pre>\n<p>\u041a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u043c? \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u0432\u0438\u0434\u044f\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <em>users<\/em> \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em> \u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>virus<\/em>. \u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430, \u043d\u0443\u0436\u043d\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0430 \u043f\u043e\u043d\u044f\u0442\u0438\u044f postgresql:<\/p>\n<ul>\n<li>\n<p>\u043d\u043e\u043c\u0435\u0440 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 postgresql \u0432\u044b\u0434\u0430\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440. \u042d\u0442\u043e\u0442 \u043d\u043e\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0432\u044b\u0437\u0432\u0430\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e pg_current_xact_id.<\/p>\n<pre><code>begin;  select pg_current_xact_id();  pg_current_xact_id  --------------------                 1043  commit;<\/code><\/pre>\n<p>\u0421\u0442\u0440\u043e\u043a\u0430 \u0432 postgresql &#8212; \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u0435. \u0424\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 postgresql \u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a. \u041a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0440\u0441\u0438\u0439. \u041f\u0440\u0438\u0447\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 &#8212; \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u0438\u0434\u043d\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: xmin \u0438 xmax. \u042d\u0442\u0438 \u043f\u043e\u043b\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043d\u0435 \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e <code>select *<\/code>. \u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u043f\u043e\u043b\u044f, \u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<pre><code>select *, xmin, xmax from users;<\/code><\/pre>\n<p>\u0412 \u043f\u043e\u043b\u0435 xmin \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u0432\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438. \u0412 \u043f\u043e\u043b\u0435 xmax \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0443\u0434\u0430\u043b\u0438\u0432\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u043b\u044f xmax. \u0412\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0430\u044f, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 &#8212; \u0435\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0433\u0443\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u0442\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044d\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u044b\u043b\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0430.<\/p>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0443. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c Repeatable Read \u0434\u043b\u044f \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 <em>printer<\/em>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0441\u0442\u0440\u043e\u043a:<\/p>\n<ul>\n<li>\n<p>xmin (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c tx_created);<\/p>\n<\/li>\n<li>\n<p>xmax (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c tx_deleted).<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<pre><code>begin;  select pg_current_xact_id();  pg_current_xact_id  --------------------                 742  insert into users (id, name, active) values  (1, 'Alex', true),  (2, 'Sam', true),  (3, 'Felix', true);  commit;<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 <em>printer<\/em> \u0438 <em>virus<\/em>.<\/p>\n<pre><code>printer                                             virus  begin isolation level repeatable read;  select pg_current_xact_id();  pg_current_xact_id  --------------------                 743  select id, name, active,   xmin as tx_created,    xmax as tx_deleted  from users order by id;  id | name  | active | tx_created | tx_deleted  ----+-------+--------+------------+------------   1 | Alex  | t      |        742 |          0   2 | Sam   | t      |        742 |          0   3 | Felix | t      |        742 |          0                                                       begin;                                                       select pg_current_xact_id();                                                       pg_current_xact_id                                                       --------------------                                                                      744                                                                                                            update users set active = not active                                                      where id = 3;                                                                                                            select id, name, active,                                                        xmin as tx_created,                                                         xmax as tx_deleted                                                       from users                                                      order by id;                                                       id | name  | active | tx_created | tx_deleted                                                       ----+-------+--------+------------+------------                                                        1 | Alex  | t      |        742 |          0                                                        2 | Sam   | t      |        742 |          0                                                        3 | Felix | f      |        744 |          0                                                                                                            commit;  select id, name, active,   xmin as tx_created,    xmax as tx_deleted  from users order by id;  id | name  | active | tx_created | tx_deleted  ----+-------+--------+------------+------------   1 | Alex  | t      |        742 |          0   2 | Sam   | t      |        742 |          0   3 | Felix | t      |        742 |        744  commit;<\/code><\/pre>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code>update<\/code> \u043e\u0442\u043c\u0435\u0442\u0438\u043b\u0430 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c Felix \u0438 \u043f\u043e\u043b\u0435\u043c active=true \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0443\u044e \u0441\u0432\u043e\u0435\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 active=false. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c Felix \u0446\u0435\u043b\u044b\u0445 \u0434\u0432\u0435 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">id<\/p>\n<\/td>\n<td>\n<p align=\"left\">name<\/p>\n<\/td>\n<td>\n<p align=\"left\">active<\/p>\n<\/td>\n<td>\n<p align=\"left\">tx_created<\/p>\n<\/td>\n<td>\n<p align=\"left\">tx_deleted<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">Alex<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<td>\n<p align=\"left\">742<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td>\n<p align=\"left\">Sam<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<td>\n<p align=\"left\">742<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">Felix<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<td>\n<p align=\"left\">742<\/p>\n<\/td>\n<td>\n<p align=\"left\">744<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">Felix<\/p>\n<\/td>\n<td>\n<p align=\"left\">false<\/p>\n<\/td>\n<td>\n<p align=\"left\">744<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em> \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Repeatable Read \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 (<code>commit<\/code>) \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e <code>select<\/code>. \u0421\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u0438\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u0441\u043d\u0438\u043c\u043a\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445<\/em> (snapshot). \u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c Repeatable Read \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0434\u0438\u043d \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u0440\u0430\u0437 \u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 <em>users<\/em> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u0431 \u044d\u0442\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 Repeatable Read (\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e).<\/p>\n<p>\u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em> \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Read Committed \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e <code>select<\/code>. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em> \u043f\u043e\u0441\u043b\u0435 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 <em>virus<\/em> \u0432\u0438\u0434\u0438\u0442 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c Felix &#8212; \u044d\u0442\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043d\u0438\u043c\u043a\u0430.<\/p>\n<p>\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/441\/ddc\/803\/441ddc803c96f001213193b176ef7d07.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043d\u0438\u043c\u043a\u043e\u0432\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043d\u0438\u043c\u043a\u043e\u0432\" width=\"591\" height=\"469\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/441\/ddc\/803\/441ddc803c96f001213193b176ef7d07.png\"\/><\/p>\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043d\u0438\u043c\u043a\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f 742 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u0440\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <em>users<\/em>, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f 743 &#8212; \u0447\u0438\u0442\u0430\u044e\u0449\u0430\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em>. \u0412 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 744 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>update<\/code> \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c Felix \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0443\u044e \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Repeatable Read \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e <em>\u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435<\/em>, \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0435\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 Read Committed, \u043b\u0438\u0431\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0432 \u0440\u0430\u043c\u043a\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439. Repeatable Read &#8212; \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 postgresql.<\/p>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: \u0443\u0442\u0438\u043b\u0438\u0442\u0430 <em>printer<\/em> \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 <code>select count(*)<\/code>, \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0435\u0440\u043d\u0443\u043b \u043f\u0435\u0440\u0432\u044b\u0439 <code>select<\/code>. \u042d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u0441\u0442\u0440\u043e\u043a &#8212; \u0442\u043e\u0436\u0435 \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0423 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 &#8212; \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435.<\/p>\n<h2>\u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432<\/h2>\n<p>\u0412\u0441\u0435 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0435\u0433\u043e \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0435 \u0434\u0430\u0435\u0442 \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445 postgresql.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0433\u043b\u0443\u0431\u0436\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u043d\u0438\u0433\u043e\u0439 <a href=\"https:\/\/postgrespro.ru\/education\/books\/internals\" rel=\"noopener noreferrer nofollow\">PostgreSQL 15 \u0438\u0437\u043d\u0443\u0442\u0440\u0438<\/a>. \u0412\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0433\u043b\u0430\u0432 \u0438\u0437 \u044d\u0442\u043e\u0439 \u043a\u043d\u0438\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0441\u0442\u0430\u0442\u044c\u0435\u0439:<\/p>\n<ul>\n<li>\n<p>\u0413\u043b\u0430\u0432\u0430 2. \u0418\u0437\u043e\u043b\u044f\u0446\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0413\u043b\u0430\u0432\u0430 4. \u0421\u043d\u0438\u043c\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0441\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 postgresql \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/postgres\/postgres\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435<\/a>. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/postgres\/postgres\/blob\/1bc19dfcfea71e7ed03eff9d72072579bd678b4c\/src\/backend\/utils\/time\/snapmgr.c#L250\" rel=\"noopener noreferrer nofollow\"> GetTransactionSnapshot<\/a> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043d\u0438\u043c\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 docker-compose.yml \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/gitlab.com\/sim6a-articles\/read-skew-postgresql\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/756202\/\"> https:\/\/habr.com\/ru\/articles\/756202\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0440\u043e\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e <em>\u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435<\/em> (read skew) \u0432 postgresql, \u0438 \u043a\u0430\u043a \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 Repeatable Read \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e.<\/p>\n<h2>\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445. \u041f\u0443\u0441\u0442\u044c \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <em>users<\/em>.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">id<\/p>\n<\/td>\n<td>\n<p align=\"left\">name<\/p>\n<\/td>\n<td>\n<p align=\"left\">active<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">Alex<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2<\/p>\n<\/td>\n<td>\n<p align=\"left\">Sam<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">Felix<\/p>\n<\/td>\n<td>\n<p align=\"left\">false<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <em>printer<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 (active=true) \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <em>users<\/em> \u0438 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e.<\/p>\n<pre><code>~$ printer 1 Alex 2 Sam total:  2<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, <em>printer<\/em> \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 postgresql.<\/p>\n<pre><code>begin;  select id, name from users where active = true order by id;  id | name   ----+-------   1 | Alex   2 | Sam  select count(*) from users where active = true;  count  -------      2  commit;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <em>virus<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0440\u0443\u0448\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0443\u0442\u0438\u043b\u0438\u0442\u044b <em>printer<\/em>. \u0412\u0441\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c <em>virus<\/em>, &#8212; \u044d\u0442\u043e \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432 postgresql \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<pre><code>update users set active = not active where id = 3;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <em>printer<\/em>, \u043f\u043e\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <em>virus<\/em>, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code>~$ printer 1 Alex 2 Sam 3 Felix total:  2<\/code><\/pre>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0430\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443. \u042d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u043b sql-\u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442 <em>virus<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 &#171;\u0432\u043a\u043b\u0438\u043d\u0438\u043b\u0441\u044f&#187; \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f sql-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 <em>printer<\/em> \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u043b \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<pre><code>printer                           virus  begin;  select id, name from users where active = true order by id;  id | name   ----+-------   1 | Alex   2 | Sam   3 | Felix                                    update users set active = not active                                   where id = 3;  select count(*) from users where active = true;  count  -------      2  commit;<\/code><\/pre>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u0430 <em>printer<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 Read Committed (\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435) &#8212; \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 postgresql, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e <code>begin<\/code>. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em>. \u0423\u0442\u0438\u043b\u0438\u0442\u0430 <em>printer<\/em> \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0430 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 <em>virus<\/em>. \u0414\u0430, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438: \u0435\u0441\u043b\u0438 \u044f\u0432\u043d\u043e \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>begin<\/code>\/<code>commit<\/code>, \u0442\u043e postgresql \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u0440\u0430\u043c\u043a\u0438 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043e\u0442 <em>virus<\/em> postgresql \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code>begin;  update users set active = not active where id = 3;  commit;<\/code><\/pre>\n<h2>\u0423\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Repeatable Read<\/h2>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Repeatable Read. \u041f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0438 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0447\u0442\u0435\u043d\u0438\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e, \u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430 <em>virus<\/em> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432 \u0441\u0438\u043b\u0430\u0445 \u043f\u043e\u043c\u0435\u0448\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 <em>printer<\/em>.<\/p>\n<pre><code>begin isolation level repeatable read;<\/code><\/pre>\n<p>\u041a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u043c? \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u0432\u0438\u0434\u044f\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <em>users<\/em> \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em> \u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>virus<\/em>. \u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430, \u043d\u0443\u0436\u043d\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0430 \u043f\u043e\u043d\u044f\u0442\u0438\u044f postgresql:<\/p>\n<ul>\n<li>\n<p>\u043d\u043e\u043c\u0435\u0440 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 postgresql \u0432\u044b\u0434\u0430\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440. \u042d\u0442\u043e\u0442 \u043d\u043e\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0432\u044b\u0437\u0432\u0430\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e pg_current_xact_id.<\/p>\n<pre><code>begin;  select pg_current_xact_id();  pg_current_xact_id  --------------------                 1043  commit;<\/code><\/pre>\n<p>\u0421\u0442\u0440\u043e\u043a\u0430 \u0432 postgresql &#8212; \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u0435. \u0424\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 postgresql \u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a. \u041a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0440\u0441\u0438\u0439. \u041f\u0440\u0438\u0447\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 &#8212; \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u0438\u0434\u043d\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: xmin \u0438 xmax. \u042d\u0442\u0438 \u043f\u043e\u043b\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043d\u0435 \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e <code>select *<\/code>. \u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u043f\u043e\u043b\u044f, \u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<pre><code>select *, xmin, xmax from users;<\/code><\/pre>\n<p>\u0412 \u043f\u043e\u043b\u0435 xmin \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u0432\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438. \u0412 \u043f\u043e\u043b\u0435 xmax \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0443\u0434\u0430\u043b\u0438\u0432\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u043b\u044f xmax. \u0412\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0430\u044f, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 &#8212; \u0435\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0433\u0443\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u0442\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044d\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u044b\u043b\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0430.<\/p>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0443. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c Repeatable Read \u0434\u043b\u044f \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 <em>printer<\/em>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0441\u0442\u0440\u043e\u043a:<\/p>\n<ul>\n<li>\n<p>xmin (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c tx_created);<\/p>\n<\/li>\n<li>\n<p>xmax (\u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c tx_deleted).<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<pre><code>begin;  select pg_current_xact_id();  pg_current_xact_id  --------------------                 742  insert into users (id, name, active) values  (1, 'Alex', true),  (2, 'Sam', true),  (3, 'Felix', true);  commit;<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 <em>printer<\/em> \u0438 <em>virus<\/em>.<\/p>\n<pre><code>printer                                             virus  begin isolation level repeatable read;  select pg_current_xact_id();  pg_current_xact_id  --------------------                 743  select id, name, active,   xmin as tx_created,    xmax as tx_deleted  from users order by id;  id | name  | active | tx_created | tx_deleted  ----+-------+--------+------------+------------   1 | Alex  | t      |        742 |          0   2 | Sam   | t      |        742 |          0   3 | Felix | t      |        742 |          0                                                       begin;                                                       select pg_current_xact_id();                                                       pg_current_xact_id                                                       --------------------                                                                      744                                                                                                            update users set active = not active                                                      where id = 3;                                                                                                            select id, name, active,                                                        xmin as tx_created,                                                         xmax as tx_deleted                                                       from users                                                      order by id;                                                       id | name  | active | tx_created | tx_deleted                                                       ----+-------+--------+------------+------------                                                        1 | Alex  | t      |        742 |          0                                                        2 | Sam   | t      |        742 |          0                                                        3 | Felix | f      |        744 |          0                                                                                                            commit;  select id, name, active,   xmin as tx_created,    xmax as tx_deleted  from users order by id;  id | name  | active | tx_created | tx_deleted  ----+-------+--------+------------+------------   1 | Alex  | t      |        742 |          0   2 | Sam   | t      |        742 |          0   3 | Felix | t      |        742 |        744  commit;<\/code><\/pre>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code>update<\/code> \u043e\u0442\u043c\u0435\u0442\u0438\u043b\u0430 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c Felix \u0438 \u043f\u043e\u043b\u0435\u043c active=true \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0443\u044e \u0441\u0432\u043e\u0435\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 active=false. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c Felix \u0446\u0435\u043b\u044b\u0445 \u0434\u0432\u0435 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">id<\/p>\n<\/td>\n<td>\n<p align=\"left\">name<\/p>\n<\/td>\n<td>\n<p align=\"left\">active<\/p>\n<\/td>\n<td>\n<p align=\"left\">tx_created<\/p>\n<\/td>\n<td>\n<p align=\"left\">tx_deleted<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">Alex<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<td>\n<p align=\"left\">742<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td>\n<p align=\"left\">Sam<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<td>\n<p align=\"left\">742<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">Felix<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<td>\n<p align=\"left\">742<\/p>\n<\/td>\n<td>\n<p align=\"left\">744<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">Felix<\/p>\n<\/td>\n<td>\n<p align=\"left\">false<\/p>\n<\/td>\n<td>\n<p align=\"left\">744<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em> \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Repeatable Read \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 (<code>commit<\/code>) \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e <code>select<\/code>. \u0421\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u0438\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u0441\u043d\u0438\u043c\u043a\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445<\/em> (snapshot). \u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c Repeatable Read \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0434\u0438\u043d \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u0440\u0430\u0437 \u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 <em>users<\/em> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u0431 \u044d\u0442\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 Repeatable Read (\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e).<\/p>\n<p>\u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em> \u0441 \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Read Committed \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e <code>select<\/code>. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em> \u043f\u043e\u0441\u043b\u0435 \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 <em>virus<\/em> \u0432\u0438\u0434\u0438\u0442 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c Felix &#8212; \u044d\u0442\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043d\u0438\u043c\u043a\u0430.<\/p>\n<p>\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043d\u0438\u043c\u043a\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f 742 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u0440\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <em>users<\/em>, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f 743 &#8212; \u0447\u0438\u0442\u0430\u044e\u0449\u0430\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f <em>printer<\/em>. \u0412 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 744 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>update<\/code> \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c Felix \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0443\u044e \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Repeatable Read \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044e <em>\u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435<\/em>, \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0435\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 Read Committed, \u043b\u0438\u0431\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0432 \u0440\u0430\u043c\u043a\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439. Repeatable Read &#8212; \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 postgresql.<\/p>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: \u0443\u0442\u0438\u043b\u0438\u0442\u0430 <em>printer<\/em> \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 <code>select count(*)<\/code>, \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0435\u0440\u043d\u0443\u043b \u043f\u0435\u0440\u0432\u044b\u0439 <code>select<\/code>. \u042d\u0442\u043e\u0442 \u043d\u0430\u0431\u043e\u0440 \u0441\u0442\u0440\u043e\u043a &#8212; \u0442\u043e\u0436\u0435 \u0441\u043d\u0438\u043c\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0423 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 &#8212; \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435.<\/p>\n<h2>\u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432<\/h2>\n<p>\u0412\u0441\u0435 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0435\u0433\u043e \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0435 \u0434\u0430\u0435\u0442 \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445 postgresql.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0433\u043b\u0443\u0431\u0436\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u043d\u0438\u0433\u043e\u0439 <a href=\"https:\/\/postgrespro.ru\/education\/books\/internals\" rel=\"noopener noreferrer nofollow\">PostgreSQL 15 \u0438\u0437\u043d\u0443\u0442\u0440\u0438<\/a>. \u0412\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0433\u043b\u0430\u0432 \u0438\u0437 \u044d\u0442\u043e\u0439 \u043a\u043d\u0438\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0441\u0442\u0430\u0442\u044c\u0435\u0439:<\/p>\n<ul>\n<li>\n<p>\u0413\u043b\u0430\u0432\u0430 2. \u0418\u0437\u043e\u043b\u044f\u0446\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0413\u043b\u0430\u0432\u0430 4. \u0421\u043d\u0438\u043c\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0441\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 postgresql \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/postgres\/postgres\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435<\/a>. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/github.com\/postgres\/postgres\/blob\/1bc19dfcfea71e7ed03eff9d72072579bd678b4c\/src\/backend\/utils\/time\/snapmgr.c#L250\" rel=\"noopener noreferrer nofollow\"> GetTransactionSnapshot<\/a> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-352840","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=352840"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352840\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=352840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=352840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=352840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}