summaryrefslogtreecommitdiff
path: root/src/bin/pg_rewind/libpq_source.c
AgeCommit message (Collapse)Author
34 hoursStandardize LSN formatting by zero paddingÁlvaro Herrera
This commit standardizes the output format for LSNs to ensure consistent representation across various tools and messages. Previously, LSNs were inconsistently printed as `%X/%X` in some contexts, while others used zero-padding. This often led to confusion when comparing. To address this, the LSN format is now uniformly set to `%X/%08X`, ensuring the lower 32-bit part is always zero-padded to eight hexadecimal digits. Author: Japin Li <[email protected]> Reviewed-by: Masahiko Sawada <[email protected]> Reviewed-by: Álvaro Herrera <[email protected]> Discussion: https://postgr.es/m/ME0P300MB0445CA53CA0E4B8C1879AF84B641A@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
2025-03-29Use PRI?64 instead of "ll?" in format strings (continued).Peter Eisentraut
Continuation of work started in commit 15a79c73, after initial trial. Author: Thomas Munro <[email protected]> Discussion: https://postgr.es/m/b936d2fb-590d-49c3-a615-92c3a88c6c19%40eisentraut.org
2025-01-01Update copyright for 2025Bruce Momjian
Backpatch-through: 13
2024-11-06Remove unused #include's from bin .c filesPeter Eisentraut
as determined by IWYU Similar to commit dbbca2cf299, but for bin and some related files. Discussion: https://www.postgresql.org/message-id/flat/0df1d5b1-8ca8-4f84-93be-121081bde049%40eisentraut.org
2024-08-10Fix inappropriate uses of atol()Peter Eisentraut
Some code using atol() would not work correctly if sizeof(long)==4: - src/bin/pg_basebackup/pg_basebackup.c: Would miscount size of a tablespace over 2 TB. - src/bin/pg_basebackup/streamutil.c: Would truncate a timeline ID beyond INT32_MAX. - src/bin/pg_rewind/libpq_source.c: Would miscount size of files larger than 2 GB (but this currently cannot happen). Replace these with atoll(). In one case, the use of atol() did not result in incorrect behavior but seems inconsistent with related code: - src/interfaces/ecpg/ecpglib/execute.c: Gratuitous, since it processes a value from pg_type.typlen, which is int16. Replace this with atoi(). Reviewed-by: Heikki Linnakangas <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/a52738ad-06bc-4d45-b59f-b38a8a89de49%40eisentraut.org
2024-05-17Revise GUC names quoting in messages againPeter Eisentraut
After further review, we want to move in the direction of always quoting GUC names in error messages, rather than the previous (PG16) wildly mixed practice or the intermittent (mid-PG17) idea of doing this depending on how possibly confusing the GUC name is. This commit applies appropriate quotes to (almost?) all mentions of GUC names in error messages. It partially supersedes a243569bf65 and 8d9978a7176, which had moved things a bit in the opposite direction but which then were abandoned in a partial state. Author: Peter Smith <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/CAHut%2BPv-kSN8SkxSdoHano_wPubqcg5789ejhCDZAcLFceBR-w%40mail.gmail.com
2024-02-15Introduce transaction_timeoutAlexander Korotkov
This commit adds timeout that is expected to be used as a prevention of long-running queries. Any session within the transaction will be terminated after spanning longer than this timeout. However, this timeout is not applied to prepared transactions. Only transactions with user connections are affected. Discussion: https://postgr.es/m/CAAhFRxiQsRs2Eq5kCo9nXE3HTugsAAJdSQSmxncivebAxdmBjQ%40mail.gmail.com Author: Andrey Borodin <[email protected]> Author: Japin Li <[email protected]> Author: Junwang Zhao <[email protected]> Reviewed-by: Nikolay Samokhvalov <[email protected]> Reviewed-by: Andres Freund <[email protected]> Reviewed-by: Fujii Masao <[email protected]> Reviewed-by: bt23nguyent <[email protected]> Reviewed-by: Yuhang Qiu <[email protected]>
2024-01-04Update copyright for 2024Bruce Momjian
Reported-by: Michael Paquier Discussion: https://postgr.es/m/[email protected] Backpatch-through: 12
2023-07-30Fix pg_rewind with in-place tablespaces when source is remoteMichael Paquier
libpq_source.c would consider any result returned by pg_tablespace_location() as a symlink, resulting in run-time errors like that: pg_rewind: error: file "pg_tblspc/NN" is of different type in source and target In-place tablespaces are directories located in pg_tblspc/, returned as relative paths instead of absolute paths, so rely on that to make the difference with a normal tablespace and an in-place one. If the path is relative, the tablespace is handled as a directory. If the path is absolute, consider it as a symlink. In-place tablespaces are only intended for development purposes, so like 363e8f9 no backpatch is done. A test is added in pg_rewind with an in-place tablespace and some data in it. Author: Rui Zhao, Michael Paquier Discussion: https://postgr.es/m/[email protected]
2023-05-02Fix overridden callbacks in pg_rewind.Daniel Gustafsson
The <source>_traverse_files functions take a callback for processing files, but both the local and libpq source implementations called the function directly without using the callback argument. While there is no bug right now as the function called is the same as the callback, fix by calling the callback to reduce the risk of subtle bugs in the future. Author: Junwang Zhao <[email protected]> Reviewed-by: Richard Guo <[email protected]> Discussion: https://postgr.es/m/CAEG8a3Jdwgh+PZr2zh1=t8apA4Yz8tKq+uubPqoCt14nvWKHEw@mail.gmail.com
2023-01-02Update copyright for 2023Bruce Momjian
Backpatch-through: 11
2022-04-05pg_rewind: Fetch small files according to new size.Daniel Gustafsson
There's a race condition if a file changes in the source system after we have collected the file list. If the file becomes larger, we only fetched up to its original size. That can easily result in a truncated file. That's not a problem for relation files, files in pg_xact, etc. because any actions on them will be replayed from the WAL. However, configuration files are affected. This commit mitigates the race condition by fetching small files in whole, even if they have grown. A test is added in which an extra file copied is concurrently grown with the output of pg_rewind thus guaranteeing it to have changed in size during the operation. This is not a full fix: we still believe the original file size for files larger than 1 MB. That should be enough for configuration files, and doing more than that would require big changes to the chunking logic in libpq_source.c. This mitigates the race condition if the file is modified between the original scan of files and copying the file, but there's still a race condition if a file is changed while it's being copied. That's a much smaller window, though, and pg_basebackup has the same issue. This race can be seen with pg_auto_failover, which frequently uses ALTER SYSTEM, which updates postgresql.auto.conf. Often, pg_rewind will fail, because the postgresql.auto.conf file changed concurrently and a partial version of it was copied to the target. The partial file would fail to parse, preventing the server from starting up. Author: Heikki Linnakangas Reviewed-by: Cary Huang Discussion: https://postgr.es/m/f67feb24-5833-88cb-1020-19a4a2b83ac7%40iki.fi
2022-01-08Update copyright for 2022Bruce Momjian
Backpatch-through: 10
2021-04-21Don't use INT64_FORMAT inside message stringsPeter Eisentraut
Use %lld and cast to long long int instead.
2021-02-24Fix some typos, grammar and style in docs and commentsMichael Paquier
The portions fixing the documentation are backpatched where needed. Author: Justin Pryzby Discussion: https://postgr.es/m/[email protected] backpatch-through: 9.6
2021-01-02Update copyright for 2021Bruce Momjian
Backpatch-through: 9.5
2020-11-12Allow pg_rewind to use a standby server as the source system.Heikki Linnakangas
Using a hot standby server as the source has not been possible, because pg_rewind creates a temporary table in the source system, to hold the list of file ranges that need to be fetched. Refactor it to queue up the file fetch requests in pg_rewind's memory, so that the temporary table is no longer needed. Also update the logic to compute 'minRecoveryPoint' correctly, when the source is a standby server. Reviewed-by: Kyotaro Horiguchi, Soumyadeep Chakraborty Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi
2020-11-04pg_rewind: Refactor the abstraction to fetch from local/libpq source.Heikki Linnakangas
This makes the abstraction of a "source" server more clear, by introducing a common abstract class, borrowing the object-oriented programming term, that represents all the operations that can be done on the source server. There are two implementations of it, one for fetching via libpq, and another to fetch from a local directory. This adds some code, but makes it easier to understand what's going on. The copy_executeFileMap() and libpq_executeFileMap() functions contained basically the same logic, just calling different functions to fetch the source files. Refactor so that the common logic is in one place, in a new function called perform_rewind(). Reviewed-by: Kyotaro Horiguchi, Soumyadeep Chakraborty Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi