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.96) (envelope-from ) id 1w4vM5-002hLG-1H for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2026 06:35:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4vM3-004lRs-33 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2026 06:35:08 +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.96) (envelope-from ) id 1w4vJ0-004im9-29 for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2026 06:31:59 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4vIy-00000000pT4-2P6q for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2026 06:31:58 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5a27c329e98so4573797e87.3 for ; Mon, 23 Mar 2026 23:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774333916; cv=none; d=google.com; s=arc-20240605; b=gnW4DDU/64FX+m9+9nwIUUEgNf11t+hYrlnmsX6Z+Tu73hnH07dZZXIEbD/IKpbxAX tnluPuy3vGpnZJd5mFkVBAI0HEXnqknZGt6bDJ8HczoVKmYTuMTtjwQgIxD+nXxuDj0m 2ayXA5sKnJaajWN/3iZp2fcslTT5P02etjmwpO4pd4TET0ExSyhq4CJZf/PpMO4XVFI6 MOiOE0mPr317Fd5Xb7yBs6ifa4k2YnWRC59zQEgXZU0NJhGJbBcjfT05DwBf7zTyAvTh bopJqHShMbNIXL0nvhUK3MCkXb04G3smo1B2bgn8Gn0ccO18KWzt2Jz3ABwcYdn3LwxI 44GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Nu/7jyFW2Tm+2YIROCMOTl+3GkdFq6RNpu2B1O8fxqA=; fh=kah5rAEGh92k0B0z7HTckZZM5PHRLUaN2IcOF9SorB0=; b=Oxm4z2Visq4HykCqfQM3GUITwUJav5nNRPo4WhhpyTXIJIFcW68So8OhLQv8HpMoIr 9+Hfy4HX5IF43YDZQLTBzF0SzZ+CVk1WTRBvIv3VMWHt0dmIDSSwHxgmKSv+0PZO/hLs 2tzNolO6ZLBDNUjyLroQTT3L/Z6xTtFkpXlZ4aissKwtYQwDqJULuhBIqzE/31cjPaRF t3ssSLEKc4vXCgFRPe0qDbia4JEqBVet+k+OXysQElISrP02IHYCRmSRruA7wlERJEaP MNyfJhWacp0WhKA25eVfiFL5WgD3jQz1Ftr3wLOreYhlW41/1e/fMvCxr8yLx++IX8/B bs5A==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774333916; x=1774938716; 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=Nu/7jyFW2Tm+2YIROCMOTl+3GkdFq6RNpu2B1O8fxqA=; b=SNj/55aObFQark/xExQOwCOeE36fV7ETb+h0wYhF9k3aAxcldPMgSJ1omuJUhcpJoL 30rLzP8D83Po6jSCq1ssYtON7HdCeMpILeJ3OgWfv9DKvPszWkFeX5G3luMspyzrn5M+ Rt2g8wcVxbBf3phUiF5QRpDk8+iXAeBeKzcGAi9GLdQEK+yRtv9AuETQ9FVmmiOD62eQ SoEMCcFxjgvFNkn7D57D2U/OxNRQiNMhC2FOHHxWmjdr7se25jfOCVt3pgdJuGWWbOxD /Q/VzegZYIJxt80UbWY/nGvCpRWUoRsR/qVQOt7Xlli7ep0XtCLydJwZQAKMuiHfst7q Vstg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774333916; x=1774938716; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Nu/7jyFW2Tm+2YIROCMOTl+3GkdFq6RNpu2B1O8fxqA=; b=UyWnGjSmVOGrM4Nbi9Lmx4k/9Hue01fNiSBv1VCs+eC4uP5fQKCHQtEx1bsTsAHY68 ZyaeCVeUutFB1UDog4qfR1ZW0Xk7hRfGS97FiPRXNAfpO4Ccps3m/5bGbKF0aJ3Ch3w2 koV8BoERgJhVpcKqT2cOAIvmirUkaRZ+Z2ICRvFgDgKpA6AXLk2bRivqI/zF2JKqDmTG L5Kk9A1fMpk2W6ImkHyuaHkl4KzidjBL4CCNyq0MxkN16UbK3lfMwQJxXMv66K/07WHQ d031L0H0j3eiOSG+7CpePElVHJ9JcYW9WDI9bT6mqTS9xGItyt0KamCwlV5YB2ogWin9 uJkg== X-Forwarded-Encrypted: i=1; AJvYcCV9aUdm58lyaYR8SXVXOuVq9Q9hHjUcfC38aNYkMTiQXZJfO8rFH0nk60tzajDnb+KpQk8bGvj/Ei7Ku0ur@lists.postgresql.org X-Gm-Message-State: AOJu0YywqNuFTAV0FVx58cOfCnYdo0NH6u3eqC6sxA4ej17kURej/BL/ K9PFURtB5oHDHNt4k3PFAy0DcALZ7m+3O748UpwP9XMX2UH4KqRVrcbu9AhW2965v0wFIc/rvfw B5h4/Ehuq2LYXmm1o/GsSh6uoO3IhNsU= X-Gm-Gg: ATEYQzwUw/qZ0XahBH5+PVhFtZU6NIafTKzHiSPXk5kud3ZmP6GwkIQ5Sqa2xb234pL v49QcHCDzof32XzGNW1DC2AlZaXHB/LZl1YygVpn/NdQuofgZTQCsC4LQES3gTLwuS0dumLxxmf rtgZaLRaWWmwCvOew4ZSGuegkqz2yCFOHs7c5QacpDDW1H4ROH+8GnNj+9UYGSNxlwqwd8Nt1B/ ck2tBDiDRkkd4IYcX8uzVe1edPRF/FXJsWL+ryb0GSXuv2rBnUWAdwqWtWJA31Rt8Za7QymCy9p U3kecO7txFbDsnNXctAj5nYILdE/BasRh/FpHKc= X-Received: by 2002:a05:6512:68a:b0:5a1:4287:15e6 with SMTP id 2adb3069b0e04-5a285b6e567mr4738424e87.35.1774333916012; Mon, 23 Mar 2026 23:31:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Tue, 24 Mar 2026 12:01:44 +0530 X-Gm-Features: AQROBzDk1gvtqa_FkrWCxxVRzOj679Y4y42CHBRQRntotN0A_N0gYJTzUas3Exg Message-ID: Subject: Re: [Proposal] Adding Log File Capability to pg_createsubscriber To: Chao Li Cc: Gyan Sreejith , =?UTF-8?B?S3Vyb2RhLCBIYXlhdG8v6buS55SwIOmavOS6ug==?= , shveta malik , Shlok Kyal , vignesh C , Euler Taveira , "pgsql-hackers@lists.postgresql.org" , Peter Smith 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 Tue, Mar 24, 2026 at 8:32=E2=80=AFAM Chao Li wr= ote: > > > On Mar 24, 2026, at 09:23, Gyan Sreejith wrot= e: > > > > On Mon, Mar 23, 2026 at 2:24=E2=80=AFAM Chao Li wrote: > > + /* Build timestamp directory path */ > > + len =3D snprintf(logdir, MAXPGPATH, "%s/%s", log_basedir, times= tamp); > > + > > + if (len >=3D MAXPGPATH) > > + pg_fatal("directory path for log files, %s/%s, is too l= ong", > > + logdir, timestamp); > > ``` > > > In the pg_fatal call, I believe logdir should be log_basedir. > > We are writing into logdir, and the if will be true only if it is too l= ong. Hence we should be checking logdir. > > Not sure if I stated my comment clearly. The =E2=80=9Clogdir=E2=80=9D is = build from (=E2=80=9C%s/%s, log_basedir, timestamp), however, in the pg_fat= al, you are printing (=E2=80=9C%s/%s=E2=80=9D, logdir, timestamp), here log= dir has included a truncated timestamp as it is too long, and so the fatal = message will be =E2=80=9Clog_basedir/truncated-timestamp/timestamp=E2=80=9D= . So the pg_fatal should be: > ``` > report_createsub_fatal("directory path for log files, %s/%s, is t= oo long=E2=80=9D, > log_basedir, timestamp); > ``` > > > > > > The biggest problem I see with this patch is here. internal_log_file_= write doesn=E2=80=99t handle =E2=80=9C%m=E2=80=9D. I think we can check the= implementation of pg_log_generic_v how %m is handled. The key code snippet= is: > > ``` > > > errno =3D save_errno; > > > > > va_copy(ap2, ap); > > > required_len =3D vsnprintf(NULL, 0, fmt, ap2) + 1; > > > va_end(ap2); > > ``` > > > Where, vsnprintf points to pg_vsnprintf, and pg_vsnprintf calls dopr = to handle %m. > > I have saved and restored errno similar to that. The code snippet you p= ointed out is, as far as I understand, where they are calculating how much = space to allocate (including the \0 at the end). I think it will be handled= automatically as long as errno is not overwritten - which it will now be. = Thank you! > > I verified with v17, %m works now. > > > > > >The other problem is, with internal_log_file_write, HINT, DETAIL prefi= x are no longer printed, is that intentional? > > I could add a switch-case to print it out. Is that important? What do y= ou think? > > I personally prefer to keep those prefixes, which helps keep the log mess= ages in a consistent style. > +1 to keep HINT, DETAIL kind of prefixes. I have one additional comment in the latest patch: + mode_t oumask; + + oumask =3D umask((mode_t) ((~(S_IRUSR | S_IWUSR)) & (S_IRWXU | S_IRWXG | S_IRWXO))); + fh =3D fopen(filename, mode); + umask(oumask); I think we should follow the permissions model for this file same as what pg_ctl does for log_file given with -l option. Basically, start with with 077 permission and then switch to data_directory permissions. This is because to start server we anyway use pg_ctl with -l option which will use a specific way to assign permissions to server log file, so we should use same for internal file, otherwise, we will end up with different file permissions for internal and server logfile. --=20 With Regards, Amit Kapila.