Details
Description
I was trying out the postgis NG datastore against the old one using the same old Texas roads database
when I found out that the NG one was systematically throwing OOM.
A little investigation shows that PostgreSQL can do partial fetches only if autocommit is false:
http://www.nabble.com/ResultSet---setFetchSize-fails-to-stop-heap-failures-td17519869.html#a17521489
http://jdbc.postgresql.org/documentation/83/query.html#query-with-cursor
Looking into the old jdbc datastores code one can see that auto-commit is not set not even
for Transaction.AUTO_COMMIT. The upside is that partial fetches do work, the downside
is that apparently one has to use transactions to ensure changes are properly written?
Yet, the old postgis tests ensured that operations were working even on auto_commit,
not sure if it was an unintended side effect or if the transactions are committed on close unless
explicitly rolled back (I would find this odd thought)...
I made a few tests by adding setAutoCommit(false) to PostgisDialect.initializeConnection...
of course test failed. I had to add two things to get tests working again:
- add an explicit con.commit() in JDBCTestSetup.run()
- add an explicit con.commit() in PostgisDialect.postCreateTable
After those two gross hacks all tests are passing again but... ugh...
On the other side having a datastore that cannot load huge amounts of data
by streaming them is a major problem... ![]()
Opinions?
What would happen if we disabled write access (throw an exception) when using Transaction.AUTO_COMMIT. I don't think geoserver would be affected since it always uses a proper transaction. If this was the case we could always use Connection.setAutoCommit(false) for postgis-ng. And since we disallow any use of AUTO_COMMIT for writing we don't have to worry about nasty hacks to try and commit the connection.
The only other alternative i could think of is coming up with a new type of transaction type... say READ_ONLY. It would not be ideal since it would require api changes... but it would give us the chance to achieve good performance for really the only case that it matters.
Either way sort of nasty. Sorry I don't have a good answer for this one.