pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Arnaud L. <arnaud.listes@codata.eu>
To: Luca Ferrari <fluca1978@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: psql \copy hanging
Date: Wed, 28 Aug 2019 10:13:09 +0200
Message-ID: <8dbfafa9-cf8c-c2b5-2bca-846e0d564c68@codata.eu> (raw)
In-Reply-To: <CAKoxK+6HcC+Qh-nHbgVNkJotH5cjbZjCq1J-z-8cDzY7hTRQnw@mail.gmail.com>
References: <d5df5507-7491-5877-5412-c9325d0ec49c@codata.eu>
	<6947a518-82dd-fc26-57b3-6da5e8b89445@codata.eu>
	<CAKoxK+5qWTmmEeGFU8nG3JxGuUKSMUnFtUFkEcjCCYLCWSqaew@mail.gmail.com>
	<4f450814-5697-06b1-651b-540cac0a10b0@codata.eu>
	<CAKoxK+4TWweuGqjpRtcQc3r==3N9mTb=qW0+qPi8YAAev6hhHw@mail.gmail.com>
	<b73603c5-de86-97c3-03fa-15e0499452e4@codata.eu>
	<CAKoxK+7hnFS6N0t57nsSBKGrKO5PjKZ5mRrvuxZ4yz4n0Pv-jg@mail.gmail.com>
	<574a09e0-cf01-4664-c61c-c2d0ae9300f9@codata.eu>
	<89fb69a6-ff8e-9182-4557-e4a3a8ac3905@codata.eu>
	<CAKoxK+6HcC+Qh-nHbgVNkJotH5cjbZjCq1J-z-8cDzY7hTRQnw@mail.gmail.com>

Le 28/08/2019 à 09:43, Luca Ferrari a écrit :
> I don't want to be pedantic, but I would have tried with a single
> change at a time.
> And my bet is: the local file would do the trick (i.e., it is a weird
> share problem).

You're not don't worry. This process is quite important in our workflow 
(not critical), so I can't really afford to make tests for weeks.

Moving the offending line to the end of the script is what I'd consider 
"single change". To me it makes something clear : the problem occurs 
only at the very specific time this command is running.


> If you are going to invest some time, you could also try to write a
> small file on the share just before the copy starts, so that you are
> guaranteed the share is working. Something like:
> 
> echo $(date) >> $SHARE/log.txt
> psql 'copy ...'
> echo 'done' >> $SHARE/log.txt

Well, I do know that the share is working just before this command runs 
because ALL the commands in the script write to this specific share.
The script is basically outputting many views results in a single share, 
something like :
\copy (select * from view1) TO '\\myserver\myshare\file1.csv'
\copy (select * from view2) TO '\\myserver\myshare\file2.csv'
...
\copy (select * from view99) TO '\\myserver\myshare\file99.csv'
So the \copy command right before (say view15 for instance) is writing 
to this same share just milliseconds before the the problematic command 
(view16) tries to do the same.
Since this particular view takes some time to execute, there is some 
time between the moment the file gets created on the share (which 
happens immediately when the \copy command runs if I get it right), and 
the moment psql receives content and starts writing to it (my tests 
suggest 1min to 1min30s). Either psql doesn't receive anything 
(possible, since the connection is marked as active but it does not look 
as if it's doing anything at all), or there has been some timeout.
It could have been tcp keepalive, but in Windows the default is 2h I 
believe and postgresql uses system default if nothing is specified in 
conf (which is my case).

So with all this in mind I'd rather think I have a problem with either 
psql's \copy or with my query on the server side. But I'm not rulling 
anything out of course.

One other thing I could try is using COPY TO STDOUT \g. From what I 
understand in the documentation this would not be 100% similar to what 
\copy is doing.
Anyway, if it works with the current setup I won't dig into it much deeper.

Cheers
--
Arnaud












view thread (40+ messages)  latest in thread

Message-ID: <8dbfafa9-cf8c-c2b5-2bca-846e0d564c68@codata.eu>
Permalink:  ../8dbfafa9-cf8c-c2b5-2bca-846e0d564c68@codata.eu/
Also on:    postgresql.org/message-id/8dbfafa9-cf8c-c2b5-2bca-846e0d564c68@codata.eu

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: arnaud.listes@codata.eu, fluca1978@gmail.com
  Subject: Re: psql \copy hanging
  In-Reply-To: <8dbfafa9-cf8c-c2b5-2bca-846e0d564c68@codata.eu>
  References: <d5df5507-7491-5877-5412-c9325d0ec49c@codata.eu> <6947a518-82dd-fc26-57b3-6da5e8b89445@codata.eu> <CAKoxK+5qWTmmEeGFU8nG3JxGuUKSMUnFtUFkEcjCCYLCWSqaew@mail.gmail.com> <4f450814-5697-06b1-651b-540cac0a10b0@codata.eu> <CAKoxK+4TWweuGqjpRtcQc3r==3N9mTb=qW0+qPi8YAAev6hhHw@mail.gmail.com> <b73603c5-de86-97c3-03fa-15e0499452e4@codata.eu> <CAKoxK+7hnFS6N0t57nsSBKGrKO5PjKZ5mRrvuxZ4yz4n0Pv-jg@mail.gmail.com> <574a09e0-cf01-4664-c61c-c2d0ae9300f9@codata.eu> <89fb69a6-ff8e-9182-4557-e4a3a8ac3905@codata.eu> <CAKoxK+6HcC+Qh-nHbgVNkJotH5cjbZjCq1J-z-8cDzY7hTRQnw@mail.gmail.com> <8dbfafa9-cf8c-c2b5-2bca-846e0d564c68@codata.eu>

* 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