agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedPatch for Postmaster Uptime (from the TODO)
6+ messages / 4 participants
[nested] [flat]
* Patch for Postmaster Uptime (from the TODO)
@ 2005-02-24 22:49 Eric Crampton <escpg@eonomine.com>
0 siblings, 1 reply; 6+ messages in thread
From: Eric Crampton @ 2005-02-24 22:49 UTC (permalink / raw)
To: pgsql-patches@postgresql.org
Hello hackers,
I noticed in the TODO that there is an item requesting a function which
returns the uptime of the postmaster. I've wanted that as well. So, I've
added just such a thing: server_start_time(). This function returns the
time when the postmaster was started; a simple now() - server_start_time()
returns the uptime.
The below patches are for four files:
* postmaster.c: Now calls a new function, MarkServerStartTime(), before
calling ServerLoop().
* timestamp.h/timestamp.c: New functions: MarkServerStartTime() (called
from postmaster.c) and server_start_time(), a new SQL function which may
be called.
* pg_proc.h: Added DATA and DESCR to the very end of the list (OID=2557)
for the server_start_time function.
I didn't bother to include the generated fmgroids.h and fmgrtab.c. Since
they are small, I've attached the four unified diffs against the 8.0.1
code. Let me know if there's anything different the code should have done.
--Eric
Attachments:
[application/octet-stream] pg_proc.h.diff (610B, ../../39796.207.171.180.101.1109285340.spork@webmail.eonomine.com/2-pg_proc.h.diff)
download | inline diff:
--- postgresql-8.0.1/src/include/catalog/pg_proc.h Fri Dec 31 14:03:25 2004
+++ patched-postgresql-8.0.1/src/include/catalog/pg_proc.h Thu Feb 24 08:37:57 2005
@@ -3604,6 +3604,9 @@
DATA(insert OID = 2556 ( pg_tablespace_databases PGNSP PGUID 12 f f t t s 1 26 "26" _null_ pg_tablespace_databases - _null_));
DESCR("returns database oids in a tablespace");
+DATA(insert OID = 2557 ( server_start_time PGNSP PGUID 12 f f t f s 0 1184 "" _null_ server_start_time - _null_ ));
+DESCR("time when the server started");
+
/*
* Symbolic values for provolatile column: these indicate whether the result
[application/octet-stream] postmaster.c.diff (338B, ../../39796.207.171.180.101.1109285340.spork@webmail.eonomine.com/3-postmaster.c.diff)
download | inline diff:
--- postgresql-8.0.1/src/backend/postmaster/postmaster.c Wed Jan 12 08:38:17 2005
+++ patched-postgresql-8.0.1/src/backend/postmaster/postmaster.c Thu Feb 24 08:20:46 2005
@@ -915,6 +915,11 @@
*/
StartupPID = StartupDataBase();
+ /*
+ * Set the server start time.
+ */
+ MarkServerStartTime();
+
status = ServerLoop();
/*
[application/octet-stream] timestamp.c.diff (1.2K, ../../39796.207.171.180.101.1109285340.spork@webmail.eonomine.com/4-timestamp.c.diff)
download | inline diff:
--- postgresql-8.0.1/src/backend/utils/adt/timestamp.c Fri Dec 31 14:01:22 2004
+++ patched-postgresql-8.0.1/src/backend/utils/adt/timestamp.c Thu Feb 24 14:04:12 2005
@@ -50,6 +50,11 @@
static void AdjustIntervalForTypmod(Interval *interval, int32 typmod);
static TimestampTz timestamp2timestamptz(Timestamp timestamp);
+/*
+ * Set by MarkServerStartTime().
+ */
+static AbsoluteTime serverStartTime = 0;
+static int serverStartTimeUsec = 0;
/*****************************************************************************
* USER I/O ROUTINES *
@@ -941,6 +946,28 @@
PG_RETURN_TIMESTAMPTZ(result);
}
+/* MarkServerStartTime()
+ * Marks the time of server startup.
+ */
+void
+MarkServerStartTime(void)
+{
+ serverStartTime = GetCurrentAbsoluteTimeUsec(&(serverStartTimeUsec));
+}
+
+/* server_start_time()
+ * Returns the time when the server was started.
+ */
+Datum
+server_start_time(PG_FUNCTION_ARGS)
+{
+ TimestampTz result;
+
+ result = AbsoluteTimeUsecToTimestampTz(serverStartTime, serverStartTimeUsec);
+
+ PG_RETURN_TIMESTAMPTZ(result);
+}
+
void
dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
{
@@ -4002,3 +4029,4 @@
PG_RETURN_TIMESTAMP(result);
} /* timestamptz_izone() */
+
[application/octet-stream] timestamp.h.diff (411B, ../../39796.207.171.180.101.1109285340.spork@webmail.eonomine.com/5-timestamp.h.diff)
download | inline diff:
--- postgresql-8.0.1/src/include/utils/timestamp.h Fri Dec 31 14:03:46 2004
+++ patched-postgresql-8.0.1/src/include/utils/timestamp.h Thu Feb 24 08:19:46 2005
@@ -248,6 +248,9 @@
extern Datum timestamptz_part(PG_FUNCTION_ARGS);
extern Datum now(PG_FUNCTION_ARGS);
+extern void MarkServerStartTime(void);
+extern Datum server_start_time(PG_FUNCTION_ARGS);
+
/* Internal routines (not fmgr-callable) */
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Patch for Postmaster Uptime (from the TODO)
@ 2005-02-25 01:38 Tom Lane <tgl@sss.pgh.pa.us>
parent: Eric Crampton <escpg@eonomine.com>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2005-02-25 01:38 UTC (permalink / raw)
To: escpg@eonomine.com; +Cc: pgsql-patches@postgresql.org
"Eric Crampton" <escpg@eonomine.com> writes:
> I noticed in the TODO that there is an item requesting a function which
> returns the uptime of the postmaster. I've wanted that as well. So, I've
> added just such a thing: server_start_time(). This function returns the
> time when the postmaster was started; a simple now() - server_start_time()
> returns the uptime.
Isn't there one of these in the patch queue already?
The patch as given won't work on Windows, because it depends on fork
inheritance of the value. I think the previous patcher fixed that.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Patch for Postmaster Uptime (from the TODO)
@ 2005-02-25 02:48 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 6+ messages in thread
From: Bruce Momjian @ 2005-02-25 02:48 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: escpg@eonomine.com; pgsql-patches@postgresql.org
Tom Lane wrote:
> "Eric Crampton" <escpg@eonomine.com> writes:
> > I noticed in the TODO that there is an item requesting a function which
> > returns the uptime of the postmaster. I've wanted that as well. So, I've
> > added just such a thing: server_start_time(). This function returns the
> > time when the postmaster was started; a simple now() - server_start_time()
> > returns the uptime.
>
> Isn't there one of these in the patch queue already?
Yes.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 6+ messages in thread
* [PATCH 2/2] Stop demanding that top xact must be seen before subxact in decoding.
@ 2019-10-23 12:56 Arseny Sher <sher-ars@yandex.ru>
0 siblings, 0 replies; 6+ messages in thread
From: Arseny Sher @ 2019-10-23 12:56 UTC (permalink / raw)
Manifested as
ERROR: subtransaction logged without previous top-level txn record
this check forbids legit behaviours like
- First xl_xact_assignment record is beyond reading, i.e. earlier
restart_lsn.
- After restart_lsn there is some change of a subxact.
- After that, there is second xl_xact_assignment (for another subxact)
revealing relationship between top and first subxact.
Such transaction won't be streamed anyway because we hadn't seen it in full;
confirmed_flush_lsn must be past all these records. Saying for sure whether xact
of some record encountered after snapshot was deserialized can be streamed or
not requires to know whether it wrote something before deserialization point --
if yes, it hasn't been seen in full and can't be decoded. Snapshot doesn't have
such info, so there is no easy way to relax the check.
---
src/backend/replication/logical/reorderbuffer.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 8ce28ad629..6faba6077e 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -778,9 +778,6 @@ ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid,
txn = ReorderBufferTXNByXid(rb, xid, true, &new_top, lsn, true);
subtxn = ReorderBufferTXNByXid(rb, subxid, true, &new_sub, lsn, false);
- if (new_top && !new_sub)
- elog(ERROR, "subtransaction logged without previous top-level txn record");
-
if (!new_sub)
{
if (subtxn->is_known_as_subxact)
--
2.11.0
--=-=-=
Content-Type: text/plain
--
Arseny Sher
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
--=-=-=--
^ permalink raw reply [nested|flat] 6+ messages in thread
* [PATCH 2/2] Stop demanding that top xact must be seen before subxact in decoding.
@ 2019-10-23 12:56 Arseny Sher <sher-ars@yandex.ru>
0 siblings, 0 replies; 6+ messages in thread
From: Arseny Sher @ 2019-10-23 12:56 UTC (permalink / raw)
Manifested as
ERROR: subtransaction logged without previous top-level txn record
this check forbids legit behaviours like
- First xl_xact_assignment record is beyond reading, i.e. earlier
restart_lsn.
- After restart_lsn there is some change of a subxact.
- After that, there is second xl_xact_assignment (for another subxact)
revealing relationship between top and first subxact.
Such transaction won't be streamed anyway because we hadn't seen it in full;
confirmed_flush_lsn must be past all these records. Saying for sure whether xact
of some record encountered after snapshot was deserialized can be streamed or
not requires to know whether it wrote something before deserialization point --
if yes, it hasn't been seen in full and can't be decoded. Snapshot doesn't have
such info, so there is no easy way to relax the check.
---
contrib/test_decoding/Makefile | 2 +-
.../test_decoding/expected/subxact_without_top.out | 40 +++++++++++++
.../test_decoding/specs/subxact_without_top.spec | 65 ++++++++++++++++++++++
src/backend/replication/logical/reorderbuffer.c | 3 -
4 files changed, 106 insertions(+), 4 deletions(-)
create mode 100644 contrib/test_decoding/expected/subxact_without_top.out
create mode 100644 contrib/test_decoding/specs/subxact_without_top.spec
diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile
index 4afb1d963e..f439c582a5 100644
--- a/contrib/test_decoding/Makefile
+++ b/contrib/test_decoding/Makefile
@@ -7,7 +7,7 @@ REGRESS = ddl xact rewrite toast permissions decoding_in_xact \
decoding_into_rel binary prepared replorigin time messages \
spill slot truncate
ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \
- oldest_xmin snapshot_transfer
+ oldest_xmin snapshot_transfer subxact_without_top
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/test_decoding/logical.conf
ISOLATION_OPTS = --temp-config $(top_srcdir)/contrib/test_decoding/logical.conf
diff --git a/contrib/test_decoding/expected/subxact_without_top.out b/contrib/test_decoding/expected/subxact_without_top.out
new file mode 100644
index 0000000000..357e0fd964
--- /dev/null
+++ b/contrib/test_decoding/expected/subxact_without_top.out
@@ -0,0 +1,40 @@
+Parsed test spec with 3 sessions
+
+starting permutation: s0_begin s0_first_subxact s2_checkpoint s1_begin s1_dml s0_many_subxacts s0_commit s2_checkpoint s2_get_changes_suppress_output s1_commit s2_get_changes
+step s0_begin: BEGIN;
+step s0_first_subxact:
+ DO LANGUAGE plpgsql $$
+ BEGIN
+ BEGIN
+ INSERT INTO harvest VALUES (41);
+ EXCEPTION WHEN OTHERS THEN RAISE;
+ END;
+ END $$;
+
+step s2_checkpoint: CHECKPOINT;
+step s1_begin: BEGIN;
+step s1_dml: INSERT INTO harvest VALUES (43);
+step s0_many_subxacts: select subxacts();
+subxacts
+
+
+step s0_commit: COMMIT;
+step s2_checkpoint: CHECKPOINT;
+step s2_get_changes_suppress_output: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1') LIMIT 5;
+data
+
+BEGIN
+table public.harvest: INSERT: apples[integer]:41
+table public.harvest: INSERT: apples[integer]:42
+table public.harvest: INSERT: apples[integer]:42
+table public.harvest: INSERT: apples[integer]:42
+step s1_commit: COMMIT;
+step s2_get_changes: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
+data
+
+BEGIN
+table public.harvest: INSERT: apples[integer]:43
+COMMIT
+?column?
+
+stop
diff --git a/contrib/test_decoding/specs/subxact_without_top.spec b/contrib/test_decoding/specs/subxact_without_top.spec
new file mode 100644
index 0000000000..1e78c2e8bf
--- /dev/null
+++ b/contrib/test_decoding/specs/subxact_without_top.spec
@@ -0,0 +1,65 @@
+# Forces decoding session to see (and associate with toplevel before commit)
+# subxact with previous top records (first xl_xact_assignment) beyond
+# restart_lsn. Such partially seen xact won't be streamed as it must finish
+# before confirmed_flush_lsn, but nevertheless this harmless schedule used to
+# cause
+# ERROR: subtransaction logged without previous top-level txn record
+# failures.
+
+setup
+{
+ SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'test_decoding'); -- must be first write in xact
+ CREATE TABLE harvest(apples integer);
+ CREATE OR REPLACE FUNCTION subxacts() returns void as $$
+ BEGIN
+ FOR i in 1 .. 128 LOOP
+ BEGIN
+ INSERT INTO harvest VALUES (42);
+ EXCEPTION
+ WHEN OTHERS THEN
+ RAISE;
+ END;
+ END LOOP;
+ END; $$LANGUAGE 'plpgsql';
+}
+
+teardown
+{
+ DROP TABLE IF EXISTS harvest;
+ SELECT 'stop' FROM pg_drop_replication_slot('isolation_slot');
+}
+
+session "s0"
+setup { SET synchronous_commit=on; }
+step "s0_begin" { BEGIN; }
+step "s0_first_subxact" {
+ DO LANGUAGE plpgsql $$
+ BEGIN
+ BEGIN
+ INSERT INTO harvest VALUES (41);
+ EXCEPTION WHEN OTHERS THEN RAISE;
+ END;
+ END $$;
+}
+step "s0_many_subxacts" { select subxacts(); }
+step "s0_commit" { COMMIT; }
+
+session "s1"
+setup { SET synchronous_commit=on; }
+step "s1_begin" { BEGIN; }
+step "s1_dml" { INSERT INTO harvest VALUES (43); }
+step "s1_commit" { COMMIT; }
+
+session "s2"
+setup { SET synchronous_commit=on; }
+step "s2_checkpoint" { CHECKPOINT; }
+step "s2_get_changes" { SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); }
+step "s2_get_changes_suppress_output" { SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1') LIMIT 5; }
+
+# First s2_checkpoint serializes snapshot (creates potential restart_lsn point)
+# *after* initial subxact, i.e. first xl_xact_assignment is beyond it.
+# s0_many_subxacts forces second xl_xact_assignment (issues >
+# PGPROC_MAX_CACHED_SUBXIDS) to associate subxact with toplevel before commit.
+# Second s2_checkpoint ensures s2_get_changes directly following it will
+# advance the slot, establishing that restart_lsn.
+permutation "s0_begin" "s0_first_subxact" "s2_checkpoint" "s1_begin" "s1_dml" "s0_many_subxacts" "s0_commit" "s2_checkpoint" "s2_get_changes_suppress_output" "s1_commit" "s2_get_changes"
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index aeebbf243a..481277a1fd 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -838,9 +838,6 @@ ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid,
txn = ReorderBufferTXNByXid(rb, xid, true, &new_top, lsn, true);
subtxn = ReorderBufferTXNByXid(rb, subxid, true, &new_sub, lsn, false);
- if (new_top && !new_sub)
- elog(ERROR, "subtransaction logged without previous top-level txn record");
-
if (!new_sub)
{
if (rbtxn_is_known_subxact(subtxn))
--
2.11.0
--=-=-=
Content-Type: text/plain
-- cheers, arseny
--=-=-=--
^ permalink raw reply [nested|flat] 6+ messages in thread
* [PATCH 2/2] Stop demanding that top xact must be seen before subxact in decoding.
@ 2019-10-23 12:56 Arseny Sher <sher-ars@yandex.ru>
0 siblings, 0 replies; 6+ messages in thread
From: Arseny Sher @ 2019-10-23 12:56 UTC (permalink / raw)
Manifested as
ERROR: subtransaction logged without previous top-level txn record
this check forbids legit behaviours like
- First xl_xact_assignment record is beyond reading, i.e. earlier
restart_lsn.
- After restart_lsn there is some change of a subxact.
- After that, there is second xl_xact_assignment (for another subxact)
revealing relationship between top and first subxact.
Such transaction won't be streamed anyway because we hadn't seen it in full;
confirmed_flush_lsn must be past all these records. Saying for sure whether xact
of some record encountered after snapshot was deserialized can be streamed or
not requires to know whether it wrote something before deserialization point --
if yes, it hasn't been seen in full and can't be decoded. Snapshot doesn't have
such info, so there is no easy way to relax the check.
---
contrib/test_decoding/Makefile | 2 +-
.../test_decoding/expected/subxact_without_top.out | 39 +++++++++++++
.../test_decoding/specs/subxact_without_top.spec | 67 ++++++++++++++++++++++
src/backend/replication/logical/reorderbuffer.c | 3 -
4 files changed, 107 insertions(+), 4 deletions(-)
create mode 100644 contrib/test_decoding/expected/subxact_without_top.out
create mode 100644 contrib/test_decoding/specs/subxact_without_top.spec
diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile
index 4afb1d963e..f439c582a5 100644
--- a/contrib/test_decoding/Makefile
+++ b/contrib/test_decoding/Makefile
@@ -7,7 +7,7 @@ REGRESS = ddl xact rewrite toast permissions decoding_in_xact \
decoding_into_rel binary prepared replorigin time messages \
spill slot truncate
ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \
- oldest_xmin snapshot_transfer
+ oldest_xmin snapshot_transfer subxact_without_top
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/test_decoding/logical.conf
ISOLATION_OPTS = --temp-config $(top_srcdir)/contrib/test_decoding/logical.conf
diff --git a/contrib/test_decoding/expected/subxact_without_top.out b/contrib/test_decoding/expected/subxact_without_top.out
new file mode 100644
index 0000000000..99ce998822
--- /dev/null
+++ b/contrib/test_decoding/expected/subxact_without_top.out
@@ -0,0 +1,39 @@
+Parsed test spec with 3 sessions
+
+starting permutation: s0_begin s0_first_subxact s2_checkpoint s1_begin s1_dml s0_many_subxacts s0_commit s2_checkpoint s2_get_changes_suppress_output s2_get_changes_suppress_output s1_commit s2_get_changes
+step s0_begin: BEGIN;
+step s0_first_subxact:
+ DO LANGUAGE plpgsql $$
+ BEGIN
+ BEGIN
+ INSERT INTO harvest VALUES (41);
+ EXCEPTION WHEN OTHERS THEN RAISE;
+ END;
+ END $$;
+
+step s2_checkpoint: CHECKPOINT;
+step s1_begin: BEGIN;
+step s1_dml: INSERT INTO harvest VALUES (43);
+step s0_many_subxacts: select subxacts();
+subxacts
+
+
+step s0_commit: COMMIT;
+step s2_checkpoint: CHECKPOINT;
+step s2_get_changes_suppress_output: SELECT null n FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1') GROUP BY n;
+n
+
+
+step s2_get_changes_suppress_output: SELECT null n FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1') GROUP BY n;
+n
+
+step s1_commit: COMMIT;
+step s2_get_changes: SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
+data
+
+BEGIN
+table public.harvest: INSERT: apples[integer]:43
+COMMIT
+?column?
+
+stop
diff --git a/contrib/test_decoding/specs/subxact_without_top.spec b/contrib/test_decoding/specs/subxact_without_top.spec
new file mode 100644
index 0000000000..6e9984da62
--- /dev/null
+++ b/contrib/test_decoding/specs/subxact_without_top.spec
@@ -0,0 +1,67 @@
+# Forces decoding session to see (and associate with toplevel before commit)
+# subxact with previous top records (first xl_xact_assignment) beyond
+# restart_lsn. Such partially seen xact won't be streamed as it must finish
+# before confirmed_flush_lsn, but nevertheless this harmless schedule used to
+# cause
+# ERROR: subtransaction logged without previous top-level txn record
+# failures.
+
+setup
+{
+ SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'test_decoding'); -- must be first write in xact
+ CREATE TABLE harvest(apples integer);
+ CREATE OR REPLACE FUNCTION subxacts() returns void as $$
+ BEGIN
+ FOR i in 1 .. 128 LOOP
+ BEGIN
+ INSERT INTO harvest VALUES (42);
+ EXCEPTION
+ WHEN OTHERS THEN
+ RAISE;
+ END;
+ END LOOP;
+ END; $$LANGUAGE 'plpgsql';
+}
+
+teardown
+{
+ DROP TABLE IF EXISTS harvest;
+ SELECT 'stop' FROM pg_drop_replication_slot('isolation_slot');
+}
+
+session "s0"
+setup { SET synchronous_commit=on; }
+step "s0_begin" { BEGIN; }
+step "s0_first_subxact" {
+ DO LANGUAGE plpgsql $$
+ BEGIN
+ BEGIN
+ INSERT INTO harvest VALUES (41);
+ EXCEPTION WHEN OTHERS THEN RAISE;
+ END;
+ END $$;
+}
+step "s0_many_subxacts" { select subxacts(); }
+step "s0_commit" { COMMIT; }
+
+session "s1"
+setup { SET synchronous_commit=on; }
+step "s1_begin" { BEGIN; }
+step "s1_dml" { INSERT INTO harvest VALUES (43); }
+step "s1_commit" { COMMIT; }
+
+session "s2"
+setup { SET synchronous_commit=on; }
+step "s2_checkpoint" { CHECKPOINT; }
+step "s2_get_changes" { SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); }
+step "s2_get_changes_suppress_output" { SELECT null n FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1') GROUP BY n; }
+
+# First s2_checkpoint serializes snapshot (creates potential restart_lsn point)
+# *after* initial subxact, i.e. first xl_xact_assignment is beyond it.
+# s0_many_subxacts forces second xl_xact_assignment (issues >
+# PGPROC_MAX_CACHED_SUBXIDS) to associate subxact with toplevel before commit.
+# Second s2_checkpoint ensures s2_get_changes directly following it will
+# advance the slot, establishing that restart_lsn.
+# We do get_changes twice because if one more xl_running_xacts record had slipped
+# before our CHECKPOINT, confirmed_flush will be advanced only to that record.
+permutation "s0_begin" "s0_first_subxact" "s2_checkpoint" "s1_begin" "s1_dml" "s0_many_subxacts" "s0_commit" "s2_checkpoint" "s2_get_changes_suppress_output" "s2_get_changes_suppress_output" "s1_commit" "s2_get_changes"
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index aeebbf243a..481277a1fd 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -838,9 +838,6 @@ ReorderBufferAssignChild(ReorderBuffer *rb, TransactionId xid,
txn = ReorderBufferTXNByXid(rb, xid, true, &new_top, lsn, true);
subtxn = ReorderBufferTXNByXid(rb, subxid, true, &new_sub, lsn, false);
- if (new_top && !new_sub)
- elog(ERROR, "subtransaction logged without previous top-level txn record");
-
if (!new_sub)
{
if (rbtxn_is_known_subxact(subtxn))
--
2.11.0
--=-=-=
Content-Type: text/plain
-- cheers, arseny
--=-=-=--
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2019-10-23 12:56 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-24 22:49 Patch for Postmaster Uptime (from the TODO) Eric Crampton <escpg@eonomine.com>
2005-02-25 01:38 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-02-25 02:48 ` Bruce Momjian <pgman@candle.pha.pa.us>
2019-10-23 12:56 [PATCH 2/2] Stop demanding that top xact must be seen before subxact in decoding. Arseny Sher <sher-ars@yandex.ru>
2019-10-23 12:56 [PATCH 2/2] Stop demanding that top xact must be seen before subxact in decoding. Arseny Sher <sher-ars@yandex.ru>
2019-10-23 12:56 [PATCH 2/2] Stop demanding that top xact must be seen before subxact in decoding. Arseny Sher <sher-ars@yandex.ru>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox