1. Jan 23, 2024
    • Dimitri Fontaine's avatar
      Use Boehm-Demers-Weiser Garbage Collector. · 3c9d5c7a
      Dimitri Fontaine authored
      From their own documentation:
      
      > The Boehm-Demers-Weiser conservative garbage collector can be used as a
      > garbage collecting replacement for C malloc or C++ new. It allows you to
      > allocate memory basically as you normally would, without explicitly
      > deallocating memory that is no longer useful. The collector automatically
      > recycles memory when it determines that it can no longer be otherwise
      > accessed.
      
      In pgcopydb C code base it's been hard to maintain proper malloc/free
      concerns while also implementing proper error-handling, which is a common
      problem when writing C code. In order to ease the maintenance of the code
      and reduce production hazards, the best way to proceed looks like automating
      the memory management altogether by using a Garbage Collector.
      3c9d5c7a
  2. Jan 22, 2024
  3. Jan 17, 2024
    • Dimitri Fontaine's avatar
      Fix eager extension/collation skipping. (#642) · 7633458c
      Dimitri Fontaine authored
      The SQLite patch series introduced a bug where we would skip extensions even
      when the option --skip-extension is not used.
      
      Also adjust the "pgcopydb copy extensions" to the recent changes where we
      use a sub-process under a supervisor to simplify snapshot handling.
      7633458c
    • Dimitri Fontaine's avatar
      Review zero-byte allocation hasards. (#641) · 49725e5d
      Dimitri Fontaine authored
      Make sure we don't try and allocate a zero-size memory area, which can lead
      to "corrupted size vs. prev_size". Review all the calloc() call sites and
      protect them better when they need to be.
      49725e5d
    • Dimitri Fontaine's avatar
      Review the splitLines() API to avoid allocating zero bytes. (#638) · b207fd41
      Dimitri Fontaine authored
      Make it systematic to first count the lines and then allocate the right
      amount of memory for the array of pointers to the start of each line, and
      make sure we don't try and allocate a zero-size array, which can lead to
      "corrupted size vs. prev_size" errors at run-time.
      b207fd41
  4. Jan 16, 2024
  5. Jan 15, 2024
  6. Jan 10, 2024
  7. Jan 09, 2024
  8. Jan 05, 2024
  9. 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
  10. Jan 03, 2024
  11. 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
  12. 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
  13. Dec 28, 2023
  14. 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
  15. 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
  16. Dec 20, 2023