Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35291
| From | Marcel Mueller <news.5.maazl@spamgourmet.org> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Not closing connections and statements |
| Date | 2016-08-13 07:55 +0200 |
| Organization | MB-NET.NET for Open-News-Network e.V. |
| Message-ID | <nomcp8$m67$1@gwaiyur.mb-net.net> (permalink) |
| References | <87shuakxjq.fsf@Equus.decebal.nl> <noki5t$1bkc$1@gioia.aioe.org> <nolbnn$m8a$1@gwaiyur.mb-net.net> <nolv72$1g6r$1@gioia.aioe.org> |
On 13.08.16 04.04, Arne Vajhøj wrote: >> True, but you may get deadlocks with you own statements if locks are >> still pending. E.g. a pending reader may prevent other updates from >> proceeding. Some databases also reject more than one open data reader. >> You may get exceptions at subsequent statements in this case. > > I am not sure that I understand the deadlock thing. > > SQLTransactionRollbackException like other SQLTransientException can > be retried. > > If the commit was successful then I would expect all locks > to be released and no SQLTransactionRollbackException. > > Am I missing something? No, but there is only a very small step from not closing a statement to not calling rollback. And it is another not too large step to not closing data readers. So it is rather likely that pending statements keep some DB resources until the GC happens to catch them. Especially if an exception (e.g. duplicate key) raises in the middle of a transaction. At this point there is still no deadlock so far, only tremendously bad performance because the dependency on the GC. But if your application deals with parallel connections or instances the probability of deadlocks is significantly increased. I have found many SQL based applications that are not free of distributed race conditions (involving the database server), especially when the DB deals with page locks which widens the locks unexpectedly to more or less randomly chosen rows. Who really operates at serializable isolation level in a larger application? Mostly these deadlocks are that unlikely that it might not even happen once in their life time. Introducing larger delays in transactions or locks respectively may increase this probability significantly, similarly to the birthday paradox. As others mentioned it is no big deal for short running, single threaded applications, of course. It is usually also no big impact for applications without transactional integrity, i.e with auto-commit. However, databases without snapshot isolation may run into trouble with open data readers too. Marcel
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-12 13:59 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 09:15 -0400
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 09:39 -0400
Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-12 22:31 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 22:04 -0400
Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-13 07:55 +0200
Re: Not closing connections and statements Martin Gregorie <martin@address-in-sig.invalid> - 2016-08-12 19:01 +0000
Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-12 22:35 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:52 -0400
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-12 23:55 +0200
Re: Not closing connections and statements Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-12 18:16 -0400
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 01:19 +0200
Re: Not closing connections and statements Martin Gregorie <martin@address-in-sig.invalid> - 2016-08-13 00:21 +0000
Re: Not closing connections and statements Gunter Herrmann <gunter.herrmann@earthlink.net> - 2016-08-17 16:38 -0400
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:58 -0400
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:50 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:59 -0400
Re: Not closing connections and statements Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-13 08:47 +0200
Re: Not closing connections and statements Andreas Leitgeb <avl@logic.at> - 2016-08-13 08:05 +0000
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:21 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 09:54 -0400
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 12:19 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 10:04 -0400
log4j RollingFileAppender (was: Not closing connections and statements) Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-14 22:24 +0200
Re: log4j RollingFileAppender Arne Vajhøj <arne@vajhoej.dk> - 2016-08-14 21:01 -0400
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 11:58 -0400
logging (was: Not closing connections and statements) Marcel Mueller <news.5.maazl@spamgourmet.org> - 2016-08-14 23:46 +0200
Re: Not closing connections and statements Arne Vajhøj <arne@vajhoej.dk> - 2016-08-12 21:44 -0400
Re: Not closing connections and statements Florian Weimer <fw@deneb.enyo.de> - 2016-08-13 16:33 +0200
Re: Not closing connections and statements Cecil Westerhof <Cecil@decebal.nl> - 2016-08-13 17:34 +0200
csiph-web