Re: pg_test_fsync problem - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: pg_test_fsync problem
Date
Msg-id 201101250043.p0P0h2R11196@momjian.us
Whole thread Raw
In response to Re: pg_test_fsync problem  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> I wrote:
> > He's complaining that it dies with EINVAL.
>
> > I notice that (1) it's using O_DIRECT even though the printout claims
> > otherwise, and (2) it's writing from a buffer that has no better than
> > char alignment, which is certainly not OK for O_DIRECT.  Either one
> > of those could plausibly result in EINVAL ...
>
> Oh, scratch that: the buffer is properly aligned, it's the length that's
> bogus for O_DIRECT.  I rather imagine that test_open_sync is meant to be
> writing so many kilobytes, not so many bytes.

Yes, that was a bug in my code that I have fixed with the attached,
applied patch.  Thanks for the report.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/contrib/pg_test_fsync/pg_test_fsync.c b/contrib/pg_test_fsync/pg_test_fsync.c
index 7ece9b9..d8099a5 100644
*** /tmp/pgdiff.10514/8NsZJd_pg_test_fsync.c    Mon Jan 24 19:41:20 2011
--- contrib/pg_test_fsync/pg_test_fsync.c    Mon Jan 24 19:39:48 2011
*************** test_open_sync(const char *msg, int writ
*** 421,427 ****
          for (ops = 0; ops < ops_per_test; ops++)
          {
              for (writes = 0; writes < 16 / writes_size; writes++)
!                 if (write(tmpfile, buf, writes_size) != writes_size)
                      die("write failed");
              if (lseek(tmpfile, 0, SEEK_SET) == -1)
                  die("seek failed");
--- 421,428 ----
          for (ops = 0; ops < ops_per_test; ops++)
          {
              for (writes = 0; writes < 16 / writes_size; writes++)
!                 if (write(tmpfile, buf, writes_size * 1024) !=
!                     writes_size * 1024)
                      die("write failed");
              if (lseek(tmpfile, 0, SEEK_SET) == -1)
                  die("seek failed");

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Use of O_DIRECT only for open_* sync options
Next
From: Robert Haas
Date:
Subject: Re: Patch to add a primary key using an existing index