From: Michael Paquier <michael@paquier.xyz>
To: Jacob Champion <pchampion@vmware.com>
Cc: magnus@hagander.net <magnus@hagander.net>
Cc: stark@mit.edu <stark@mit.edu>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: sfrost@snowman.net <sfrost@snowman.net>
Cc: tgl@sss.pgh.pa.us <tgl@sss.pgh.pa.us>
Subject: Re: Proposal: Save user's original authenticated identity for logging
Date: Thu, 18 Mar 2021 17:14:24 +0900
Message-ID: <YFML4MDZVWWuIBTF@paquier.xyz> (raw)
In-Reply-To: <e3f7433d3e2bf31e8f67a9fb3790f660b7af586e.camel@vmware.com>
References: <c55788dd1773c521c862e8e0dddb367df51222be.camel@vmware.com>
<a9ee5e4e8e844d06c2bcf70c6ed3306ccb4897f1.camel@vmware.com>
<5d8b74e64fe4a610b23624277e497cc0a925db4b.camel@vmware.com>
<2870147caa759155c5c8a232bbd2399f41f76491.camel@vmware.com>
<4b2ca51542fa84e6fa37ab678624d5b400c092c0.camel@vmware.com>
<CABUevExVHryTasKmtJW5RtU-dBesYj4bV7ggpeVMfiPCHCvLNA@mail.gmail.com>
<a2fab8e350c86aa4fe245d1af521b0bbc807f11e.camel@vmware.com>
<fc536fc557a664ad7b9dc0bf46ea335039044905.camel@vmware.com>
<679382aaff23627a2e53541322c7a3158d402394.camel@vmware.com>
<e3f7433d3e2bf31e8f67a9fb3790f660b7af586e.camel@vmware.com>
On Mon, Mar 15, 2021 at 03:50:48PM +0000, Jacob Champion wrote:
> # might need to retry if logging collector process is slow...
> my $max_attempts = 180 * 10;
> my $first_logfile;
> for (my $attempts = 0; $attempts < $max_attempts; $attempts++)
> {
> $first_logfile = slurp_file($node->data_dir . '/' . $lfname);
> - last if $first_logfile =~ m/\Q$expect_log_msg\E/;
> +
> + # Don't include previously matched text in the search.
> + $first_logfile = substr $first_logfile, $current_log_position;
> + if ($first_logfile =~ m/\Q$expect_log_msg\E/g)
> + {
> + $current_log_position += pos($first_logfile);
> + last;
> + }
> +
> usleep(100_000);
Looking at 0001, I am not much a fan of relying on the position of the
matching pattern in the log file. Instead of relying on the logging
collector and one single file, why not just changing the generation of
the logfile and rely on the output of stderr by restarting the server?
That means less tests, no need to wait for the logging collector to do
its business, and it solves your problem. Please see the idea with
the patch attached. Thoughts?
--
Michael
Attachments:
[text/x-diff] krb5-tap-simplify.patch (1.6K, ../YFML4MDZVWWuIBTF@paquier.xyz/2-krb5-tap-simplify.patch)
download | inline diff:diff --git a/src/test/kerberos/t/001_auth.pl b/src/test/kerberos/t/001_auth.plindex 079321bbfc..aca673e97a 100644--- a/src/test/kerberos/t/001_auth.pl+++ b/src/test/kerberos/t/001_auth.pl@@ -20,7 +20,7 @@ use Time::HiRes qw(usleep);
if ($ENV{with_gssapi} eq 'yes')
{
- plan tests => 34;+ plan tests => 26;
}
else
{
@@ -170,7 +170,6 @@ $node->append_conf(
'postgresql.conf', qq{
listen_addresses = '$hostaddr'
krb_server_keyfile = '$keytab'
-logging_collector = on
log_connections = on
# these ensure stability of test results:
log_rotation_age = 0
@@ -212,27 +211,13 @@ sub test_access
# Verify specified log message is logged in the log file.
if ($expect_log_msg ne '')
{
- my $current_logfiles = slurp_file($node->data_dir . '/current_logfiles');- note "current_logfiles = $current_logfiles";- like($current_logfiles, qr|^stderr log/postgresql-.*log$|,- 'current_logfiles is sane');-- my $lfname = $current_logfiles;- $lfname =~ s/^stderr //;- chomp $lfname;-- # might need to retry if logging collector process is slow...- my $max_attempts = 180 * 10;- my $first_logfile;- for (my $attempts = 0; $attempts < $max_attempts; $attempts++)- {- $first_logfile = slurp_file($node->data_dir . '/' . $lfname);- last if $first_logfile =~ m/\Q$expect_log_msg\E/;- usleep(100_000);- }-+ my $first_logfile = slurp_file($node->logfile);
like($first_logfile, qr/\Q$expect_log_msg\E/,
- 'found expected log file content');+ 'found expected log file content');++ # Rotate to a new file, for any follow-up check.+ $node->rotate_logfile;+ $node->restart;
}
return;
[application/pgp-signature] signature.asc (832B, ../YFML4MDZVWWuIBTF@paquier.xyz/3-signature.asc)
download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: michael@paquier.xyz, pchampion@vmware.com, magnus@hagander.net, stark@mit.edu, sfrost@snowman.net, tgl@sss.pgh.pa.us
Subject: Re: Proposal: Save user's original authenticated identity for logging
In-Reply-To: <YFML4MDZVWWuIBTF@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox