Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82c83b3

Browse files
committed
Fix logical_decoding_timelines test crashes
In the test_slot_timelines test module, we were abusing passing NULLvalues which was received as zeroes in x86, but this breaks in ARM(buildfarm member hamster) by crashing instead. Fix the breakage bymarking these functions as STRICT; the InvalidXid value that waspreviously implicit in NULL values (on x86 at least) can now be passedas 0. Failing to follow the fmgr protocol to check for NULLs beforehandwas causing ARM to fail, as evidenced by segmentation faults inbuildfarm member hamster.In order to use the new functionality in the test script, use COALESCEin the right spot to avoid forwarding NULL values.This was diagnosed from the hamster crash by Craig Ringer, who alsoproposed a different patch (checking for NULL values explicitely in theC function code, and keeping the non-strictness in the C functions).I decided to go with this approach instead.
1 parent27f3bbf commit82c83b3

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

‎src/test/modules/test_slot_timelines/expected/load_extension.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SELECT test_slot_timelines_create_logical_slot('test_slot', 'test_decoding');
55

66
(1 row)
77

8-
SELECT test_slot_timelines_advance_logical_slot('test_slot', txid_current(), txid_current(), pg_current_xlog_location(), pg_current_xlog_location());
8+
SELECT test_slot_timelines_advance_logical_slot('test_slot', txid_current()::text::xid, txid_current()::text::xid, pg_current_xlog_location(), pg_current_xlog_location());
99
test_slot_timelines_advance_logical_slot
1010
------------------------------------------
1111

‎src/test/modules/test_slot_timelines/sql/load_extension.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ CREATE EXTENSION test_slot_timelines;
22

33
SELECT test_slot_timelines_create_logical_slot('test_slot','test_decoding');
44

5-
SELECT test_slot_timelines_advance_logical_slot('test_slot', txid_current(), txid_current(), pg_current_xlog_location(), pg_current_xlog_location());
5+
SELECT test_slot_timelines_advance_logical_slot('test_slot', txid_current()::text::xid, txid_current()::text::xid, pg_current_xlog_location(), pg_current_xlog_location());
66

77
SELECT pg_drop_replication_slot('test_slot');

‎src/test/modules/test_slot_timelines/test_slot_timelines--1.0.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
CREATE OR REPLACEFUNCTIONtest_slot_timelines_create_logical_slot(slot_nametext, plugintext)
55
RETURNS void
6-
LANGUAGE cAS'MODULE_PATHNAME';
6+
STRICTLANGUAGE cAS'MODULE_PATHNAME';
77

88
COMMENTON FUNCTION test_slot_timelines_create_logical_slot(text,text)
99
IS'Create a logical slot at a particular lsn and xid. Do not use in production servers, it is not safe. The slot is created with an invalid xmin and lsn.';
1010

11-
CREATE OR REPLACEFUNCTIONtest_slot_timelines_advance_logical_slot(slot_nametext, new_xminbigint, new_catalog_xminbigint, new_restart_lsn pg_lsn, new_confirmed_lsn pg_lsn)
11+
CREATE OR REPLACEFUNCTIONtest_slot_timelines_advance_logical_slot(slot_nametext, new_xminxid, new_catalog_xminxid, new_restart_lsn pg_lsn, new_confirmed_lsn pg_lsn)
1212
RETURNS void
13-
LANGUAGE cAS'MODULE_PATHNAME';
13+
STRICTLANGUAGE cAS'MODULE_PATHNAME';
1414

15-
COMMENTON FUNCTION test_slot_timelines_advance_logical_slot(text,bigint,bigint, pg_lsn, pg_lsn)
15+
COMMENTON FUNCTION test_slot_timelines_advance_logical_slot(text,xid, xid, pg_lsn, pg_lsn)
1616
IS'Advance a logical slot directly. Do not use this in production servers, it is not safe.';

‎src/test/modules/test_slot_timelines/test_slot_timelines.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ Datum
8585
test_slot_timelines_advance_logical_slot(PG_FUNCTION_ARGS)
8686
{
8787
char*slotname=text_to_cstring(PG_GETARG_TEXT_P(0));
88-
TransactionIdnew_xmin=(TransactionId)PG_GETARG_INT64(1);
89-
TransactionIdnew_catalog_xmin=(TransactionId)PG_GETARG_INT64(2);
88+
TransactionIdnew_xmin=DatumGetTransactionId(PG_GETARG_DATUM(1));
89+
TransactionIdnew_catalog_xmin=DatumGetTransactionId(PG_GETARG_DATUM(2));
9090
XLogRecPtrrestart_lsn=PG_GETARG_LSN(3);
9191
XLogRecPtrconfirmed_lsn=PG_GETARG_LSN(4);
9292

@@ -95,7 +95,7 @@ test_slot_timelines_advance_logical_slot(PG_FUNCTION_ARGS)
9595
ReplicationSlotAcquire(slotname);
9696

9797
if (MyReplicationSlot->data.database!=MyDatabaseId)
98-
elog(ERROR,"Trying to update a slot on a different database");
98+
elog(ERROR,"trying to update a slot on a different database");
9999

100100
MyReplicationSlot->data.xmin=new_xmin;
101101
MyReplicationSlot->data.catalog_xmin=new_catalog_xmin;

‎src/test/recovery/t/006_logical_decoding_timelines.pl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,13 @@ BEGIN
172172
# we're just doing it by hand for this test. This is exposing
173173
# postgres innards to SQL so it's unsafe except for testing.
174174
$node_master->safe_psql('postgres','CREATE EXTENSION test_slot_timelines;');
175-
my$slotinfo =$node_master->safe_psql('postgres',
176-
'SELECT slot_name, plugin, xmin, catalog_xmin, restart_lsn, confirmed_flush_lsn FROM pg_replication_slots ORDER BY slot_name'
175+
176+
my$slotinfo =$node_master->safe_psql(
177+
'postgres',
178+
qq{SELECT slot_name, plugin,
179+
COALESCE(xmin, '0'), catalog_xmin,
180+
restart_lsn, confirmed_flush_lsn
181+
FROM pg_replication_slots ORDER BY slot_name}
177182
);
178183
diag"Copying slots to replica";
179184
openmy$fh,'<', \$slotinfoordie$!;
@@ -183,10 +188,7 @@ BEGIN
183188
chomp$_;
184189
my ($slot_name,$plugin,$xmin,$catalog_xmin,$restart_lsn,
185190
$confirmed_flush_lsn)
186-
=map {
187-
if ($_ne'') {"'$_'" }
188-
else {'NULL' }
189-
}splitqr/\|/,$_;
191+
=map {"'$_'" }splitqr/\|/,$_;
190192

191193
print
192194
"# Copying slot$slot_name,$plugin,$xmin,$catalog_xmin,$restart_lsn,$confirmed_flush_lsn\n";
@@ -208,7 +210,7 @@ BEGIN
208210

209211
$stdout =$node_replica->safe_psql(
210212
'postgres',
211-
qq{SELECT slot_name, plugin, xmin, catalog_xmin,
213+
qq{SELECT slot_name, plugin,COALESCE(xmin, '0'), catalog_xmin,
212214
restart_lsn, confirmed_flush_lsn
213215
FROM pg_replication_slots
214216
ORDER BY slot_name});
@@ -243,6 +245,7 @@ BEGIN
243245
opendir(my$pg_xlog,$node_master->data_dir ."/pg_xlog")ordie$!;
244246
while (my$seg =readdir$pg_xlog)
245247
{
248+
nextif$segeq'.'or$segeq'..';
246249
nextunless$seg >=$oldest_needed_segment &&$seg =~/^[0-9]{24}/;
247250
diag"copying xlog seg$seg";
248251
copy(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp