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 1vaB9R-004lym-1n for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 11:11:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vaB9Q-00GfDZ-1o for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 11:11:01 +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 1vaB9Q-00GfDR-0s for pgsql-hackers@lists.postgresql.org; Mon, 29 Dec 2025 11:11:01 +0000 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vaB9O-003O7V-2p for pgsql-hackers@lists.postgresql.org; Mon, 29 Dec 2025 11:11:00 +0000 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-78fba1a1b1eso102239337b3.1 for ; Mon, 29 Dec 2025 03:10:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767006657; x=1767611457; 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=phzh0/lLtjwZ4sa8i6vdkKk+kt2hEv6ThQ9IJtTwAAk=; b=H+p1+KgkvbFQ1Vj7LCmJS6qnTb0F/dfuz8U2uAy+wRuj4d8YS/p0xiXQ+TIP5xPqrH HHHLSNn2jtqpwmCj7BczDDEhaibaFsGLlMcWemAeNZpI9mQa90bgMMo9dxD/z4cl69hh FehmHoCvk75IkIhhbNdDNP6iYW2yIh3N2M8MtSr1TkwutAtNyWFxyeTqtsk+XUmwrWmZ qviNowZ39qeEyC3bA+wD4A9Orhn3l1ylz+iJThBJNuxpI6Hf9Ovxkv+YSWdG3V8xULGW wsgrvydmi4+pHxB5t85Mgo3ooJNimVGPU1imvIWWn8Di4g0kSkPbKvru0nj0sSqwlfII fB0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767006657; x=1767611457; 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=phzh0/lLtjwZ4sa8i6vdkKk+kt2hEv6ThQ9IJtTwAAk=; b=pjLoktHjL2HBCmA0fyAfW8qwRUI2pM/xwTu7H3kWDOiTj9Ev9BIWvivMaBjPwEI5bS ok3spBVYUhisblVVOfzH9uRHbyOV0sguj3evY+f0CQ8CGW290D0vu/kAo3GUseEICwU+ ozlpseznKArLnZ6fAoiqdJ6BKoyVKjcDZJOsG6++eaDiYPQ4oQKcu2F9KDYbiPgEWMu4 WApkCoXgGX+l/7X17g3kjP0/Q5vguD5ZHQ/P0zGQtq1ruwJ1ngk1zfarNZybOde2ORA9 lJq/yAJ88AOq6niiE9xIf1LH9mqY03poiZWCBZEbCYVJgCIvlEZX6J86uZzo895qA9uj 9E0A== X-Forwarded-Encrypted: i=1; AJvYcCUwDtT2fF12A6zS5vysV7/J9yXciNjVsN62aCcQlIHeC70LXKbEd1VGaf0TVFLynN7J/DIjWDfuBEe05w4J@lists.postgresql.org X-Gm-Message-State: AOJu0YyT9P0rpyTlVLXzb0UqpHxRBuI1r7lrbl1dhRmq79stbBSRB4X8 H70p2Jf8I+v1ZbJQun30vwchA9qCc9Dd0w7FKE9Ro8P5a0KQAit5+PMp0X8R2Z0yCtc6WkZIRa5 +FksiIRfXvGaj7YjFw+JokNangghPFx0= X-Gm-Gg: AY/fxX4B3fM/KIPg9XUVhOhF8XKrGeIlZ6Fx4z9guQwUpu6UKBmUJeoAMtTAbl7RNrM OLALi5z7EXIbp3LSjXtWvWrcVD6jZKsHwSrHZ/lPv8p5XtGMcISG0GiezfN8FobxJxfW2dENJhq 3MlJD5VQYsuKv6xzcyZ2NGE8R4xzRkEku3gGV1e7KpcJCgD6kVEF9+oJAsVGgrGJBDcoK6UHZQ7 J6cBgUyLn0m9wB6tqMsDO7H5I4iobIKq1380K4Tug8R10kcwio8UWaibPaD77IZ9o8cWS15mA== X-Google-Smtp-Source: AGHT+IHq3YA8BSPkl+1SzuoHDqwVz//hAHKfIJQtCYJp4aNQSxiFmxSplpmbgcEyfMze3g2aKrYi/6IevVCzmeayxZU= X-Received: by 2002:a05:690e:130e:b0:640:ca9a:5f5b with SMTP id 956f58d0204a3-6466322750fmr23615941d50.1.1767006657509; Mon, 29 Dec 2025 03:10:57 -0800 (PST) MIME-Version: 1.0 References: <48261e54-c4f1-4bde-a4a9-4f3698a6b380@app.fastmail.com> In-Reply-To: From: vignesh C Date: Mon, 29 Dec 2025 16:40:46 +0530 X-Gm-Features: AQt7F2oSNaXD8jGnUpPk-ZnwTyKOFeZgP1dHgLZIIuQ6Ft1FV4BqvyybWoi7X0o Message-ID: Subject: Re: [Proposal] Adding Log File Capability to pg_createsubscriber To: Gyan Sreejith Cc: Amit Kapila , Euler Taveira , "kuroda.hayato@fujitsu.com" , "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 Wed, 24 Dec 2025 at 04:52, Gyan Sreejith wrote= : > > Thank you for the feedback everybody. As I read through this email chain,= I found differing opinions on how logging should be implemented. This ambi= guity leaves me unsure as to which solution(s) to pursue. As of right now, = I have attached the git-format patch like Hayato Kuroda recommended (but it= does not have any new changes). I am willing to implement whatever solutio= n when we reach a consensus. Few comments: 1) The file permissions are 664 for pg_createsubscriber_internal.log, pg_createsubscriber_resetwal.log but 600 for pg_createsubscriber_server.log. The permissions should be the same for all the files. ... if (opt->log_dir !=3D NULL) out_file =3D psprintf("%s/pg_createsubscriber_resetwal.log", opt->log_dir); else out_file =3D DEVNULL; cmd_str =3D psprintf("\"%s\" -D \"%s\" > \"%s\"", pg_resetwal_path, subscriber_dir, out_file); pg_log_debug("pg_resetwal command is: %s", cmd_str); ... ... if (opt->log_dir !=3D NULL) { appendPQExpBuffer(pg_ctl_cmd, " -l %s/pg_createsubscriber_server.log", opt->log_dir); } pg_log_debug("pg_ctl command is: %s", pg_ctl_cmd->data); rc =3D system(pg_ctl_cmd->data); ... 2) Can you gracefully handle the case where permissions are not enough in the directory and throw proper error: if (stat(opt.log_dir, &statbuf) !=3D 0) { if (errno =3D=3D ENOENT) { mkdir(opt.log_dir, S_IRWXU); pg_log_info("log directory created"); } else pg_fatal("could not access directory \"%s\": %m", opt.log_dir); } 3) Currently there is no timestamp included for pg_createsubscriber_internal and pg_createsubscriber_resetwal log file contents. Without that it is difficult to tell when the operations were done. It will be good to include them. 4) The patch does not apply on the head, kindly rebase on top of head. 5) Do you need to open and close the log file each time? ... if (internal_log_file !=3D NULL) { if ((fp =3D fopen(internal_log_file, "a")) =3D=3D NULL) pg_fatal("could not write to log file \"%s\": %m", internal_log_file); fprintf(fp, "checking settings on subscriber\n"); fclose(fp); } else pg_log_info("checking settings on subscriber"); ... ... if (internal_log_file !=3D NULL) { if ((fp =3D fopen(internal_log_file, "a")) =3D=3D NULL) pg_fatal("could not write to log file \"%s\": %m", internal_log_file); fprintf(fp, "checking settings on publisher\n"); fclose(fp); } else pg_log_info("checking settings on publisher"); ... Regards, Vignesh