Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wall2json message not completely pushed for update operation (long text not pushed) #205

Closed
suganda7 opened this issue Aug 20, 2021 · 3 comments
Labels

Comments

@suganda7
Copy link

suganda7 commented Aug 20, 2021

Hi team, I found an issue when updating the row for update operation (long text).
here is the test chronology :

  • PostgreSQL 11.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit
  • wal2json11.x86_64 2.3-2.rhel7 @pgdg11
  • CREATE TABLE test ( user_id serial PRIMARY KEY, username VARCHAR ( 50 ), description text );

  • select pg_create_logical_replication_slot('testing', 'wal2json');

  • INSERT INTO public.test (username, description) VALUES('foo',$Put Long text more than 8000 character);

  • SELECT data FROM pg_logical_slot_get_changes('testing', null, null);
    Data pushed perfectly (I can see long string in the message)

  • Update only one column
    UPDATE public.test SET username='hello' WHERE user_id=1;

  • SELECT data FROM pg_logical_slot_get_changes('testing', null, null);

 {
  "change": [
    {
      "kind": "update",
      "schema": "public",
      "table": "test",
      "columnnames": [
        "user_id",
        "username"
      ],
      "columntypes": [
        "integer",
        "character varying(50)"
      ],
      "columnvalues": [
        1,
        "hello"
      ],
      "oldkeys": {
        "keynames": [
          "user_id"
        ],
        "keytypes": [
          "integer"
        ],
        "keyvalues": [
          1
        ]
      }
    }
  ]
}

description column is missing in the message. and for the short text all working fine.

is that expected behavior ? and can we fix this ?

thanks

@eulerto
Copy link
Owner

eulerto commented Aug 29, 2021

Yes. That's the way logical decoding works. It does not include unchanged TOAST columns (your long description seems to be stored as a TOAST value) for performance reasons. Because of that, wal2json does not include that column in the JSON output. However, if you modify the description value, wal2json will include it (see TOAST tests).

In summary, it is a logical decoding limitation, it is not a wal2json bug. When Postgres supports it, wal2json will certainly include these columns too.

@suganda7
Copy link
Author

thank you @eulerto

@mertant
Copy link

mertant commented Mar 15, 2024

That's the way logical decoding works. It does not include unchanged TOAST columns

What constitutes an "unchanged toast"?

If I do UPDATE SET my_toastable_column = my_toastable_column - in other words, perform a "no-op" update on the toast - will it then be considered a "changed toast" even though there is no diff between the old and new value?

If that is the case, then a possible workaround could be: when performing an update operation modifying a non-toast column, set the toast column to the value it already is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants