Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8vC2-0000s9-QB for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jul 2021 01:50:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8vC0-0006Q2-Ce for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jul 2021 01:50:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8vC0-0006Pu-2W for pgsql-hackers@lists.postgresql.org; Thu, 29 Jul 2021 01:50:36 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m8vBx-0003v9-7k for pgsql-hackers@lists.postgresql.org; Thu, 29 Jul 2021 01:50:35 +0000 Received: by mail-pj1-x102d.google.com with SMTP id mz5-20020a17090b3785b0290176ecf64922so13079370pjb.3 for ; Wed, 28 Jul 2021 18:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=eQNuTq0yuwNwaNvRQ6gy9wanq09YdNovCfSvTIWB2NA=; b=FneF9JMUINWpyqF257oeoqPw1lO1VRFtigHqCIoKINOPhFa5KPoxpCv20rXC9LfC3P 4pCU3nYkf0Yjtu7weqaVbqwW+uozJ9Y+pfToHtvcrGfjR4kg7E2F2hYvLoZbS5cVu6oD N6qB5L2jiMDbUTqwGLMZaZVkplevOObY+m44ppU4K3lTwecRyFb9GBQOBTobbtRx/c/A 4m8pngoAg672c/P53eymFB292/KlZCbfUEay0HIWJGp2FJhnm7wJsbMA4bGZ/nPXPhx3 /Sjep1aE5tKq1lVr9Wt/9jGWu/+FXQTcDhF4kEiUjny0PmkZY7OfWpxWZO9tLh9+nd75 35bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=eQNuTq0yuwNwaNvRQ6gy9wanq09YdNovCfSvTIWB2NA=; b=sCLLZMnSVZl3qK/fELoNVbothkfVU9bzZqhRRhofQdYyECnb9JXJ1M6tnr9rVXA9AD KBNXoRAH+3kUBxdGzVFGEIp9b6AhVJKEEG0pPQnrTPStVG0bypKw3JBl9eprxfUhEWpq /fC7v1gwLVLreJAjuvc/dNLzbNil7+IaspFrHamFNAnYkgdIh/njr2zmVqKqXxZmvrwh +DvwKZO8Z6oAPXOjHJk0yMzx6QQVVY+A7Ej8K8SI20zKhY7pPtTl409Y88x+rZLGsLSQ UvOEyalW77TTDRdo4dyhPj1dWjf4Q6bf78xgIFQcZfQ/TUf4x5flu0v4ONoUxEdVwTVB IZLA== X-Gm-Message-State: AOAM533baeWMB+FpkvIDtYVNrTngja5EcBNQtDD7OPmY4RPD28B7Qzki hgH0A/EUul1QOsDy1k+Vzew6xcM49eDrOr+YalI= X-Google-Smtp-Source: ABdhPJzE9fHet20cPG4qNI9Eeutj+Ck0CSu7JHCCh/PTuh5H0w5fEnw8eCqHCvLj9ri6vrqjpdSDGxk0uPTNb/GkZAQ= X-Received: by 2002:a17:902:9688:b029:129:183a:2a61 with SMTP id n8-20020a1709029688b0290129183a2a61mr2416071plp.27.1627523431983; Wed, 28 Jul 2021 18:50:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Thu, 29 Jul 2021 10:49:55 +0900 Message-ID: Subject: Re: Failed transaction statistics to measure the logical replication progress To: "osumi.takamichi@fujitsu.com" Cc: "pgsql-hackers@lists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jul 8, 2021 at 3:55 PM osumi.takamichi@fujitsu.com wrote: > > Hello, hackers > > > When the current HEAD fails during logical decoding, the failure > increments txns count in pg_stat_replication_slots - [1] and adds > the transaction size to the sum of bytes in the same repeatedly > on the publisher, until the problem is solved. > One of the good examples is duplication error on the subscriber side > and this applies to both streaming and spill cases as well. > > This update prevents users from grasping the exact number and size of > successful and unsuccessful transactions. Accordingly, we need to > have new columns of failed transactions that will work to differentiate > both of them for all types, which means spill, streaming and normal > transactions. This will help users to measure the exact status of > logical replication. Could you please elaborate on use cases of the proposed statistics? For example, the current statistics on pg_replication_slots can be used for tuning logical_decoding_work_mem as well as inferring the total amount of bytes passed to the output plugin. How will the user use those statistics? Also, if we want the stats of successful transactions why don't we show the stats of successful transactions in the view instead of ones of failed transactions? > > Attached file is the POC patch for this. > Current design is to save failed stats data in the ReplicationSlot struct= . > This is because after the error, I'm not able to access the ReorderBuffer= object. > Thus, I chose the object where I can interact with at the ReplicationSlot= Release timing. When discussing the pg_stat_replication_slots view, there was an idea to store the slot statistics on ReplicationSlot struct. But the idea was rejected mainly because the struct is on the shared buffer[1]. If we store those counts on ReplicationSlot struct it increases the usage of shared memory. And those statistics are used only by logical slots and don=E2=80=99t necessarily need to be shared among the server processes. Moreover, if we want to add more statistics on the view in the future, it further increases the usage of shared memory. If we want to track the stats of successful transactions, I think it's easier to track them on the subscriber side rather than the publisher side. We can increase counters when applying [stream]commit/abort logical changes on the subscriber. Regards, [1] https://www.postgresql.org/message-id/CAA4eK1Kuj%2B3G59hh3wu86f4mmpQLpa= h_mGv2-wfAPyn%2BzT%3DP4A%40mail.gmail.com --=20 Masahiko Sawada EDB: https://www.enterprisedb.com/