1. Jan 08, 2024
  2. Jan 05, 2024
  3. Jan 04, 2024
    • Hanefi Onaldi's avatar
      Automate updating help messages in docs (#565) · 1ed47db3
      Hanefi Onaldi authored
      This commit introduces a shell script that runs all commands that accept
      `--help` parameter and stores the result in template files that are
      referenced in our documentation. You can use that script by running
      `make update-docs` in top directory of the project.
      1ed47db3
  4. Jan 03, 2024
  5. Jan 02, 2024
    • Dimitri Fontaine's avatar
      Fix pgcopydb list progress command. (#610) · 65c51045
      Dimitri Fontaine authored
      Introduce a new query to count the number of tables and indexes already
      processed from the summary table, fixing the list progress output for items
      "done".
      65c51045
    • Dimitri Fontaine's avatar
    • Dimitri Fontaine's avatar
    • Dimitri Fontaine's avatar
      Use our SQLite catalogs for the pgcopydb sentinel table. (#601) · 97f18bc5
      Dimitri Fontaine authored
      * Use our SQLite catalogs for the pgcopydb sentinel table.
      
      The main use-case for the sentinel table is to communicate progress made by
      the three independent worker processes for stream, transform, and replay.
      It is also needed to communicate new startpos, endpos and apply values with
      those processes from another pgcopydb (interactive) command, a process
      that's not in the process tree.
      
      This was previously solved by creating and using a pgcopydb.sentinel table
      on the source database. Now that we have a SQLite database internal to the
      pgcopydb run, we can use that instead.
      
      * More work on the sentinel table move to SQLite catalogs.
      
      In particular, we need to share a common directory mount point in the test
      and inject containers, because the inject container is setting the endpos
      for the test container where the main tests are running.
      
      For that, in my testing the best option is to use a host directory. This
      also makes it very easy to then use sqlite3 and inspect what's going on from
      the outside.
      
      * Attempt to fix GitHub Action host workdir perms
      
      * Fix follow-data-only tests: update sentinel at stream flush time.
      
      * Assorted fixes, per self-review.
      97f18bc5
  6. Dec 30, 2023
    • Hanefi Onaldi's avatar
      Removes copy-db command (#605) · d365e07f
      Hanefi Onaldi authored
      The copy-db command is deprecated and will get removed from pgcopydb on
      next release, please upgrade your scripts and integrations.
      d365e07f
  7. Dec 28, 2023
  8. Dec 27, 2023
    • Dimitri Fontaine's avatar
    • Arunprasad Rajkumar's avatar
    • Dimitri Fontaine's avatar
      Remove summary files, use our SQLite database instead. (#590) · 75e1e8d7
      Dimitri Fontaine authored
      * Remove summary files, use our SQLite database instead.
      
      * Get rid of summary files for the indexing and constraints too.
      
      This allows also to entirely remove the need for semaphores to handle
      concurrency between worker processes, using SQLite insert-or-ignore for
      concurrency control instead.
      
      Also the idea of TablePaths and IndexPaths elements are gone, with the lock
      files and the done files mechanisms.
      
      * Protect SQLite concurrent write access with a semaphore.
      
      SQLite has not been designed for write-write concurrency, so implement a
      critical section in our code so that SQLite only sees a single writer at all
      times. It may still see multiple readers though.
      
      Because we have re-entrant queries (an SQLite iterator function may then
      choose to run another SQLite query), this commit also adds support for
      re-entrant semaphore in a way that doesn't call into semop(2) again when we
      already are in the critical section.
      
      * Assorted fixes.
      75e1e8d7
    • Dimitri Fontaine's avatar
    • Dimitri Fontaine's avatar
      Fix error handling (--fail-fast) for copy workers. (#598) · 4ce24428
      Dimitri Fontaine authored
      When the COPY table-data workers fail before the iteration over the list of
      tables is done, we have a race condition where the COPY supervisor would be
      busy and is not using waitpid(), thus not reacting to worker process
      termination.
      
      To solve, limit the responsibilities of the COPY supervisor process even
      more and create a new process that's responsible for iterating over the
      table list and sending tables/parts to the queue, etc.
      4ce24428
    • Dimitri Fontaine's avatar
      Review the COPY arguments API to fix TRUNCATE calls. (#597) · 9db10402
      Dimitri Fontaine authored
      The code to call TRUNCATE ONLY was only active for tables setup with COPY
      partitioning (--split-tables-larger-than), and was forced to "false" for the
      other tables.
      
      The code also evolved in a way that it would build a sub-SELECT query with
      the table attribute list as the "srcQname" argument to the pgsql.c internal
      bits for the copy, making it impossible to then re-use that bit in the sql
      command for the TRUNCATE operation.
      
      To fix, implement a new way to prepare the COPY query bits and pieces so
      that we can re-use the qualified table name in the TRUNCATE command and also
      build a full COPY (SELECT a, b, c FROM ONLY t WHERE ...) TO STDOUT; query.
      
      In passing, because of the way we are changing the summary files to use our
      internal SQLite database instead, also push the TRUNCATE command of COPY
      partitionned table to the COPY supervisor process. This is a better way to
      solve the concurrency issues and make sure that TRUNCATE is done only once,
      and also finished before any of the copy-data worker processes get started.
      9db10402
  9. Dec 22, 2023
    • Shubham Dhama's avatar
      Fix escaping of identifiers while transforming for wal2json plugin. (#595) · 30a87a7f
      Shubham Dhama authored
      
      
      * add quotes identifiers
      
      * test changes
      
      * Fix escaping of identifiers while transforming for wal2json plugin.
      
      wal2json doesn't escape identifiers as test_decoding do. To fix this issue
      we are using PQescapeIdentifier function. Even though this function doesn't
      require PGconn to be connected, but creating an empty PGconn object was
      unfeasible. Some fields of PGconn that are required by new versions of
      libpq for PQescapeIdentifier are not available in older PGconn. So decided
      to do this the right way, but creating PGconn with an actual server
      connection. It turned out more simpler than managing a dummy PGconn object.
      
      * Fix review comments.
      
      * Fix style.
      
      ---------
      
      Co-authored-by: default avatarVaibhaveS <vaibhavedavey@gmail.com>
      30a87a7f
    • Arunprasad Rajkumar's avatar
      Attach source catalog even for follow only mode (#596) · d7a1ea0a
      Arunprasad Rajkumar authored
      
      
      test_decoding transform relies on source catalog to decode the update message.
      
      Prior to this commit, update while using test_decoding would work only while doing `pgcopydb clone --follow`. This commit enables support for update message decoding
      while using test_decoding plugin in `pgcopydb follow` too.
      
      Signed-off-by: default avatarArunprasad Rajkumar <ar.arunprasad@gmail.com>
      d7a1ea0a
  10. Dec 20, 2023
  11. Dec 19, 2023
  12. Dec 18, 2023
  13. Dec 15, 2023
    • Dimitri Fontaine's avatar
      Use SQLite to store our internal copy of the source catalogs. (#569) · 27346848
      Dimitri Fontaine authored
      This allows to implement an in-memory array with the capabilities to
      spill-to-disk and also hash-table like lookup operations, and with good
      multi-process concurrency handling.
      
      Using SQLite internally will allow reducing the memory usage of pgcopydb and
      make it possible to address databases with more than a million of tables
      defined.
      27346848
    • Dimitri Fontaine's avatar
      Fix interrupt handling in queue_receive. (#580) · c0b8b459
      Dimitri Fontaine authored
      That allows C-c to work in more situations, which is always good.
      c0b8b459
    • Dimitri Fontaine's avatar
      Fix Postgres connection handling in Large Object related code. (#579) · 3fbb1f61
      Dimitri Fontaine authored
      We would see “WARNING: transaction already in progress” in the logs.
      3fbb1f61
    • Dimitri Fontaine's avatar
      Fix application_name truncation notice messages. (#578) · 13b7290a
      Dimitri Fontaine authored
      Postgres application_name is limited to NAMEDATALEN, sending more bytes
      than that gives us a NOTICE and we can easily avoid it. In passing, avoid
      redundancies in the application_name when the ps_buffer already starts with
      "pgcopydb: ".
      13b7290a
    • Hanefi Onaldi's avatar
      Remove links for indices and tables in docs (#577) · 3f32b1a0
      Hanefi Onaldi authored
      Search page shows 404, whereas genindex and modindex are empty pages.
      3f32b1a0
    • Hanefi Onaldi's avatar
      Add option to output numeric as string on wal2json (#576) · ebe3f332
      Hanefi Onaldi authored
      * Add option to output numeric as string on wal2json
      
      This change adds a new option `--wal2json-numeric-as-string` that
      changes wal2json plugin output format to print numeric data types as
      strings. This is accomplished by passing the
      `--numeric-data-types-as-string` option to wal2json plugin.
      
      This is useful to prevent precision loss when using wal2json
      plugin to stream changes from a database that uses numeric data types.
      
      wal2json plugin version that supports `--numeric-data-types-as-string`
      option is required to use this pgcopydb option. As of today there is no
      official wal2json release that supports this option, but it is available
      on master branch of the project.
      
      Relevant changes in wal2json plugin is at
      https://github.com/eulerto/wal2json/pull/255
      
      * Add env to output numeric as string on wal2json
      
      PGCOPYDB_WAL2JSON_NUMERIC_AS_STRING can be set to a boolean value that
      will be used to determine if pgcopydb should set the wal2json option
      `--numeric-data-types-as-string`.
      
      In passing, also add the PGCOPYDB_OUTPUT_PLUGIN env variable to all
      relevant pages of our documentation.
      ebe3f332
  14. Dec 07, 2023
  15. Dec 06, 2023