Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rl1qk-00H9Yg-F7 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2024 07:19:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rl1qh-006bdZ-PY for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2024 07:19:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rl1qh-006bdQ-DH for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2024 07:19:27 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rl1qa-004cKh-VI for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2024 07:19:27 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-513d212f818so1787332e87.2 for ; Fri, 15 Mar 2024 00:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710487160; x=1711091960; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RpHE4Qy/NNwqTh1E5DrgtkmZDVivbMXBXk1tLs4hvbk=; b=HT3ty4kVY8LVCC3pvJR9hYKMd6ZjyRxOcDPkrife0UCPgdbkeGoNZekk6J/Gb4oy+u LbjWRFecTP20F47PNwqo+J+TEetcQRZhdl1HZVZb6tGnCFNWIuJTqIykod0mFl237Lwv +fI8hV/3JcIzwOWlYsAsdEzS3p+wDUzh0dMRGx3I1RLLngFj2ygGI5/CP+U5kbeZRiW8 3mfgBNJ7eJw9WoRO38frPswhePVD5KBacNgKTAh1Zx+H/XuNlQgQ1a7G7FDD1nQ8PzPG DnuthPtCrlpFLaEarRVW69kNIbynKA/culcxOrX4oMQTGpYyHA5tCneeQvxAtWL0MwB6 OCng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710487160; x=1711091960; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RpHE4Qy/NNwqTh1E5DrgtkmZDVivbMXBXk1tLs4hvbk=; b=Hg1PtvrxHnF2HeDJQo9qpkwsIT+IbwPNO6CySRWVooZEwSrKgsxldIlXobCc4HhH3Q LJQPfUoTXPn5fOeb+p37faugry6+P5EBnOoH2Dy1UTmmM9pPpppGRIkXAXEKr6NiI4Vb HmkQHipAVCBJCB/sWdvK/t6BeNXhEz67dFZwlgC/xkoD7bN9pP+6baaug7VJzpBgBNos lD08EElfWno50uS3po6xOxG5X3OF6K0vdyX5WPTgq1MoFu1YSXy0VdzZD9vKzorXGoPk IMdsM5UHSkVvTXLSkwgjYlvHBt97ATpoHTP25XhCw3YmA4j+UmDIXhvlrfo1m5kv6v7d VE0Q== X-Forwarded-Encrypted: i=1; AJvYcCXlxTQzXpKl4VdH33Tkx3B3Jn/vccO5MZueYs3qYJG2mJOVlCy+SGrfzBtSaZUH79Qp/Fp99Y4JjFrY7yo55o7YnHiyRw1+ONtuSwEFhIDIgspM X-Gm-Message-State: AOJu0YwTi72hAwqoDTFkYe9NOoklgyac3hQShI8s5ICeVs+blA9y+zWq ZqIeMpFTAf2MxhnJ/wHJ+4V3anSyt6p9gJ1Zp4tifzuKbdNjIe+/jMb4r/u9A+5O9i19nee5XRo UeIrVc9ZiNL79aTVU/EAwEVYb2LE= X-Google-Smtp-Source: AGHT+IGAUPJhffEt151OWe2Nr+GquMv/yjLoMGjCa7h2I7MspZH1h+1udIcRoWOBB8T4V0AJO1lruFT9+xmjaG+1OJ8= X-Received: by 2002:ac2:4649:0:b0:513:ba35:cacd with SMTP id s9-20020ac24649000000b00513ba35cacdmr1613916lfo.39.1710487159604; Fri, 15 Mar 2024 00:19:19 -0700 (PDT) MIME-Version: 1.0 References: <20240301221108.GB3024365@nathanxps13> <20240303214434.GA3036597@nathanxps13> In-Reply-To: From: shveta malik Date: Fri, 15 Mar 2024 12:49:07 +0530 Message-ID: Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation To: Bharath Rupireddy Cc: Amit Kapila , Nathan Bossart , Bertrand Drouvot , PostgreSQL Hackers , shveta malik 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, Mar 14, 2024 at 7:58=E2=80=AFPM Bharath Rupireddy wrote: > > While we wait to hear from others on this, I'm attaching the v9 patch > set implementing the above idea (check 0001 patch). Please have a > look. I'll come back to the other review comments soon. > patch002: 1) I would like to understand the purpose of 'inactive_count'? Is it only for users for monitoring purposes? We are not using it anywhere internally. I shutdown the instance 5 times and found that 'inactive_count' became 5 for all the slots created on that instance. Is this intentional? I mean we can not really use them if the instance is down. I felt it should increment the inactive_count only if during the span of instance, they were actually inactive i.e. no streaming or replication happening through them. 2) slot.c: + case RS_INVAL_XID_AGE: + { + if (TransactionIdIsNormal(s->data.xmin)) + { + .......... + } + if (TransactionIdIsNormal(s->data.catalog_xmin)) + { + .......... + } + } Can we optimize this code? It has duplicate code for processing s->data.catalog_xmin and s->data.xmin. Can we create a sub-function for this purpose and call it twice here? thanks Shveta