pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
commit problem
9+ messages / 4 participants
[nested] [flat]

* commit problem
@ 2012-10-25 20:12  John R Pierce <pierce@hogranch.com>
  0 siblings, 3 replies; 9+ messages in thread

From: John R Pierce @ 2012-10-25 20:12 UTC (permalink / raw)
  To: pgsql-jdbc

my Java developers are telling me, the recent JDBC drivers are throwing 
an exception if they inadvertantly issue a commit() on an autocommit 
connection.    this is causing a bunch of problems for us, we have a 
huge code base of java jdbc software which was originally written for 
Oracle, and it assumes that read only operations are NOT starting a 
transaction block (apparently Oracle only starts a transaction block on 
DML like insert/update/delete/select for update/etc.).   We have long 
running threads which just do SELECTs and others that do transactions, 
some which can do either of these depending on external events.    We've 
tried to make the SELECT only connections 'autocommit' so they don't 
start transaction blocks, and we've tried to enforce .Commit() on other 
situations, but the code is complex enough that sometimes the wires get 
crossed, and a Commit() s done on an autocommit connection.       All of 
this is to prevent gigenormous data bloating from week-long <IDLE> in 
transactions.

in the JDBC releases for PG 8.x, this was quietly ignored.   On the new 
9.x JDBC releases, this crashes with an ugly exception.

My very-oracle-centric lead SQL developer is trying to use this as yet 
another excuse not to use Postgres as in his opinion, Oracle just 'does 
what you want'.  ok, it does what HE wants, meh.

Meanwhile, these random crashes that only show up under full production 
volume workloads (at our deployment sites in Asia) are freaking out the 
operations people, who ALSO are becoming afraid of Postgres.



-- 
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: commit problem
@ 2012-10-25 20:44  Dave Cramer <pg@fastcrypt.com>
  parent: John R Pierce <pierce@hogranch.com>
  2 siblings, 0 replies; 9+ messages in thread

From: Dave Cramer @ 2012-10-25 20:44 UTC (permalink / raw)
  To: John R Pierce <pierce@hogranch.com>; +Cc: pgsql-jdbc

So ... looking at the API this is clearly unambiguous. A rarity in JDBC

from the api specs ...

void commit()
            throws SQLException
Makes all changes made since the previous commit/rollback permanent
and releases any database locks currently held by this Connection
object. This method should be used only when auto-commit mode has been
disabled.
Throws:
SQLException - if a database access error occurs, this method is
called while participating in a distributed transaction, if this
method is called on a closed conection or this Connection object is in
auto-commit mode
See Also:
setAutoCommit(boolean)


So it would appear oracle is breaking their own API.

Thoughts ?

<tongue in cheek>
BTW, you might suggest to your Oracle centric dev that he pay the
difference for the licenses if he really wants Oracle
</tongue in cheek>

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Thu, Oct 25, 2012 at 4:12 PM, John R Pierce <pierce@hogranch.com> wrote:
> my Java developers are telling me, the recent JDBC drivers are throwing an
> exception if they inadvertantly issue a commit() on an autocommit
> connection.    this is causing a bunch of problems for us, we have a huge
> code base of java jdbc software which was originally written for Oracle, and
> it assumes that read only operations are NOT starting a transaction block
> (apparently Oracle only starts a transaction block on DML like
> insert/update/delete/select for update/etc.).   We have long running threads
> which just do SELECTs and others that do transactions, some which can do
> either of these depending on external events.    We've tried to make the
> SELECT only connections 'autocommit' so they don't start transaction blocks,
> and we've tried to enforce .Commit() on other situations, but the code is
> complex enough that sometimes the wires get crossed, and a Commit() s done
> on an autocommit connection.       All of this is to prevent gigenormous
> data bloating from week-long <IDLE> in transactions.
>
> in the JDBC releases for PG 8.x, this was quietly ignored.   On the new 9.x
> JDBC releases, this crashes with an ugly exception.
>
> My very-oracle-centric lead SQL developer is trying to use this as yet
> another excuse not to use Postgres as in his opinion, Oracle just 'does what
> you want'.  ok, it does what HE wants, meh.
>
> Meanwhile, these random crashes that only show up under full production
> volume workloads (at our deployment sites in Asia) are freaking out the
> operations people, who ALSO are becoming afraid of Postgres.
>
>
>
> --
> john r pierce                            N 37, W 122
> santa cruz ca                         mid-left coast
>
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: commit problem
@ 2012-10-25 20:45  Kevin Grittner <kgrittn@mail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Kevin Grittner @ 2012-10-25 20:45 UTC (permalink / raw)
  To: John R Pierce <pierce@hogranch.com>; pgsql-jdbc

John R Pierce wrote:

> my Java developers are telling me, the recent JDBC drivers are
> throwing an exception if they inadvertantly issue a commit() on an
> autocommit connection.

Which is what seems to be required by the API:

http://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html#commit%28%29

> My very-oracle-centric lead SQL developer is trying to use this as
> yet another excuse not to use Postgres as in his opinion, Oracle
> just 'does what you want'.

Or rather, whatever it wants, regardless of standards and API
definitions. An API currently published by... Oracle?

> Meanwhile, these random crashes that only show up under full
> production volume workloads (at our deployment sites in Asia) are
> freaking out the operations people, who ALSO are becoming afraid of
> Postgres.

Sounds ugly. What I wonder is why the your development team doesn't
route all transaction completions through a common method. I have
always seen that as the only sane way to do it. Then you have one
place where you can change:

    conn.commit();

to:

    if (conn.getAutoCommit() == false)
        conn.commit();

I would be afraid of developers who seem to be either unable to
manage development in a way that prevents such problems, or willing
to let preventable problems happen to try to "prove a point".  I hope
you have managers above this lead SQL developer who will ask him why
he hasn't made this work when so many other developers can do so. Is
he simply not as good as the developers at all these other companies
who solve such problems, or is he unwilling to do so?  Is there a 3rd
option there?

-Kevin




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: commit problem
@ 2012-10-25 21:48  John R Pierce <pierce@hogranch.com>
  parent: Kevin Grittner <kgrittn@mail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: John R Pierce @ 2012-10-25 21:48 UTC (permalink / raw)
  To: pgsql-jdbc

On 10/25/12 1:45 PM, Kevin Grittner wrote:
> Sounds ugly. What I wonder is why the your development team doesn't
> route all transaction completions through a common method. I have
> always seen that as the only sane way to do it. Then you have one
> place where you can change:
>
>      conn.commit();

because my developers don't think simple reads ARE a transaction.



-- 
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: commit problem
@ 2012-10-25 21:56  Thomas Kellerer <spam_eater@gmx.net>
  parent: John R Pierce <pierce@hogranch.com>
  2 siblings, 0 replies; 9+ messages in thread

From: Thomas Kellerer @ 2012-10-25 21:56 UTC (permalink / raw)
  To: pgsql-jdbc

John R Pierce wrote on 25.10.2012 22:12:
> my Java developers are telling me, the recent JDBC drivers are
> throwing an exception if they inadvertantly issue a commit() on an
> autocommit connection.

Just for the record:

Apparently there is no consensus on this behaviour (even though it's clearly required according to the JDBC specs)

MySQL, the jTDS driver for SQL Server and Firebird also throw an exeption in that case.

The Microsoft driver, DB2, Derby, h2 and HSQLDB do not throw an exception just like the Oracle driver.






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: commit problem
@ 2012-10-25 22:04  Kevin Grittner <kgrittn@mail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Kevin Grittner @ 2012-10-25 22:04 UTC (permalink / raw)
  To: John R Pierce <pierce@hogranch.com>; pgsql-jdbc

John R Pierce wrote:
> On 10/25/12 1:45 PM, Kevin Grittner wrote:
> > Sounds ugly. What I wonder is why the your development team doesn't
> > route all transaction completions through a common method. I have
> > always seen that as the only sane way to do it. Then you have one
> > place where you can change:
> >
> > conn.commit();
> 
> because my developers don't think simple reads ARE a transaction.
> 
> 
> 
> -- 
> john r pierce N 37, W 122
> santa cruz ca mid-left coast
> 
> 
> 
> -- 
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: commit problem
@ 2012-10-25 22:07  Thomas Kellerer <spam_eater@gmx.net>
  parent: John R Pierce <pierce@hogranch.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Thomas Kellerer @ 2012-10-25 22:07 UTC (permalink / raw)
  To: pgsql-jdbc

John R Pierce wrote on 25.10.2012 23:48:
> because my developers don't think simple reads ARE a transaction.
>

Then they haven't read the concepts manual of Oracle.
Because a SELECT statement *is* (and starts) a transaction in Oracle as well.








^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: commit problem
@ 2012-10-25 22:09  Thomas Kellerer <spam_eater@gmx.net>
  parent: John R Pierce <pierce@hogranch.com>
  2 siblings, 0 replies; 9+ messages in thread

From: Thomas Kellerer @ 2012-10-25 22:09 UTC (permalink / raw)
  To: pgsql-jdbc

John R Pierce wrote on 25.10.2012 22:12:
> in the JDBC releases for PG 8.x, this was quietly ignored.   On the
> new 9.x JDBC releases, this crashes with an ugly exception.

You can always get the driver's source, change it and compile your own version.
Something you can't do with Oracle in case it doesn't do what you want.
  





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: commit problem
@ 2012-10-25 22:10  Kevin Grittner <kgrittn@mail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Kevin Grittner @ 2012-10-25 22:10 UTC (permalink / raw)
  To: John R Pierce <pierce@hogranch.com>; pgsql-jdbc

John R Pierce wrote:

> my developers don't think simple reads ARE a transaction.

Now you've piqued my interest. To run multiple simple selects which
should see a consistent view of the data, wouldn't they expect they
could setTransactionIsolation() to TRANSACTION_REPEATABLE_READ or
TRANSACTION_SERIALIZABLE and setAutoCommit() false to see a stable
view of the data?  How would they say they were done with that view
and wanted a fresh one for the next batch of SELECT statements?

-Kevin




^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2012-10-25 22:10 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-10-25 20:12 commit problem John R Pierce <pierce@hogranch.com>
2012-10-25 20:44 ` Dave Cramer <pg@fastcrypt.com>
2012-10-25 21:56 ` Thomas Kellerer <spam_eater@gmx.net>
2012-10-25 22:09 ` Thomas Kellerer <spam_eater@gmx.net>
2012-10-25 20:45 Re: commit problem Kevin Grittner <kgrittn@mail.com>
2012-10-25 21:48 ` John R Pierce <pierce@hogranch.com>
2012-10-25 22:07   ` Thomas Kellerer <spam_eater@gmx.net>
2012-10-25 22:04 Re: commit problem Kevin Grittner <kgrittn@mail.com>
2012-10-25 22:10 Re: commit problem Kevin Grittner <kgrittn@mail.com>

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