summaryrefslogtreecommitdiff
path: root/src/bin/pg_rewind
AgeCommit message (Collapse)Author
2016-05-09Translation updatesPeter Eisentraut
Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git Source-Git-Hash: 17bf3e8564abf600274789fcc90e72532d5e7c05
2016-03-28pg_rewind: Improve internationalizationAlvaro Herrera
This is mostly cosmetic since two of the three changes are debug messages, and the third one is just a progress indicator. Author: Michaël Paquier
2016-03-27pg_rewind: fsync target data directory.Andres Freund
Previously pg_rewind did not fsync any files. That's problematic, given that the target directory is modified. If the database was started afterwards, 2ce439f33 luckily already caused the data directory to be synced to disk at postmaster startup; reducing the scope of the problem. To fix, use initdb -S, at the end of the pg_rewind run. It doesn't seem worthwhile to duplicate the code into pg_rewind, and initdb -S is already used that way by pg_upgrade. Reported-By: Andres Freund Author: Michael Paquier, somewhat edited by me Discussion: 20160310034352.iuqgvpmg5qmnxtkz@alap3.anarazel.de CAB7nPqSytVG1o4S3S2pA1O=692ekurJ+fckW2PywEG3sNw54Ow@mail.gmail.com Backpatch: 9.5, where pg_rewind was introduced
2016-03-27pg_rewind: Close backup_label file descriptor.Andres Freund
This was a relatively harmless leak, as createBackupLabel() is only called once per pg_rewind invocation. Author: Michael Paquier Reported-By: Michael Paquier Discussion: CAB7nPqRnOw30gOXe2_SPLjh37bgm4V+txbYAPwoXb97nGQ297w@mail.gmail.com Backpatch: 9.5, where pg_rewind was introduced
2016-02-26Move some code from RewindTest into PostgresNodeAlvaro Herrera
Some code in the RewindTest test suite is more generally useful than just for that suite, so put it where other test suites can reach it. Some postgresql.conf parameters change their default values when a cluster is initialized with 'allows_streaming' than the previous behavior; most notably, autovacuum is no longer turned off. (Also, we no longer call pg_ctl promote with -w, but that flag doesn't actually do anything in promote so there's no behavior change.) Author: Michael Paquier
2016-01-20PostgresNode: Add names to nodesAlvaro Herrera
This makes the log files easier to follow when investigating a test failure. Author: Michael Paquier Review: Noah Misch
2016-01-04Fix typo in comment.Robert Haas
Masahiko Sawada
2016-01-02Update copyright for 2016Bruce Momjian
Backpatch certain files through 9.1
2015-12-24Remove unnecessary row ordering dependency in pg_rewind test suite.Tom Lane
t/002_databases.pl was expecting to see a specific physical order of the rows in pg_database. I broke that in HEAD with commit 01e386a325549b77, but I'd say it's a pretty fragile test methodology in any case, so fix it in 9.5 as well.
2015-12-17Remove unreferenced function declarations.Tom Lane
datapagemap_create() and datapagemap_destroy() were declared extern, but they don't actually exist anywhere. Per YUriy Zhuravlev and Michael Paquier.
2015-12-14Add missing cleanup logic in pg_rewind/t/005_same_timeline.pl test.Tom Lane
Per Michael Paquier
2015-12-11pg_rewind: Don't error if the two clusters are already on the same timelinePeter Eisentraut
This previously resulted in an error and a nonzero exit status, but after discussion this should rather be a noop with a zero exit status.
2015-12-02Refactor Perl test codeAlvaro Herrera
The original code was a bit clunky; make it more amenable for further reuse by creating a new Perl package PostgresNode, which is an object-oriented representation of a single server, with some support routines such as init, start, stop, psql. This serves as a better basis on which to build further test code, and enables writing tests that use more than one server without too much complication. This commit modifies a lot of the existing test files, mostly to remove explicit calls to system commands (pg_ctl) replacing them with method calls of a PostgresNode object. The result is quite a bit more straightforward. Also move some initialization code to BEGIN and INIT blocks instead of having it straight in as top-level code. This commit also introduces package RecursiveCopy so that we can copy whole directories without having to depend on packages that may not be present on vanilla Perl 5.8 installations. I also ran perltidy on the modified files, which changes some code sites that are not otherwise touched by this patch. I tried to avoid this, but it ended up being more trouble than it's worth. Authors: Michael Paquier, Álvaro Herrera Review: Noah Misch
2015-12-01Use pg_rewind when target timeline was switchedTeodor Sigaev
Allow pg_rewind to work when target timeline was switched. Now user can return promoted standby to old master. Target timeline history becomes a global variable. Index in target timeline history is used in function interfaces instead of specifying TLI directly. Thus, SimpleXLogPageRead() can easily start reading XLOGs from next timeline when current timeline ends. Author: Alexander Korotkov Review: Michael Paquier
2015-10-01pg_rewind: Improve some messagesPeter Eisentraut
The output of a typical pg_rewind run contained a mix of capitalized and not-capitalized and punctuated and not-punctuated phrases for no apparent reason. Make that consistent. Also fix some problems in other messages.
2015-09-18Simplify GETTEXT_FILES listPeter Eisentraut
2015-09-16Review program help output for wording and formattingPeter Eisentraut
2015-09-07In the pg_rewind test suite, receive WAL fully before promoting.Noah Misch
If a transaction never reaches the standby, later tests find unexpected cluster state. A "tail-copy: query result matches" test failure has been the usual symptom. Among the buildfarm members having run this test suite, most have exhibited that symptom at least once. Back-patch to 9.5, where pg_rewind was introduced. Michael Paquier, reported by Christoph Berg.
2015-08-11More fixes to allow pg_rewind tests to run on Msys.Andrew Dunstan
2015-08-05Allow pg_rewind tap tests to run with older File::Path versionsAndrew Dunstan
Older versions have rmtree but not remove_tree. The one-argument forms of these are equivalent, so replace remove_tree with rmtree. This allows the tests to be run on oldish Msys systems.
2015-08-03Fix pg_rewind when pg_xlog is a symlink.Heikki Linnakangas
pg_xlog is often a symlink, typically to a different filesystem. Don't get confused and comlain about by that, and just always pretend that it's a normal directory, even if it's really a symlink. Also add a test case for this. Backpatch to 9.5.
2015-08-03Clean up pg_rewind regression test script.Heikki Linnakangas
Since commit 01f6bb4b2, TestLib.pm has exported path to tmp_check directory, so let's use that also for the pg_rewind test clusters etc. Also, in master, the $tempdir_short variable has not been used since commit 13d856e17, which moved the initdb-running code to TestLib.pm. Backpatch to 9.5.
2015-07-29Make TAP tests work on Windows.Heikki Linnakangas
On Windows, use listen_address=127.0.0.1 to allow TCP connections. We were already using "pg_regress --config-auth" to set up HBA appropriately. The standard_initdb helper function now sets up the server's unix_socket_directories or listen_addresses in the config file, so that they don't need to be specified in the pg_ctl command line anymore. That way, the pg_ctl invocations in test programs don't need to differ between Windows and Unix. Add another helper function to configure the server's pg_hba.conf to allow replication connections. The configuration is done similarly to "pg_regress --config-auth": trust on domain sockets on Unix, and SSPI authentication on Windows. Replace calls to "cat" and "touch" programs with built-in perl code, as those programs don't normally exist on Windows. Add instructions in the docs on how to install IPC::Run on Windows. Adjust vcregress.pl to not replace PERL5LIB completely in vcregress.pl, because otherwise cannot install IPC::Run in a non-standard location easily. Michael Paquier, reviewed by Noah Misch, some additional tweaking by me.
2015-07-28Make tap tests store postmaster logs and handle vpaths correctlyAndrew Dunstan
Given this it is possible that the buildfarm animals running these tests will be able to capture adequate logging to allow diagnosis of failures.
2015-07-27Fix memory leaks in pg_rewind. Several PQclear() calls were missing.Heikki Linnakangas
Originally reported by Vladimir Borodin in the pg_rewind github project, patch by Michael Paquier.
2015-07-12Fix assorted memory leaks.Tom Lane
Per Coverity (not that any of these are so non-obvious that they should not have been caught before commit). The extent of leakage is probably minor to unnoticeable, but a leak is a leak. Back-patch as necessary. Michael Paquier
2015-07-09Use --debug flag in "remote" pg_rewind regression tests.Heikki Linnakangas
Gives more information in the log, to debug possible failures.
2015-07-09Improve logging of TAP tests.Heikki Linnakangas
Create a log file for each test run. Stdout and stderr of the test script, as well as any subprocesses run as part of the test, are redirected to the log file. This makes it a lot easier to debug test failures. Also print the test output (ok 12 - ... messages) to the log file, and the command line of any external programs executed with the system_or_bail and run_log functions. This makes it a lot easier to debug failing tests. Modify some of the pg_ctl and other command invocations to not use 'silent' or 'quiet' options, and don't redirect output to /dev/null, so that you get all the information in the log instead. In the passing, construct some command lines in a way that works if $tempdir contains quote-characters. I haven't systematically gone through all of them or tested that, so I don't know if this is enough to make that work. pg_rewind tests had a custom mechanism for creating a similar log file. Use the new generic facility instead. Michael Paquier and me.
2015-06-28Translation updatesPeter Eisentraut
Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git Source-Git-Hash: fb7e72f46cfafa1b5bfe4564d9686d63a1e6383f
2015-06-28Don't choke on files that are removed while pg_rewind runs.Heikki Linnakangas
If a file is removed from the source server, while pg_rewind is running, the invocation of pg_read_binary_file() will fail. Use the just-added missing_ok option to that function, to have it return NULL instead, and handle that gracefully. And similarly for pg_ls_dir and pg_stat_file. Reported by Fujii Masao, fix by Michael Paquier.
2015-06-23Add missing newline to debug-message.Heikki Linnakangas
Michael Paquier
2015-06-22pg_rewind: Improve message wordingPeter Eisentraut
2015-06-12Clean up useless mention of RMGRDESCSOURCES in pg_rewind Makefile.Fujii Masao
RMGRDESCSOURCES is defined and used only in pg_xlogdump Makefile, but pg_rewind Makefile mentioned it as extra files to remove in "make clean". This patch removes that useless mention from pg_rewind Makefile. Michael Paquier
2015-06-11Fix some issues in pg_rewind.Fujii Masao
* Remove invalid option character "N" from the third argument (valid option string) of getopt_long(). * Use pg_free() or pfree() to free the memory allocated by pg_malloc() or palloc() instead of always using free(). * Assume problem is no disk space if write() fails but doesn't set errno. * Fix several typos. Patch by me. Review by Michael Paquier.
2015-05-28Fix pg_rewind's handling of top-level symlinks.Tom Lane
The previous coding suffered a null-pointer dereference if it found any symlink at the top level of $PGDATA. Fix that, and teach it to recurse into a symlink for pg_xlog, but not anything else. Per note from Abhijit Menon-Sen.
2015-05-28Fix assorted inconsistencies in our calls of readlink().Tom Lane
Ensure that we null-terminate the result string (one place in pg_rewind). Be paranoid about out-of-range results from readlink() (should not happen, but there is no good reason for some call sites to be careful about it and others not). Consistently use the whole buffer, not sometimes one byte less. Ensure we emit an appropriate errcode() in all cases. Spell the error messages the same way. The only serious bug here is the missing null-termination in pg_rewind, which is new code, so no need for a back-patch. Abhijit Menon-Sen and Tom Lane
2015-05-23pgindent run for 9.5Bruce Momjian
2015-04-30Fix pg_rewind regression failure after "fast promotion"Heikki Linnakangas
pg_rewind looks at the control file to determine the server's timeline. If the standby performs a "fast promotion", the timeline ID in the control file is not updated until the next checkpoint. The startup process requests a checkpoint immediately after promotion, so this is unlikely to be an issue in the real world, but the regression suite ran pg_rewind so quickly after promotion that the checkpoint had not yet completed. Reported by Stephen Frost
2015-04-22Make the pg_rewind regression tests more robust on slow systems.Heikki Linnakangas
There were a couple of hard-coded sleeps in the tests: to wait for standby to catch up with master, and to wait for promotion with "pg_ctl promote" to complete. Instead of a fixed, hard-coded sleep, poll the server with a query once a second. This isn't ideal either, and I wish we had a better solution for real-world applications too, but this should fix the immediate problem. Patch by Michael Paquier, with some editing by me.
2015-04-22Don't leave 'tmp_check' directory behind in pg_rewind regression tests.Heikki Linnakangas
2015-04-21Add missing installcheck target to pg_rewind's MakefileHeikki Linnakangas
Michael Paquier
2015-04-16Add missing newlines to error messages.Heikki Linnakangas
2015-04-15Error out in pg_rewind if lstat() fails.Heikki Linnakangas
A "file not found" is expected if the source server is running, so don't complain about that. But any other error is definitely not expected.
2015-04-15Minor cleanup of pg_rewind.Heikki Linnakangas
Update comments and function names to use the terms "source" and "target" consistently. Some places were calling them remote and local instead, which was confusing. Fix incorrect comment in extractPageInfo on database creation record - it was wrong on what happens for databases created in the target that don't exist in source.
2015-04-15Shut down test servers after pg_rewind regression tests.Heikki Linnakangas
Now that the test servers are initialized twice in each .pl script, the single END block is not enough to stop them. Add a new clean_rewind_test function that is called at the end of each test. Michael Paquier
2015-04-14Reorganize our CRC source files again.Heikki Linnakangas
Now that we use CRC-32C in WAL and the control file, the "traditional" and "legacy" CRC-32 variants are not used in any frontend programs anymore. Move the code for those back from src/common to src/backend/utils/hash. Also move the slicing-by-8 implementation (back) to src/port. This is in preparation for next patch that will add another implementation that uses Intel SSE 4.2 instructions to calculate CRC-32C, where available.
2015-04-13Fix pg_rewind regression tests in VPATH buildsHeikki Linnakangas
Should call just "pg_rewind", instead of "./pg_rewind". The tests are called so that PATH contains the temporariy installation bin dir. Per report from Alvaro Herrera
2015-04-13Refactor and fix TAP tests of pg_rewindHeikki Linnakangas
* Don't pass arguments to prove, since that's not supported on perl 5.8 which is the minimum version supported by the TAP tests. Refactor the test files themselves to run the tests twice, in both local and remote mode. * Use eq rather than == for string comparison. This thinko caused the remote versions of the tests to never run. * Add "use strict" and "use warnings", and fix warnings that that produced. * Increase the delay after standby promotion, to make the tests more robust. * In remote mode, the connection string to the promoted standby was incorrect, leading to connection errors. Patch by Michael Paquier, to address Peter Eisentraut's report.
2015-04-13Silence gettext warning about '\r' escape sequence in translatable string.Fujii Masao
gettext was unhappy about the commit b216ad7 because it revealed the problem that internationalized messages may contain '\r' escape sequence in pg_rewind. This commit moves '\r' to a separate printf() call. Michael Paquier, bug reported by Peter Eisentraut
2015-04-12Free leaked result set in pg_rewindHeikki Linnakangas
It was not significant in practice, it was just one instance of a small result set, but let's pacify Coverity. Michael Paquier