pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Maciek Sakrejda <msakrejda@truviso.com>
To: pgsql-jdbc@postgresql.org
Subject: PGStream synchronization
Date: Wed, 26 Aug 2009 23:36:43 -0700
Message-ID: <895e58dd0908262336o4d3eb445te833a9f4cef2958b@mail.gmail.com> (raw)
In-Reply-To: <895e58dd0908262334k20544c1el292dc972f38c65b2@mail.gmail.com>
References: <895e58dd0908241736q3575cdc2v461d879c5b5f9dcb@mail.gmail.com>
	<4A9334C4.2060503@opencloud.com>
	<895e58dd0908250815m1a8aada0qc9d3f0bde9c7a303@mail.gmail.com>
	<895e58dd0908250951m1aa4baabnf1695c9e681aa278@mail.gmail.com>
	<4A946B7A.60408@opencloud.com>
	<895e58dd0908260201g59762012ka2349eada052ab6d@mail.gmail.com>
	<4A95CE4B.5050107@opencloud.com>
	<895e58dd0908261737t20f5b7dbsd9ae546a34264a7@mail.gmail.com>
	<4A95D980.3070809@opencloud.com>
	<895e58dd0908262334k20544c1el292dc972f38c65b2@mail.gmail.com>

(missed CCing the list on my reply to Oliver)

> How about, instead of using raw monitor synchronization to provide
> mutual exclusion on access to the stream, we use a lock object (i.e.
> something similar to java.util.concurrent.locks.Lock, though we can't
> use exactly that class before 1.5 obviously), try to grab the lock
> before close, and behave differently depending on if we succeeded or not.
>
> So the close logic can look something like this:
>
>  if (lock.tryLock()) {
>    // we have exclusive access to the connection
>    // do a normal shutdown
>    try {
>      sendTerminate();
>      stream.close();
>    } finally {
>      lock.unlock();
>    }
>  } else {
>    // something is concurrently using the connection
>    // just abruptly close the connection
>    stream.close();
>  }
>
> In the concurrent case, we don't send Terminate, but we also don't risk
> sending it at the wrong point in the stream.
>
> This means that a concurrent Connection.close() while something is
> happening will result in an "unexpected client EOF" logged on the server
> side, but that's almost what you want in this case anyway .. concurrent
> close pretty much means "help, abort this!" ..
>
> -O
>

That's interesting. I think it's not quite in the spirit of the
protocol, but there may not be much more we can do, and it's certainly
a reasonable behavior. I'd like to spend some more time with the FEBE
spec tomorrow and then I'll submit a patch based on this approach.

Thanks,
--
Maciek Sakrejda | Software Engineer | Truviso
(650) 242-3500 Main
(650) 242-3501 F
msakrejda@truviso.com
www.truviso.com



view thread (12+ messages)  latest in thread

Message-ID: <895e58dd0908262336o4d3eb445te833a9f4cef2958b@mail.gmail.com>
Permalink:  ../895e58dd0908262336o4d3eb445te833a9f4cef2958b@mail.gmail.com/
Also on:    postgresql.org/message-id/895e58dd0908262336o4d3eb445te833a9f4cef2958b@mail.gmail.com

 · 

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-jdbc@postgresql.org
  Cc: msakrejda@truviso.com
  Subject: Re: PGStream synchronization
  In-Reply-To: <895e58dd0908262336o4d3eb445te833a9f4cef2958b@mail.gmail.com>
  References: <895e58dd0908241736q3575cdc2v461d879c5b5f9dcb@mail.gmail.com> <4A9334C4.2060503@opencloud.com> <895e58dd0908250815m1a8aada0qc9d3f0bde9c7a303@mail.gmail.com> <895e58dd0908250951m1aa4baabnf1695c9e681aa278@mail.gmail.com> <4A946B7A.60408@opencloud.com> <895e58dd0908260201g59762012ka2349eada052ab6d@mail.gmail.com> <4A95CE4B.5050107@opencloud.com> <895e58dd0908261737t20f5b7dbsd9ae546a34264a7@mail.gmail.com> <4A95D980.3070809@opencloud.com> <895e58dd0908262334k20544c1el292dc972f38c65b2@mail.gmail.com> <895e58dd0908262336o4d3eb445te833a9f4cef2958b@mail.gmail.com>

* 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