pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedSupport for JDBC setQueryTimeout, et al.
45+ messages / 12 participants
[nested] [flat]
* Support for JDBC setQueryTimeout, et al.
@ 2010-10-11 06:46 David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 1 reply; 45+ messages in thread
From: David Fetter @ 2010-10-11 06:46 UTC (permalink / raw)
To: PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
Folks,
Please find enclosed a WIP patch from one of my co-workers intended to
support JDBC's setQueryTimeout, along with the patch for JDBC that
uses it.
I think this is an especially handy capability, and goes to the number
one TODO on the JDBC compliance list.
http://jdbc.postgresql.org/todo.html
Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
Attachments: download all (2 files, .tar.gz)
backend_setQueryTimeout_02.patch (text/plain, 5.6K) download
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index e4a7dd9..06c8fce 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -51,6 +51,8 @@
/* GUC variables */
int DeadlockTimeout = 1000;
int StatementTimeout = 0;
+int SessionTimerTarget = 0;
+
bool log_lock_waits = false;
/* Pointer to this process's PGPROC struct, if any */
@@ -1550,6 +1552,10 @@ CheckStatementTimeout(void)
/* Time to die */
statement_timeout_active = false;
cancel_from_timeout = true;
+
+ /* reset session timer. Never fire twice. */
+ set_session_timer_ms(0);
+
#ifdef HAVE_SETSID
/* try to signal whole process group */
kill(-MyProcPid, SIGINT);
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index cba90a9..769ac2c 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2445,28 +2445,43 @@ exec_describe_portal_message(const char *portal_name)
pq_putemptymessage('n'); /* NoData */
}
-
/*
* Convenience routines for starting/committing a single command.
*/
static void
start_xact_command(void)
{
+ int64 timeout = 0;
+
if (!xact_started)
{
- ereport(DEBUG3,
- (errmsg_internal("StartTransactionCommand")));
+ ereport(DEBUG3, (errmsg_internal("StartTransactionCommand")));
StartTransactionCommand();
- /* Set statement timeout running, if any */
- /* NB: this mustn't be enabled until we are within an xact */
- if (StatementTimeout > 0)
- enable_sig_alarm(StatementTimeout, true);
- else
- cancel_from_timeout = false;
+ if (timeout == 0 ||
+ (StatementTimeout > 0 && timeout > StatementTimeout)) {
+ timeout = StatementTimeout;
+ }
+
+ /* Set statement timeout running, if any */
+ /* NB: this mustn't be enabled until we are within an xact */
+ if (StatementTimeout > 0)
+ enable_sig_alarm(StatementTimeout, true);
+ else
+ cancel_from_timeout = false;
xact_started = true;
- }
+ }
+
+ timeout = get_session_timer_ms();
+ if (timeout > 0) {
+ if (StatementTimeout == 0 || timeout < StatementTimeout) {
+ ereport(DEBUG3, (errmsg_internal("Enable an once session timer")));
+ enable_sig_alarm(timeout, true);
+ } else {
+ cancel_from_timeout = false;
+ }
+ }
}
static void
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index c6e1d13..d998df6 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -4824,3 +4824,50 @@ generate_series_timestamptz(PG_FUNCTION_ARGS)
SRF_RETURN_DONE(funcctx);
}
}
+
+/* Session timer target, in ms */
+static int64 sessionTimerTarget;
+
+Datum set_session_timer(PG_FUNCTION_ARGS)
+{
+ int64 ms = PG_GETARG_INT64(0);
+ set_session_timer_ms(ms);
+ PG_RETURN_DATUM(0);
+}
+
+#ifndef HAVE_INT64_TIMESTAMP
+#error Assumes int64 impl of timestamp
+#endif
+
+void set_session_timer_ms(int64 ms)
+{
+ if (ms == 0) {
+ sessionTimerTarget = 0;
+ } else {
+ /* GetCurrentTimestamp is in us */
+ int64 time_now = GetCurrentTimestamp() / 1000;
+ sessionTimerTarget = time_now + ms;
+ }
+}
+
+int64 get_session_timer_ms()
+{
+ int64 ret = 0;
+ if (sessionTimerTarget != 0) {
+ int64 time_now = GetCurrentTimestamp() / 1000;
+ ret = sessionTimerTarget - time_now;
+
+ if (ret <= 0) {
+ /* Timer already passed. This maybe possible if some statement
+ * set the timer, finished so the timer is disabled, next statement
+ * set the timer again, but too late. We want to go through the
+ * same routine and fire the timer. Return 1 ms.
+ */
+ ret = 1;
+ }
+
+ sessionTimerTarget = 0;
+ }
+
+ return ret;
+}
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 910474c..904a821 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201010101
+#define CATALOG_VERSION_NO 201010102
#endif
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 61c6b27..308f014 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -4849,6 +4849,8 @@ DATA(insert OID = 3113 ( last_value PGNSP PGUID 12 1 0 0 f t f t f i 1 0 2283 "
DESCR("fetch the last row value");
DATA(insert OID = 3114 ( nth_value PGNSP PGUID 12 1 0 0 f t f t f i 2 0 2283 "2283 23" _null_ _null_ _null_ _null_ window_nth_value _null_ _null_ _null_ ));
DESCR("fetch the Nth row value");
+DATA(insert OID = 3115 ( set_session_timer PGNSP PGUID 12 1 0 0 f f f t f i 1 0 20 "20" _null_ _null_ _null_ _null_ set_session_timer _null_ _null_ _null_ ));
+DESCR("Set a timer for the session");
/*
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h
index db7b729..c60d109 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -310,6 +310,11 @@ extern Datum pg_conf_load_time(PG_FUNCTION_ARGS);
extern Datum generate_series_timestamp(PG_FUNCTION_ARGS);
extern Datum generate_series_timestamptz(PG_FUNCTION_ARGS);
+/* session timer, for jdbc setQueryTimeout and like */
+extern Datum set_session_timer(PG_FUNCTION_ARGS);
+extern void set_session_timer_ms(int64 ms);
+extern int64 get_session_timer_ms(void);
+
/* Internal routines (not fmgr-callable) */
extern TimestampTz GetCurrentTimestamp(void);
jdbc_setQueryTimeout_02.patch (text/plain, 17.2K) download
diff --git a/org/postgresql/core/QueryExecutor.java b/org/postgresql/core/QueryExecutor.java
index 73cbfac..12c978e 100644
--- a/org/postgresql/core/QueryExecutor.java
+++ b/org/postgresql/core/QueryExecutor.java
@@ -113,6 +113,7 @@ public interface QueryExecutor {
ResultHandler handler,
int maxRows,
int fetchSize,
+ int timer,
int flags)
throws SQLException;
@@ -140,6 +141,7 @@ public interface QueryExecutor {
ResultHandler handler,
int maxRows,
int fetchSize,
+ int timer,
int flags)
throws SQLException;
diff --git a/org/postgresql/core/v2/ConnectionFactoryImpl.java b/org/postgresql/core/v2/ConnectionFactoryImpl.java
index cfa1df5..9fa6aeb 100644
--- a/org/postgresql/core/v2/ConnectionFactoryImpl.java
+++ b/org/postgresql/core/v2/ConnectionFactoryImpl.java
@@ -413,7 +413,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
try
{
- executor.execute(query, null, handler, 0, 0, flags);
+ executor.execute(query, null, handler, 0, 0, 0, flags);
}
finally
{
diff --git a/org/postgresql/core/v2/QueryExecutorImpl.java b/org/postgresql/core/v2/QueryExecutorImpl.java
index f06b7eb..ef0222b 100644
--- a/org/postgresql/core/v2/QueryExecutorImpl.java
+++ b/org/postgresql/core/v2/QueryExecutorImpl.java
@@ -253,17 +253,17 @@ public class QueryExecutorImpl implements QueryExecutor {
public synchronized void execute(Query query,
ParameterList parameters,
ResultHandler handler,
- int maxRows, int fetchSize, int flags)
+ int maxRows, int fetchSize, int timer, int flags)
throws SQLException
{
- execute((V2Query)query, (SimpleParameterList)parameters, handler, maxRows, flags);
+ execute((V2Query)query, (SimpleParameterList)parameters, handler, maxRows, timer, flags);
}
// Nothing special yet, just run the queries one at a time.
public synchronized void execute(Query[] queries,
ParameterList[] parameters,
ResultHandler handler,
- int maxRows, int fetchSize, int flags)
+ int maxRows, int fetchSize, int timer, int flags)
throws SQLException
{
final ResultHandler delegateHandler = handler;
@@ -289,7 +289,7 @@ public class QueryExecutorImpl implements QueryExecutor {
};
for (int i = 0; i < queries.length; ++i)
- execute((V2Query)queries[i], (SimpleParameterList)parameters[i], handler, maxRows, flags);
+ execute((V2Query)queries[i], (SimpleParameterList)parameters[i], handler, maxRows, timer, flags);
delegateHandler.handleCompletion();
}
@@ -301,7 +301,7 @@ public class QueryExecutorImpl implements QueryExecutor {
private void execute(V2Query query,
SimpleParameterList parameters,
ResultHandler handler,
- int maxRows, int flags) throws SQLException
+ int maxRows, int timer, int flags) throws SQLException
{
// The V2 protocol has no support for retrieving metadata
diff --git a/org/postgresql/core/v3/QueryExecutorImpl.java b/org/postgresql/core/v3/QueryExecutorImpl.java
index 62678f9..b246f84 100644
--- a/org/postgresql/core/v3/QueryExecutorImpl.java
+++ b/org/postgresql/core/v3/QueryExecutorImpl.java
@@ -224,6 +224,7 @@ public class QueryExecutorImpl implements QueryExecutor {
ResultHandler handler,
int maxRows,
int fetchSize,
+ int timer,
int flags)
throws SQLException
{
@@ -249,7 +250,7 @@ public class QueryExecutorImpl implements QueryExecutor {
{
try
{
- handler = sendQueryPreamble(handler, flags);
+ handler = sendQueryPreamble(handler, flags, timer);
ErrorTrackingResultHandler trackingHandler = new ErrorTrackingResultHandler(handler);
queryCount = 0;
sendQuery((V3Query)query, (V3ParameterList)parameters, maxRows, fetchSize, flags, trackingHandler);
@@ -362,6 +363,7 @@ public class QueryExecutorImpl implements QueryExecutor {
ResultHandler handler,
int maxRows,
int fetchSize,
+ int timer,
int flags)
throws SQLException
{
@@ -384,7 +386,7 @@ public class QueryExecutorImpl implements QueryExecutor {
try
{
- handler = sendQueryPreamble(handler, flags);
+ handler = sendQueryPreamble(handler, flags, timer);
ErrorTrackingResultHandler trackingHandler = new ErrorTrackingResultHandler(handler);
queryCount = 0;
@@ -416,11 +418,33 @@ public class QueryExecutorImpl implements QueryExecutor {
handler.handleCompletion();
}
- private ResultHandler sendQueryPreamble(final ResultHandler delegateHandler, int flags) throws IOException {
+ private ResultHandler sendQueryPreamble(final ResultHandler delegateHandler, int timer, int flags) throws IOException {
+ // First, decide whether we need to do anything. Put that in final boolean so that we can use it later in anonymous class.
+ final boolean needBegin = ((flags & QueryExecutor.QUERY_SUPPRESS_BEGIN) != 0 ||
+ protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE);
+
+ final boolean needTimer = timer > 0;
+
// First, send CloseStatements for finalized SimpleQueries that had statement names assigned.
processDeadParsedQueries();
processDeadPortals();
+ if (!needBegin && !needTimer)
+ return delegateHandler;
+
+ if (needBegin) {
+ // Need to send out a BEGIN preamble.
+ sendOneQuery(beginTransactionQuery, SimpleQuery.NO_PARAMETERS, 0, 0, QueryExecutor.QUERY_NO_METADATA);
+ }
+
+ if (needTimer) {
+ // Need to send out a sesstion timer query, in ms. Timer is in sec.
+ SimpleQuery timerQuery = new SimpleQuery(new String[] {
+ "select set_session_timer(" + (timer * 1000) + "); "
+ }, null);
+ sendOneQuery(timerQuery, SimpleQuery.NO_PARAMETERS, 0, 0, QueryExecutor.QUERY_NO_METADATA);
+ }
+
// Send BEGIN on first statement in transaction.
if ((flags & QueryExecutor.QUERY_SUPPRESS_BEGIN) != 0 ||
protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE)
@@ -430,39 +454,49 @@ public class QueryExecutorImpl implements QueryExecutor {
// Insert a handler that intercepts the BEGIN.
return new ResultHandler() {
- private boolean sawBegin = false;
-
- public void handleResultRows(Query fromQuery, Field[] fields, Vector tuples, ResultCursor cursor) {
- if (sawBegin)
- delegateHandler.handleResultRows(fromQuery, fields, tuples, cursor);
- }
-
- public void handleCommandStatus(String status, int updateCount, long insertOID) {
- if (!sawBegin)
- {
- sawBegin = true;
- if (!status.equals("BEGIN"))
- handleError(new PSQLException(GT.tr("Expected command status BEGIN, got {0}.", status),
- PSQLState.PROTOCOL_VIOLATION));
+ private boolean needHandleBegin = needBegin;
+ private boolean needHandleTimer = needTimer;
+
+ public void handleResultRows(Query fromQuery, Field[] fields, Vector tuples, ResultCursor cursor) {
+ if (!needHandleBegin) {
+ if (needHandleTimer) {
+ // ResultSet from timer query. Drop it on the floor.
+ needHandleTimer = false;
}
else
{
- delegateHandler.handleCommandStatus(status, updateCount, insertOID);
+ // Real query result. Pass it on.
+ delegateHandler.handleResultRows(fromQuery, fields, tuples, cursor);
}
}
-
- public void handleWarning(SQLWarning warning) {
- delegateHandler.handleWarning(warning);
+ }
+
+ public void handleCommandStatus(String status, int updateCount, long insertOID) {
+ if (needHandleBegin)
+ {
+ needHandleBegin = false;
+ if (!status.equals("BEGIN"))
+ handleError(new PSQLException(GT.tr("Expected command status BEGIN, got {0}.", status),
+ PSQLState.PROTOCOL_VIOLATION));
}
-
- public void handleError(SQLException error) {
- delegateHandler.handleError(error);
+ else
+ {
+ delegateHandler.handleCommandStatus(status, updateCount, insertOID);
}
+ }
- public void handleCompletion() throws SQLException{
- delegateHandler.handleCompletion();
- }
- };
+ public void handleWarning(SQLWarning warning) {
+ delegateHandler.handleWarning(warning);
+ }
+
+ public void handleError(SQLException error) {
+ delegateHandler.handleError(error);
+ }
+
+ public void handleCompletion() throws SQLException{
+ delegateHandler.handleCompletion();
+ }
+ };
}
//
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Connection.java b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
index 4571379..b24f3d2 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Connection.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
@@ -67,6 +67,8 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
public boolean autoCommit = true;
// Connection's readonly state.
public boolean readOnly = false;
+ // Respect it?
+ private boolean respectReadonly = false;
// Bind String to UNSPECIFIED or VARCHAR?
public final boolean bindStringAsVarchar;
@@ -175,6 +177,12 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
openStackTrace = new Throwable("Connection was created at this point:");
enableDriverManagerLogging();
}
+
+ String rdonly = info.getProperty("respectReadonly");
+ if (rdonly != null) {
+ if (rdonly.equalsIgnoreCase("true"))
+ respectReadonly = true;
+ }
}
private final TimestampUtils timestampUtils;
@@ -601,28 +609,36 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
/*
- * You can put a connection in read-only mode as a hunt to enable
+ * You can put a connection in read-only mode as a hint to enable
* database optimizations
*
* <B>Note:</B> setReadOnly cannot be called while in the middle
* of a transaction
*
+ * <B>Note:</B> This is only a hint, so we are free not to do
+ * anything. According to the JDBC specification, we should
+ * respectReadonly. However, this breaks a lot of popular
+ * software like Hibernate, so unless the end user *really* wants
+ * this behavior, which they can do by setting respectReadonly in
+ * the connection string, we will make this a no-op.
+ *
* @param readOnly - true enables read-only mode; false disables it
* @exception SQLException if a database access error occurs
*/
public void setReadOnly(boolean readOnly) throws SQLException
{
checkClosed();
- if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE)
- throw new PSQLException(GT.tr("Cannot change transaction read-only property in the middle of a transaction."),
- PSQLState.ACTIVE_SQL_TRANSACTION);
+ if (respectReadonly) {
+ if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE)
+ throw new PSQLException(GT.tr("Cannot change transaction read-only property in the middle of a transaction."),
+ PSQLState.ACTIVE_SQL_TRANSACTION);
- if (haveMinimumServerVersion("7.4") && readOnly != this.readOnly)
- {
- String readOnlySql = "SET SESSION CHARACTERISTICS AS TRANSACTION " + (readOnly ? "READ ONLY" : "READ WRITE");
- execSQLUpdate(readOnlySql); // nb: no BEGIN triggered.
+ if (haveMinimumServerVersion("7.4") && readOnly != this.readOnly)
+ {
+ String readOnlySql = "SET SESSION CHARACTERISTICS AS TRANSACTION " + (readOnly ? "READ ONLY" : "READ WRITE");
+ execSQLUpdate(readOnlySql); // nb: no BEGIN triggered.
+ }
}
-
this.readOnly = readOnly;
}
@@ -683,7 +699,7 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
private void executeTransactionCommand(Query query) throws SQLException {
getQueryExecutor().execute(query, null, new TransactionCommandHandler(),
- 0, 0, QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN);
+ 0, 0, 0, QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN);
}
/*
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
index 5e44a73..da2262b 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
@@ -502,6 +502,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
handler,
maxrows,
fetchSize,
+ timeout,
flags);
result = firstUnclosedResult = handler.getResults();
@@ -652,9 +653,6 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
throw new PSQLException(GT.tr("Query timeout must be a value greater than or equals to 0."),
PSQLState.INVALID_PARAMETER_VALUE);
- if (seconds > 0)
- throw Driver.notImplemented(this.getClass(), "setQueryTimeout(int)");
-
timeout = seconds;
}
@@ -2739,6 +2737,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
handler,
maxrows,
fetchSize,
+ timeout,
flags);
return updateCounts;
@@ -2827,7 +2826,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_DESCRIBE_ONLY | QueryExecutor.QUERY_SUPPRESS_BEGIN;
StatementResultHandler handler = new StatementResultHandler();
- connection.getQueryExecutor().execute(preparedQuery, preparedParameters, handler, 0, 0, flags);
+ connection.getQueryExecutor().execute(preparedQuery, preparedParameters, handler, 0, 0, timeout, flags);
ResultWrapper wrapper = handler.getResults();
if (wrapper != null) {
rs = wrapper.getResultSet();
diff --git a/org/postgresql/jdbc3/AbstractJdbc3Statement.java b/org/postgresql/jdbc3/AbstractJdbc3Statement.java
index ecbfb76..e795ee8 100644
--- a/org/postgresql/jdbc3/AbstractJdbc3Statement.java
+++ b/org/postgresql/jdbc3/AbstractJdbc3Statement.java
@@ -411,7 +411,7 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
{
int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_DESCRIBE_ONLY | QueryExecutor.QUERY_SUPPRESS_BEGIN;
StatementResultHandler handler = new StatementResultHandler();
- connection.getQueryExecutor().execute(preparedQuery, preparedParameters, handler, 0, 0, flags);
+ connection.getQueryExecutor().execute(preparedQuery, preparedParameters, handler, 0, 0, timeout, flags);
int oids[] = preparedParameters.getTypeOIDs();
if (oids != null)
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
@ 2010-10-11 13:29 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-11 14:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
0 siblings, 2 replies; 45+ messages in thread
From: Kevin Grittner @ 2010-10-11 13:29 UTC (permalink / raw)
To: David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
David Fetter <david@fetter.org> wrote:
> Please find enclosed a WIP patch from one of my co-workers
> intended to support JDBC's setQueryTimeout, along with the patch
> for JDBC that uses it.
I agree that it would be very nice to support this JDBC feature, but
I'm not clear on why this can't be done with just JDBC changes using
the java.util.Timer class and the existing Statement.cancel()
method. Can you explain why the backend needed to be touched?
-Kevin
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-11 14:17 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-11 14:27 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
1 sibling, 1 reply; 45+ messages in thread
From: Tom Lane @ 2010-10-11 14:17 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> David Fetter <david@fetter.org> wrote:
>> Please find enclosed a WIP patch from one of my co-workers
>> intended to support JDBC's setQueryTimeout, along with the patch
>> for JDBC that uses it.
> I agree that it would be very nice to support this JDBC feature, but
> I'm not clear on why this can't be done with just JDBC changes using
> the java.util.Timer class and the existing Statement.cancel()
> method. Can you explain why the backend needed to be touched?
... and, if you are seriously expecting to have that happen, why the
patch was submitted to pgsql-jdbc not pgsql-hackers? I hadn't even
read it because I assumed it was strictly a JDBC change.
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-11 14:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-10-11 14:27 ` Magnus Hagander <magnus@hagander.net>
2010-10-11 14:31 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 45+ messages in thread
From: Magnus Hagander @ 2010-10-11 14:27 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Mon, Oct 11, 2010 at 16:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
>> David Fetter <david@fetter.org> wrote:
>>> Please find enclosed a WIP patch from one of my co-workers
>>> intended to support JDBC's setQueryTimeout, along with the patch
>>> for JDBC that uses it.
>
>> I agree that it would be very nice to support this JDBC feature, but
>> I'm not clear on why this can't be done with just JDBC changes using
>> the java.util.Timer class and the existing Statement.cancel()
>> method. Can you explain why the backend needed to be touched?
>
> ... and, if you are seriously expecting to have that happen, why the
> patch was submitted to pgsql-jdbc not pgsql-hackers? I hadn't even
> read it because I assumed it was strictly a JDBC change.
To be fair to David, it was sent to *both* pgsql-jdbc and
pgsql-hackers. Maybe it was held for moderation on one and arrived out
of order?
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-11 14:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-11 14:27 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
@ 2010-10-11 14:31 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 45+ messages in thread
From: Tom Lane @ 2010-10-11 14:31 UTC (permalink / raw)
To: Magnus Hagander <magnus@hagander.net>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
Magnus Hagander <magnus@hagander.net> writes:
> On Mon, Oct 11, 2010 at 16:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> ... and, if you are seriously expecting to have that happen, why the
>> patch was submitted to pgsql-jdbc not pgsql-hackers?
> To be fair to David, it was sent to *both* pgsql-jdbc and
> pgsql-hackers. Maybe it was held for moderation on one and arrived out
> of order?
... Oh. My apologies to David. My copy came through via pgsql-jdbc,
and I wasn't awake enough to notice it'd been posted to -hackers too.
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-12 09:04 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
1 sibling, 1 reply; 45+ messages in thread
From: Radosław Smogura @ 2010-10-12 09:04 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Mon, 11 Oct 2010 08:29:16 -0500, "Kevin Grittner"
<Kevin.Grittner@wicourts.gov> wrote:
> David Fetter <david@fetter.org> wrote:
>
>> Please find enclosed a WIP patch from one of my co-workers
>> intended to support JDBC's setQueryTimeout, along with the patch
>> for JDBC that uses it.
>
> I agree that it would be very nice to support this JDBC feature, but
> I'm not clear on why this can't be done with just JDBC changes using
> the java.util.Timer class and the existing Statement.cancel()
> method. Can you explain why the backend needed to be touched?
>
> -Kevin
I sent such patch fully in Java
(http://archives.postgresql.org/pgsql-jdbc/2009-11/msg00010.php),
implementing cancellation with Timer and "cancel query" facility of PSQL
server, unfortunately none has revised it, even that setQuertyTimeout todo
is for long time on dashboard, and it's important for enterprise class
software.
----------
Radosław Smogura
http://www.softperience.eu
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
@ 2010-10-12 14:14 ` David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-13 17:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
0 siblings, 2 replies; 45+ messages in thread
From: David Fetter @ 2010-10-12 14:14 UTC (permalink / raw)
To: Radosław Smogura <rsmogura@softperience.eu>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Tue, Oct 12, 2010 at 04:04:56AM -0500, Radosław Smogura wrote:
> On Mon, 11 Oct 2010 08:29:16 -0500, "Kevin Grittner"
> <Kevin.Grittner@wicourts.gov> wrote:
> > David Fetter <david@fetter.org> wrote:
> >
> >> Please find enclosed a WIP patch from one of my co-workers
> >> intended to support JDBC's setQueryTimeout, along with the patch
> >> for JDBC that uses it.
> >
> > I agree that it would be very nice to support this JDBC feature, but
> > I'm not clear on why this can't be done with just JDBC changes using
> > the java.util.Timer class and the existing Statement.cancel()
> > method. Can you explain why the backend needed to be touched?
> >
> > -Kevin
>
> I sent such patch fully in Java
> (http://archives.postgresql.org/pgsql-jdbc/2009-11/msg00010.php),
> implementing cancellation with Timer and "cancel query" facility of
> PSQL server,
Would you like to update it?
Is there something incomplete about the ones I sent, and if so, what?
> unfortunately none has revised it, even that setQuertyTimeout todo
> is for long time on dashboard, and it's important for enterprise
> class software.
That sounds a tad buzzword-y. What exactly is it that *you* see as
important to delivering this feature? I'm thinking JDBC1 compliance,
but you might have something very different in mind.
Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
@ 2010-10-12 15:37 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
1 sibling, 1 reply; 45+ messages in thread
From: Kevin Grittner @ 2010-10-12 15:37 UTC (permalink / raw)
To: David Fetter <david@fetter.org>; rsmogura@softperience.eu; +Cc: PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
David Fetter <david@fetter.org> wrote:
> Is there something incomplete about the ones I sent, and if so,
> what?
Well, I'm still curious why it was necessary to modify the server
side to implement an interface feature for which everything needed
seems to be present on the client side. Is this intended to be
useful for other interfaces? If so, we should probably have an
implementation in some other interface to confirm that the
server-side support fits. If not, why touch the server side code at
all?
These are not rhetorical questions. There may be some reason, but
if so, I'd like to see it stated, rather than trying to infer it
through reverse engineering.
-Kevin
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-12 15:55 ` David Fetter <david@fetter.org>
2010-10-12 16:23 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-12 19:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 3 replies; 45+ messages in thread
From: David Fetter @ 2010-10-12 15:55 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: rsmogura@softperience.eu, PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Tue, Oct 12, 2010 at 10:37:00AM -0500, Kevin Grittner wrote:
> David Fetter <david@fetter.org> wrote:
> > Is there something incomplete about the ones I sent, and if so,
> > what?
>
> Well, I'm still curious why it was necessary to modify the server
> side to implement an interface feature for which everything needed
> seems to be present on the client side.
Not everything is.
Let's imagine you have a connection pooler with two clients, A and B.
A calls setQueryTimeout, then starts a query, which terminates in
time, but dies before handling it. B connects to the pool, gets A's
connection, and finds a statement_timeout that's not the default, even
though only A's single query was supposed to have that
statement_timeout. This is not a situation that can be resolved
without being able to set a timer *on the server side*.
> Is this intended to be useful for other interfaces?
Anybody doing similar functionality, namely a per-statement timeout,
would need this infrastructure, and for the same reason.
> If so, we should probably have an implementation in some other
> interface to confirm that the server-side support fits. If not, why
> touch the server side code at all?
See above.
While I'd *like* to put in a whole infrastructure for setting GUCs on
a per-statement basis, I don't believe that we need to get out that
giant sledgehammer for this case, even though it's worth solving.
Incidentally, this dovetails neatly with the isolation concerns that
motivated the "true serializability" patch you're working on :)
Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
@ 2010-10-12 16:23 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2 siblings, 0 replies; 45+ messages in thread
From: Kevin Grittner @ 2010-10-12 16:23 UTC (permalink / raw)
To: David Fetter <david@fetter.org>; +Cc: PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; rsmogura@softperience.eu
David Fetter <david@fetter.org> wrote:
> Let's imagine you have a connection pooler with two clients,
> A and B.
I'm with you so far.
> A calls setQueryTimeout, then starts a query, which terminates in
> time, but dies before handling it.
Here you lost me. I don't know what that means.
> B connects to the pool, gets A's connection, and finds a
> statement_timeout that's not the default
Why? I would consider the JDBC QueryTimeout property to be
orthogonal to the server's statement_timeout GUC. Perhaps that's
why we're seeing things so differently.
> even though only A's single query was supposed to have that
> statement_timeout. This is not a situation that can be resolved
> without being able to set a timer *on the server side*.
That will be true if we conflate these two things. I don't think we
should.
http://download.oracle.com/javase/6/docs/api/java/sql/Statement.html#setQueryTimeout%28int%29
This time limit should apply to the overall time allowed in the
driver for the execute, executeQuery and executeUpdate of the Java
Statement object. It should not be trying to pick apart individual
SQL statements within the execute request, and it should not affect
any other statement on the connection.
I think both patches are making this harder than it needs to be.
-Kevin
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
@ 2010-10-12 18:03 ` Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2 siblings, 1 reply; 45+ messages in thread
From: Magnus Hagander @ 2010-10-12 18:03 UTC (permalink / raw)
To: David Fetter <david@fetter.org>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; rsmogura@softperience.eu, PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Tue, Oct 12, 2010 at 17:55, David Fetter <david@fetter.org> wrote:
> On Tue, Oct 12, 2010 at 10:37:00AM -0500, Kevin Grittner wrote:
>> David Fetter <david@fetter.org> wrote:
>> > Is there something incomplete about the ones I sent, and if so,
>> > what?
>>
>> Well, I'm still curious why it was necessary to modify the server
>> side to implement an interface feature for which everything needed
>> seems to be present on the client side.
>
> Not everything is.
>
> Let's imagine you have a connection pooler with two clients, A and B.
> A calls setQueryTimeout, then starts a query, which terminates in
> time, but dies before handling it. B connects to the pool, gets A's
> connection, and finds a statement_timeout that's not the default, even
> though only A's single query was supposed to have that
> statement_timeout. This is not a situation that can be resolved
> without being able to set a timer *on the server side*.
Sure it can. The connection pooler just needs to issue a RESET ALL
statement when it hands over a connection from one client to another.
Isn't that what for example pgbouncer does - at least when configured
per instructions?
Also, doesn't this affect *all* settings, not just timeout, if it
doesn't? Imagine client A executing a SET datestyle for example.
AFAICS, any connection pooler that *doesn't* issue a reset between
handing this around is broken, isn't it?
>> If so, we should probably have an implementation in some other
>> interface to confirm that the server-side support fits. If not, why
>> touch the server side code at all?
>
> See above.
>
> While I'd *like* to put in a whole infrastructure for setting GUCs on
> a per-statement basis, I don't believe that we need to get out that
> giant sledgehammer for this case, even though it's worth solving.
We don't usually put in fixes for just one out of 105 cases, do we?
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
@ 2010-10-15 06:56 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
0 siblings, 1 reply; 45+ messages in thread
From: Radosław Smogura @ 2010-10-15 06:56 UTC (permalink / raw)
To: Magnus Hagander <magnus@hagander.net>; +Cc: David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com; tgl@sss.pgh.pa.us
On Tue, 12 Oct 2010 20:03:29 +0200, Magnus Hagander <magnus@hagander.net>
wrote:
> On Tue, Oct 12, 2010 at 17:55, David Fetter <david@fetter.org> wrote:
>> On Tue, Oct 12, 2010 at 10:37:00AM -0500, Kevin Grittner wrote:
>>> David Fetter <david@fetter.org> wrote:
>>> > Is there something incomplete about the ones I sent, and if so,
>>> > what?
>>>
>>> Well, I'm still curious why it was necessary to modify the server
>>> side to implement an interface feature for which everything needed
>>> seems to be present on the client side.
>>
>> Not everything is.
>>
>> Let's imagine you have a connection pooler with two clients, A and B.
>> A calls setQueryTimeout, then starts a query, which terminates in
>> time, but dies before handling it. B connects to the pool, gets A's
>> connection, and finds a statement_timeout that's not the default, even
>> though only A's single query was supposed to have that
>> statement_timeout. This is not a situation that can be resolved
>> without being able to set a timer *on the server side*.
>
> Sure it can. The connection pooler just needs to issue a RESET ALL
> statement when it hands over a connection from one client to another.
> Isn't that what for example pgbouncer does - at least when configured
> per instructions?
>
> Also, doesn't this affect *all* settings, not just timeout, if it
> doesn't? Imagine client A executing a SET datestyle for example.
>
> AFAICS, any connection pooler that *doesn't* issue a reset between
> handing this around is broken, isn't it?
>
If I'm right you would like to say, that when taking connection from pool
REST ALL should be invoked.
But... connection pooler will not send RESET ALL in some situations,
because JDBC driver can have no notify about switching client. In EE
platforms (e. g. Glassfish), server sometimes creates it's own pool and in
certain configuration, when you close Connection, server will never pass
close to PooledConection, nor physical connection. This due to fact, that
GF and others adds functionality for statements pooling (if server will
call close on pooled conn, then reusing cached statement will cause error -
in fact this problem occurs with Hibernate, C3po, XA, and GFv3).
To summarize, you should never believe that RESET ALL will be called, nor
any other behavior when switching clients.
Am I right?
----------
Radosław Smogura
http://www.softperience.eu
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
@ 2010-10-15 08:37 ` Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
0 siblings, 1 reply; 45+ messages in thread
From: Magnus Hagander @ 2010-10-15 08:37 UTC (permalink / raw)
To: Radosław Smogura <rsmogura@softperience.eu>; +Cc: David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com; tgl@sss.pgh.pa.us
On Fri, Oct 15, 2010 at 08:56, Radosław Smogura
<rsmogura@softperience.eu> wrote:
> On Tue, 12 Oct 2010 20:03:29 +0200, Magnus Hagander <magnus@hagander.net>
> wrote:
>> On Tue, Oct 12, 2010 at 17:55, David Fetter <david@fetter.org> wrote:
>>> On Tue, Oct 12, 2010 at 10:37:00AM -0500, Kevin Grittner wrote:
>>>> David Fetter <david@fetter.org> wrote:
>>>> > Is there something incomplete about the ones I sent, and if so,
>>>> > what?
>>>>
>>>> Well, I'm still curious why it was necessary to modify the server
>>>> side to implement an interface feature for which everything needed
>>>> seems to be present on the client side.
>>>
>>> Not everything is.
>>>
>>> Let's imagine you have a connection pooler with two clients, A and B.
>>> A calls setQueryTimeout, then starts a query, which terminates in
>>> time, but dies before handling it. B connects to the pool, gets A's
>>> connection, and finds a statement_timeout that's not the default, even
>>> though only A's single query was supposed to have that
>>> statement_timeout. This is not a situation that can be resolved
>>> without being able to set a timer *on the server side*.
>>
>> Sure it can. The connection pooler just needs to issue a RESET ALL
>> statement when it hands over a connection from one client to another.
>> Isn't that what for example pgbouncer does - at least when configured
>> per instructions?
>>
>> Also, doesn't this affect *all* settings, not just timeout, if it
>> doesn't? Imagine client A executing a SET datestyle for example.
>>
>> AFAICS, any connection pooler that *doesn't* issue a reset between
>> handing this around is broken, isn't it?
>>
>
> If I'm right you would like to say, that when taking connection from pool
> REST ALL should be invoked.
Yes. Unless the client app (or pooler) *knows* that nothing that
executes modifies any settings or session state.
> But... connection pooler will not send RESET ALL in some situations,
> because JDBC driver can have no notify about switching client. In EE
> platforms (e. g. Glassfish), server sometimes creates it's own pool and in
> certain configuration, when you close Connection, server will never pass
> close to PooledConection, nor physical connection. This due to fact, that
> GF and others adds functionality for statements pooling (if server will
> call close on pooled conn, then reusing cached statement will cause error -
> in fact this problem occurs with Hibernate, C3po, XA, and GFv3).
To me, that sounds like a bug in the connection pooler. It is only
safe under quite limited circumstances.
> To summarize, you should never believe that RESET ALL will be called, nor
> any other behavior when switching clients.
In that cas, you ct your client from calling any SET commands etc, and
it should be documented as a major limitation of the connection
pooling software. I don't see any other way to make it safe - others
may have one of course :-)
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
@ 2010-10-15 09:11 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 14:23 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 45+ messages in thread
From: Radosław Smogura @ 2010-10-15 09:11 UTC (permalink / raw)
To: Magnus Hagander <magnus@hagander.net>; +Cc: David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com; tgl@sss.pgh.pa.us
On Fri, 15 Oct 2010 10:37:05 +0200, Magnus Hagander <magnus@hagander.net>
wrote:
>> But... connection pooler will not send RESET ALL in some situations,
>> because JDBC driver can have no notify about switching client. In EE
>> platforms (e. g. Glassfish), server sometimes creates it's own pool and
>> in
>> certain configuration, when you close Connection, server will never
pass
>> close to PooledConection, nor physical connection. This due to fact,
that
>> GF and others adds functionality for statements pooling (if server will
>> call close on pooled conn, then reusing cached statement will cause
>> error -
>> in fact this problem occurs with Hibernate, C3po, XA, and GFv3).
>
> To me, that sounds like a bug in the connection pooler. It is only
> safe under quite limited circumstances.
It's hard to say this is bug. The GF connection pooler is "general pooler"
for all drivers, so it can't know anything about reseting, and if I have
right JDBC4 doesn't support such notifications. It can't close logical
connections, as if would close, cached statements will be invalideted too.
But benefits of pooling statements are much more greater then RESET ALL,
because you can take advance of precompiling prepared statements,
increasing performance; it is comparable to using connection pool instead
of starting physical connections.
In ~2008, Sun published result of (spectest?) Glassfih v2 and PostgreSQL
with special patches allowing statement caching (on JDBC driver side) - it
was the fastest combination, biting all "professional" and highly paid
software.
Probably same wrapping can do JBoss, WAS, and others.
>> in fact this problem occurs with Hibernate, C3po, XA, and GFv3).
Hibernate, with C3P0 hacks and uses some private code, unwraps objects,
etc... :(, so when private implementation changes we have BUM.
> --
> Magnus Hagander
> Me: http://www.hagander.net/
> Work: http://www.redpill-linpro.com/
--
----------
Radosław Smogura
http://www.softperience.eu
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
@ 2010-10-15 14:21 ` Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 45+ messages in thread
From: Stephen Frost @ 2010-10-15 14:21 UTC (permalink / raw)
To: Radosław Smogura <rsmogura@softperience.eu>; +Cc: Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com; tgl@sss.pgh.pa.us
* Radosław Smogura (rsmogura@softperience.eu) wrote:
> > To me, that sounds like a bug in the connection pooler. It is only
> > safe under quite limited circumstances.
>
> It's hard to say this is bug. The GF connection pooler is "general pooler"
> for all drivers, so it can't know anything about reseting, and if I have
> right JDBC4 doesn't support such notifications. It can't close logical
> connections, as if would close, cached statements will be invalideted too.
If it can't figure out a way to issue a command in between handing
around a connection to different clients then, yeah, I'd call it a bug
that needs to be fixed. Maybe other systems don't need it, and it can
be a no-op there, but the capability certainly needs to be there.
> But benefits of pooling statements are much more greater then RESET ALL,
> because you can take advance of precompiling prepared statements,
> increasing performance; it is comparable to using connection pool instead
> of starting physical connections.
errr, I don't believe RESET ALL touches cache'd plans and whatnot (which
is actually a problem I've run into in the past, because changing the
search_path also doesn't invalidate plans, and neither does set role, so
you end up with cache'd plans that try to hit things you don't have
permissions to any more :( ).
Thanks,
Stephen
Attachments:
signature.asc (application/pgp-signature, 196B) download
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
@ 2010-10-15 14:38 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 14:52 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-16 02:51 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Craig Ringer <craig@postnewspapers.com.au>
0 siblings, 2 replies; 45+ messages in thread
From: Tom Lane @ 2010-10-15 14:38 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: Radosław Smogura <rsmogura@softperience.eu>; Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
Stephen Frost <sfrost@snowman.net> writes:
> * Radosław Smogura (rsmogura@softperience.eu) wrote:
>> But benefits of pooling statements are much more greater then RESET ALL,
>> because you can take advance of precompiling prepared statements,
>> increasing performance; it is comparable to using connection pool instead
>> of starting physical connections.
> errr, I don't believe RESET ALL touches cache'd plans and whatnot (which
> is actually a problem I've run into in the past, because changing the
> search_path also doesn't invalidate plans, and neither does set role, so
> you end up with cache'd plans that try to hit things you don't have
> permissions to any more :( ).
Yeah, actually what you need is DISCARD ALL when reassigning a
connection to another client. Anything less than that assumes the
clients are cooperating closely, ie they *want* the same prepared
statements etc. But even if you make that assumption, a pooler that
isn't even capable of sending an ABORT between clients doesn't seem
usable to me. For example, if a client loses its network connection
mid-transaction, that failure will cascade to other clients if you
don't have any ability to reset the database session before handing
it to another client.
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-10-15 14:52 ` Stephen Frost <sfrost@snowman.net>
2010-10-15 20:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Dimitri Fontaine <dimitri@2ndQuadrant.fr>
1 sibling, 1 reply; 45+ messages in thread
From: Stephen Frost @ 2010-10-15 14:52 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Radosław Smogura <rsmogura@softperience.eu>; Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> > errr, I don't believe RESET ALL touches cache'd plans and whatnot (which
> > is actually a problem I've run into in the past, because changing the
> > search_path also doesn't invalidate plans, and neither does set role, so
> > you end up with cache'd plans that try to hit things you don't have
> > permissions to any more :( ).
>
> Yeah, actually what you need is DISCARD ALL when reassigning a
> connection to another client. Anything less than that assumes the
> clients are cooperating closely, ie they *want* the same prepared
> statements etc.
That assumption is certainly something I feel we should consider a valid
and important use-case. I'd think a lot of the time your typical website
is going to be using a dedicated pooler for connections and a dedicated
database where having those queries cache'd would be good.
I recall seeing a module that even set things up so you feed it all the
queries that you're going to run and it plans them all out for you when
you start up the pooler. Been meaning to look into it more, but..
The whole problem with search_path and role is very frustrating. We've
taken to just hacking things to be dynamic SQL whenever it's
role-specific, but that's a really poor solution. I wonder if it would
be possible to have the function and prepare'd plan caches be key'd off
of the search_path and role too..? So if you change one of those you
end up having to re-plan it, but then that's also cached, etc..
> But even if you make that assumption, a pooler that
> isn't even capable of sending an ABORT between clients doesn't seem
> usable to me. For example, if a client loses its network connection
> mid-transaction, that failure will cascade to other clients if you
> don't have any ability to reset the database session before handing
> it to another client.
I agree, the pooler definitely needs to be able to handle those
situations or you'll be running into some serious problems down the
road.
Thanks,
Stephen
Attachments:
signature.asc (application/pgp-signature, 196B) download
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 14:52 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
@ 2010-10-15 20:03 ` Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2010-10-15 20:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 20:22 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 45+ messages in thread
From: Dimitri Fontaine @ 2010-10-15 20:03 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Radosław Smogura <rsmogura@softperience.eu>; Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
Stephen Frost <sfrost@snowman.net> writes:
> That assumption is certainly something I feel we should consider a valid
> and important use-case. I'd think a lot of the time your typical website
> is going to be using a dedicated pooler for connections and a dedicated
> database where having those queries cache'd would be good.
Using pgbouncer without setting server_reset_query is possible and allow
to reuser prepared queries. I abuse the feature in some environment
where prepare takes ~42ms and execute 5ms, as all the data is in RAM.
> I recall seeing a module that even set things up so you feed it all the
> queries that you're going to run and it plans them all out for you when
> you start up the pooler. Been meaning to look into it more, but..
Yeah, for this same project I wanted the application code to stop having
to check whether the session given already has the queries prepared. As
pgbouncer will take new connections here and there (which is a good
idea), you have to check for that. Enters preprepare:
http://preprepare.projects.postgresql.org/README.html
http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/preprepare/preprepare/
http://packages.debian.org/sid/postgresql-8.4-preprepare
There's no release yet and the code is still under CVS, but I could see
about moving it to github some day. Well, maybe I also should implement
support for 9.0.
> The whole problem with search_path and role is very frustrating. We've
> taken to just hacking things to be dynamic SQL whenever it's
> role-specific, but that's a really poor solution. I wonder if it would
> be possible to have the function and prepare'd plan caches be key'd off
> of the search_path and role too..? So if you change one of those you
> end up having to re-plan it, but then that's also cached, etc..
By default pgbouncer maintains a different pool per database and role,
so you should be partly covered here.
Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 14:52 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 20:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Dimitri Fontaine <dimitri@2ndQuadrant.fr>
@ 2010-10-15 20:14 ` Stephen Frost <sfrost@snowman.net>
1 sibling, 0 replies; 45+ messages in thread
From: Stephen Frost @ 2010-10-15 20:14 UTC (permalink / raw)
To: Dimitri Fontaine <dimitri@2ndQuadrant.fr>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Radosław Smogura <rsmogura@softperience.eu>; Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
Dimitri,
* Dimitri Fontaine (dimitri@2ndQuadrant.fr) wrote:
[... much useful info ...]
Thanks for all of that, I certainly appreciate it.
> By default pgbouncer maintains a different pool per database and role,
> so you should be partly covered here.
No, not really.. We have a single unprivileged account which is used
for login and then that account can 'set role' to other roles (of
course, we set it up so the login role *has* to set role to another user
to be able to do anything). I doubt pgbouncer is going to switch pooler
connections on seeing a set role and I'm not really sure it'd make sense
for it to anyway.
Thanks,
Stephen
Attachments:
signature.asc (application/pgp-signature, 196B) download
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 14:52 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 20:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Dimitri Fontaine <dimitri@2ndQuadrant.fr>
@ 2010-10-15 20:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 20:58 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
1 sibling, 1 reply; 45+ messages in thread
From: Tom Lane @ 2010-10-15 20:22 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: Dimitri Fontaine <dimitri@2ndQuadrant.fr>; Radosław Smogura <rsmogura@softperience.eu>; Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
Stephen Frost <sfrost@snowman.net> writes:
>> The whole problem with search_path and role is very frustrating. We've
>> taken to just hacking things to be dynamic SQL whenever it's
>> role-specific, but that's a really poor solution. I wonder if it would
>> be possible to have the function and prepare'd plan caches be key'd off
>> of the search_path and role too..? So if you change one of those you
>> end up having to re-plan it, but then that's also cached, etc..
FWIW, I can see the point of making cached plan lookup be
search-path-specific. But why does the active role need to factor
into it?
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 14:52 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 20:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2010-10-15 20:22 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-10-15 20:58 ` Stephen Frost <sfrost@snowman.net>
2010-10-15 21:26 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 45+ messages in thread
From: Stephen Frost @ 2010-10-15 20:58 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Dimitri Fontaine <dimitri@2ndQuadrant.fr>; Radosław Smogura <rsmogura@softperience.eu>; Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> >> The whole problem with search_path and role is very frustrating. We've
> >> taken to just hacking things to be dynamic SQL whenever it's
> >> role-specific, but that's a really poor solution. I wonder if it would
> >> be possible to have the function and prepare'd plan caches be key'd off
> >> of the search_path and role too..? So if you change one of those you
> >> end up having to re-plan it, but then that's also cached, etc..
>
> FWIW, I can see the point of making cached plan lookup be
> search-path-specific. But why does the active role need to factor
> into it?
Because of $user being used in the search_path. Thinking about it, I'm
sure we'd handle the look-up at query time and would resolve the $user
in the search_path to an actual schema first, so the cache doesn't need
to be keyed off role itself.
IOW, yeah, you're right, the role doesn't really matter. One thing that
occurs to me when I last ran into a problem with this- it was painful to
debug because the "permission denied" error didn't indicate which schema
the table it was trying to access was in. I wonder if we could fix
that.
Thanks,
Stephen
Attachments:
signature.asc (application/pgp-signature, 196B) download
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 14:52 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 20:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2010-10-15 20:22 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 20:58 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
@ 2010-10-15 21:26 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 45+ messages in thread
From: Tom Lane @ 2010-10-15 21:26 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: Dimitri Fontaine <dimitri@2ndQuadrant.fr>; Radosław Smogura <rsmogura@softperience.eu>; Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
Stephen Frost <sfrost@snowman.net> writes:
> IOW, yeah, you're right, the role doesn't really matter. One thing that
> occurs to me when I last ran into a problem with this- it was painful to
> debug because the "permission denied" error didn't indicate which schema
> the table it was trying to access was in. I wonder if we could fix
> that.
Hm, are you sure you actually got a "permission denied" error? Because
AFAICS such a message would name the schema:
regression=> select * from s1.t1;
ERROR: permission denied for schema s1
The part that is a bit nasty is if you try to put a schema in your
search_path that you don't have permissions for. My recollection is
that we just silently drop it out of the effective search path, so:
regression=> set search_path = s1, public;
SET
regression=> select current_schemas(false);
current_schemas
-----------------
{public}
(1 row)
regression=> select * from t1;
ERROR: relation "t1" does not exist
This isn't terribly user-friendly, but I'm not sure how to do better.
We can't really throw an error at the point of setting the search
path, because there are too many scenarios where a default search
path is effectively set up for you, and it might or might not list
some unsearchable (or even nonexistent) schemas.
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-10-16 02:51 ` Craig Ringer <craig@postnewspapers.com.au>
1 sibling, 0 replies; 45+ messages in thread
From: Craig Ringer @ 2010-10-16 02:51 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Stephen Frost <sfrost@snowman.net>; Radosław Smogura <rsmogura@softperience.eu>; Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
On 15/10/2010 10:38 PM, Tom Lane wrote:
> Yeah, actually what you need is DISCARD ALL when reassigning a
> connection to another client. Anything less than that assumes the
> clients are cooperating closely, ie they *want* the same prepared
> statements etc.
For what it's worth, this is quite common in the world of web apps. Java
EE application servers, in particular, tend to offer per-application
connection pools that can significantly benefit from this sort of thing.
I don't know how much that sort of co-operating group of apps is likely
to use external pooling via PgPool and friends, though. Most such apps
have an *internal* connection pool, whether managed by an appserver, web
server, or by the app code its self.
The JDBC driver's org.postgresql.ds.PGPoolingDataSource is rather
unclear about how it behaves in terms of resetting GUCs, resetting
roles, clearing prepared statements etc between connection uses, so it's
not clear what category it falls into. The docs suggest it's a bit of a
toy implementation that's not intended for real-world production use,
though. OTOH, it's not clear how connection pools like DBCP should know
how or when to do this when returning a PostgreSQL connection to the
pool, so it may well be an issue for "serious" non-Pg-specific pools
too. The JDBC spec doesn't seem to offer a generic "reset this
connection to defaults" method for use when pooling a connection.
> But even if you make that assumption, a pooler that
> isn't even capable of sending an ABORT between clients doesn't seem
> usable to me. For example, if a client loses its network connection
> mid-transaction, that failure will cascade to other clients if you
> don't have any ability to reset the database session before handing
> it to another client.
You can never really assume that the connection you get from a pool (or
have directly made) is working and usable, though. You always have to be
prepared to handle failures because someone trips over an Ethernet
cable, etc, so you can get a fresh connection and re-issue your transaction.
Nonetheless, I tend to agree that pools should make some effort to
handle failures in one connection that indicate likely failure in all
other connections, re-testing all the connections before handing them
out to clients.
--
Craig Ringer
Tech-related writing at http://soapyfrogs.blogspot.com/
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 18:03 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
@ 2010-10-15 14:23 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 45+ messages in thread
From: Tom Lane @ 2010-10-15 14:23 UTC (permalink / raw)
To: Radosław Smogura <rsmogura@softperience.eu>; +Cc: Magnus Hagander <magnus@hagander.net>; David Fetter <david@fetter.org>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc; robertmhaas@gmail.com
=?UTF-8?Q?Rados=C5=82aw_Smogura?= <rsmogura@softperience.eu> writes:
> On Fri, 15 Oct 2010 10:37:05 +0200, Magnus Hagander <magnus@hagander.net>
> wrote:
>>> But... connection pooler will not send RESET ALL in some situations,
>> To me, that sounds like a bug in the connection pooler. It is only
>> safe under quite limited circumstances.
> It's hard to say this is bug.
No it isn't. What you've described is a broken, unsafe, insecure pooler
that could not under any circumstances be recommended for general
purpose use. It might be okay if you trust all the clients to cooperate
completely, and to not have any bugs that might cause them to release a
connection while it's in a non-default state.
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-12 15:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
@ 2010-10-12 19:29 ` Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 0 replies; 45+ messages in thread
From: Tom Lane @ 2010-10-12 19:29 UTC (permalink / raw)
To: David Fetter <david@fetter.org>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; rsmogura@softperience.eu, PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
David Fetter <david@fetter.org> writes:
> Let's imagine you have a connection pooler with two clients, A and B.
> A calls setQueryTimeout, then starts a query, which terminates in
> time, but dies before handling it. B connects to the pool, gets A's
> connection, and finds a statement_timeout that's not the default, even
> though only A's single query was supposed to have that
> statement_timeout. This is not a situation that can be resolved
> without being able to set a timer *on the server side*.
Actually, that seems like a fine argument why this should *not* be
implemented on the server side... although I would expect a connection
pooler to roll back GUC changes when switching users, so the argument
seems to presume several rather broken implementation decisions in
order to make the scenario possible.
> While I'd *like* to put in a whole infrastructure for setting GUCs on
> a per-statement basis, I don't believe that we need to get out that
> giant sledgehammer for this case, even though it's worth solving.
You'd need to first convince people that SET LOCAL doesn't solve the
problem well enough already.
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
@ 2010-10-13 17:17 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-13 18:27 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
1 sibling, 1 reply; 45+ messages in thread
From: Radosław Smogura @ 2010-10-13 17:17 UTC (permalink / raw)
To: David Fetter <david@fetter.org>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
This, what I see in your patch, is sending additional statement to server.
This adds some unnecessery (especially TCP/IP) latency. gura
> > I sent such patch fully in Java
> > (http://archives.postgresql.org/pgsql-jdbc/2009-11/msg00010.php),
> > implementing cancellation with Timer and "cancel query" facility of
> > PSQL server,
>
> Would you like to update it?
I updated patch to latets CVS version, I didn't have time to remove some
trashes from it.
If something will be wrong with patch, give a feedback.
Kind regards,
Radosław Smogura
http://softperience.pl
Attachments:
statemnt_to_20101013.patch.gz (application/x-gzip, 18.1K) download
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-13 17:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
@ 2010-10-13 18:27 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 01:01 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 45+ messages in thread
From: Kevin Grittner @ 2010-10-13 18:27 UTC (permalink / raw)
To: Rados*aw Smogura <rsmogura@softperience.eu>; +Cc: David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
Rados*aw Smogura<rsmogura@softperience.eu> wrote:
> I updated patch to latets CVS version, I didn't have time to
> remove some trashes from it.
>
> If something will be wrong with patch, give a feedback.
I skimmed it and agree that it is the right general approach --
using java.util.Timer to trigger the cancel method. It doesn't
confuse the function of the setQueryTimeout method of the JDBC
driver with the statement_timeout GUC of PostgreSQL, which strike me
as no more or less similar to each other than the brakes on my car
are to a highway guardrail -- both are designed to stop something,
but under different circumstances.
I certainly can't fault you for lack of testing, since about
two-thirds of the patch is testing classes. I didn't see any need
to include the last two classes (ByteConverter and
InfiniteTimerTask); can you explain why those are in there?
That said, some of the details of the implementation gave me pause
-- there seem to be rather more moving parts and more places to
check things than the overall complexity of the problem would seem
to warrant; however, it's entirely possible that on closer review
I'll find that they were necessary for reasons which escape me on a
quick scan of the code.
If you could add this to the open CommitFest, I'll be glad to review
it (if nobody beats me to it):
https://commitfest.postgresql.org/action/commitfest_view/open
-Kevin
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-13 17:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-13 18:27 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-14 01:01 ` Robert Haas <robertmhaas@gmail.com>
2010-10-14 06:59 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
0 siblings, 1 reply; 45+ messages in thread
From: Robert Haas @ 2010-10-14 01:01 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: Rados*aw Smogura <rsmogura@softperience.eu>; David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Wed, Oct 13, 2010 at 2:27 PM, Kevin Grittner
<Kevin.Grittner@wicourts.gov> wrote:
> Rados*aw Smogura<rsmogura@softperience.eu> wrote:
>
>> I updated patch to latets CVS version, I didn't have time to
>> remove some trashes from it.
>>
>> If something will be wrong with patch, give a feedback.
>
> I skimmed it and agree that it is the right general approach --
> using java.util.Timer to trigger the cancel method. It doesn't
> confuse the function of the setQueryTimeout method of the JDBC
> driver with the statement_timeout GUC of PostgreSQL, which strike me
> as no more or less similar to each other than the brakes on my car
> are to a highway guardrail -- both are designed to stop something,
> but under different circumstances.
>
> I certainly can't fault you for lack of testing, since about
> two-thirds of the patch is testing classes. I didn't see any need
> to include the last two classes (ByteConverter and
> InfiniteTimerTask); can you explain why those are in there?
>
> That said, some of the details of the implementation gave me pause
> -- there seem to be rather more moving parts and more places to
> check things than the overall complexity of the problem would seem
> to warrant; however, it's entirely possible that on closer review
> I'll find that they were necessary for reasons which escape me on a
> quick scan of the code.
>
> If you could add this to the open CommitFest, I'll be glad to review
> it (if nobody beats me to it):
>
> https://commitfest.postgresql.org/action/commitfest_view/open
Is this a JDBC patch or a PG patch? Are we tracking JDBC patches
using the CF app?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-13 17:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-13 18:27 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 01:01 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Robert Haas <robertmhaas@gmail.com>
@ 2010-10-14 06:59 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-14 12:22 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 45+ messages in thread
From: Radosław Smogura @ 2010-10-14 06:59 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Wed, 13 Oct 2010 21:01:06 -0400, Robert Haas <robertmhaas@gmail.com>
wrote:
> Is this a JDBC patch or a PG patch? Are we tracking JDBC patches
> using the CF app?
It is JDBC patch. I will clean it and submit on this site. I didn't know
about such application and such process.
----------
Radosław Smogura
http://www.softperience.eu
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-13 17:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-13 18:27 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 01:01 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Robert Haas <robertmhaas@gmail.com>
2010-10-14 06:59 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
@ 2010-10-14 12:22 ` Robert Haas <robertmhaas@gmail.com>
2010-10-14 15:32 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
0 siblings, 1 reply; 45+ messages in thread
From: Robert Haas @ 2010-10-14 12:22 UTC (permalink / raw)
To: Radosław Smogura <rsmogura@softperience.eu>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; David Fetter <david@fetter.org>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Thu, Oct 14, 2010 at 2:59 AM, Radosław Smogura
<rsmogura@softperience.eu> wrote:
> On Wed, 13 Oct 2010 21:01:06 -0400, Robert Haas <robertmhaas@gmail.com>
> wrote:
>> Is this a JDBC patch or a PG patch? Are we tracking JDBC patches
>> using the CF app?
>
> It is JDBC patch. I will clean it and submit on this site. I didn't know
> about such application and such process.
I'm not aware that the JDBC folks participate in the CommitFest
process, so it's probably best to work with the folks on pgsql-jdbc to
figure out how they'd like to see this submitted.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 09:04 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-13 17:17 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-13 18:27 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 01:01 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Robert Haas <robertmhaas@gmail.com>
2010-10-14 06:59 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-14 12:22 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Robert Haas <robertmhaas@gmail.com>
@ 2010-10-14 15:32 ` David Fetter <david@fetter.org>
0 siblings, 0 replies; 45+ messages in thread
From: David Fetter @ 2010-10-14 15:32 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Radosław Smogura <rsmogura@softperience.eu>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; PG Hackers <pgsql-hackers@postgresql.org>; pgsql-jdbc
On Thu, Oct 14, 2010 at 08:22:21AM -0400, Robert Haas wrote:
> On Thu, Oct 14, 2010 at 2:59 AM, Radosław Smogura
> <rsmogura@softperience.eu> wrote:
> > On Wed, 13 Oct 2010 21:01:06 -0400, Robert Haas <robertmhaas@gmail.com>
> > wrote:
> >> Is this a JDBC patch or a PG patch? Are we tracking JDBC patches
> >> using the CF app?
> >
> > It is JDBC patch. I will clean it and submit on this site. I didn't know
> > about such application and such process.
>
> I'm not aware that the JDBC folks participate in the CommitFest
> process, so it's probably best to work with the folks on pgsql-jdbc to
> figure out how they'd like to see this submitted.
Perhaps they'd like to participate :)
Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
@ 2010-10-14 12:55 Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 15:28 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 45+ messages in thread
From: Kevin Grittner @ 2010-10-14 12:55 UTC (permalink / raw)
To: robertmhaas@gmail.com; +Cc: david@fetter.org; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu
Robert Haas wrote:
> Is this a JDBC patch or a PG patch? Are we tracking JDBC patches
> using the CF app?
If this were the only patch for setQueryTimeout in front of us I
probably wouldn't have suggested that, but this thread started with a
patch proposal to implement the same JDBC feature through adding new
backend functions. Unless that patch is withdrawn or rejected, it
seems odd for two different groups to be simultaneously considering
patches to implement exactly the same functionality....
-Kevin
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-14 12:55 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-14 15:28 ` Robert Haas <robertmhaas@gmail.com>
0 siblings, 0 replies; 45+ messages in thread
From: Robert Haas @ 2010-10-14 15:28 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: david@fetter.org; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu
On Thu, Oct 14, 2010 at 8:55 AM, Kevin Grittner
<Kevin.Grittner@wicourts.gov> wrote:
> Robert Haas wrote:
>
>> Is this a JDBC patch or a PG patch? Are we tracking JDBC patches
>> using the CF app?
>
> If this were the only patch for setQueryTimeout in front of us I
> probably wouldn't have suggested that, but this thread started with a
> patch proposal to implement the same JDBC feature through adding new
> backend functions. Unless that patch is withdrawn or rejected, it
> seems odd for two different groups to be simultaneously considering
> patches to implement exactly the same functionality....
True. I thought we had decided on the client-side approach, but maybe
I'm confused. I don't have a position one way or the other, just
trying to understand the state of the conversation.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
@ 2010-10-14 17:25 Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 18:40 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-10-14 21:57 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 45+ messages in thread
From: Kevin Grittner @ 2010-10-14 17:25 UTC (permalink / raw)
To: robertmhaas@gmail.com; +Cc: david@fetter.org; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu
Robert Haas wrote:
Kevin Grittner wrote:
> I thought we had decided on the client-side approach, but maybe
> I'm confused. I don't have a position one way or the other, just
> trying to understand the state of the conversation.
Well, I've been pretty vocal on supporting a client-side solution,
and Rados*aw clearly is in that camp, but that hardly makes a
consensus. David still has his patch out there, and Tom's comments
seemed to imply that he supports a solution involving the
statement_timeout GUC, so the question hardly seems settled.
Regarding JDBC in the CF process -- other interfaces are handled
there. I haven't seen one patch this size for JDBC since I've been
involved, let alone two competing patches to implement the same
feature. Small patches which can be quickly handled don't make sense
to put into the process, but it seemed reasonable for these.
-Kevin
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-14 17:25 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-14 18:40 ` Radosław Smogura <rsmogura@softperience.eu>
2010-11-22 06:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Itagaki Takahiro <itagaki.takahiro@gmail.com>
1 sibling, 1 reply; 45+ messages in thread
From: Radosław Smogura @ 2010-10-14 18:40 UTC (permalink / raw)
To: pgsql-jdbc; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; robertmhaas@gmail.com; david@fetter.org; pgsql-hackers@postgresql.org
> Regarding JDBC in the CF process -- other interfaces are handled
> there. I haven't seen one patch this size for JDBC since I've been
> involved, let alone two competing patches to implement the same
> feature. Small patches which can be quickly handled don't make sense
> to put into the process, but it seemed reasonable for these.
In any way I'm sending this patch, and I will put this under Miscellaneous in
CF. This cleared patch takes only 47k (in uncleared was some binary read
classes) and about 50% it's big test case.
Have a nice day,
Radek
Attachments:
statemnt_to_20101014.patch.gz (application/x-gzip, 8.9K) download
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-14 17:25 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 18:40 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
@ 2010-11-22 06:37 ` Itagaki Takahiro <itagaki.takahiro@gmail.com>
2010-11-23 07:33 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 45+ messages in thread
From: Itagaki Takahiro @ 2010-11-22 06:37 UTC (permalink / raw)
To: Radosław Smogura <rsmogura@softperience.eu>; +Cc: pgsql-jdbc@postgresql.org, Kevin Grittner <Kevin.Grittner@wicourts.gov>; robertmhaas@gmail.com; david@fetter.org; pgsql-hackers@postgresql.org
On Fri, Oct 15, 2010 at 03:40, Radosław Smogura
<rsmogura@softperience.eu> wrote:
>> Regarding JDBC in the CF process -- other interfaces are handled
>> there. I haven't seen one patch this size for JDBC since I've been
>> involved, let alone two competing patches to implement the same
>> feature. Small patches which can be quickly handled don't make sense
>> to put into the process, but it seemed reasonable for these.
>
> In any way I'm sending this patch, and I will put this under Miscellaneous in
> CF. This cleared patch takes only 47k (in uncleared was some binary read
> classes) and about 50% it's big test case.
I changed the patch's topic to "JDBC".
https://commitfest.postgresql.org/action/patch_view?id=399
Patch reviewers are still wanted.
--
Itagaki Takahiro
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-14 17:25 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 18:40 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-11-22 06:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Itagaki Takahiro <itagaki.takahiro@gmail.com>
@ 2010-11-23 07:33 ` Kris Jurka <books@ejurka.com>
2010-11-23 15:54 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 45+ messages in thread
From: Kris Jurka @ 2010-11-23 07:33 UTC (permalink / raw)
To: Itagaki Takahiro <itagaki.takahiro@gmail.com>; +Cc: Radosław Smogura <rsmogura@softperience.eu>; pgsql-jdbc@postgresql.org, Kevin Grittner <Kevin.Grittner@wicourts.gov>; robertmhaas@gmail.com; david@fetter.org; pgsql-hackers@postgresql.org
On Mon, 22 Nov 2010, Itagaki Takahiro wrote:
> On Fri, Oct 15, 2010 at 03:40, Rados?aw Smogura
> <rsmogura@softperience.eu> wrote:
>>> Regarding JDBC in the CF process -- other interfaces are handled
>>> there. I haven't seen one patch this size for JDBC since I've been
>>> involved, let alone two competing patches to implement the same
>>> feature. Small patches which can be quickly handled don't make sense
>>> to put into the process, but it seemed reasonable for these.
>>
>> In any way I'm sending this patch, and I will put this under Miscellaneous in
>> CF. This cleared patch takes only 47k (in uncleared was some binary read
>> classes) and about 50% it's big test case.
>
> I changed the patch's topic to "JDBC".
> https://commitfest.postgresql.org/action/patch_view?id=399
>
I don't think it makes sense to try to manage anything other than core
code in the commitfest app. The other patch touched the backend, so it
made sense to put it in the commitfest, but as far as I understand it,
this one is pure Java code. There is a backlog of JDBC issues to deal
with, but I think it needs its own commitfest instead of trying to tack on
to the main project's.
Kris Jurka
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-14 17:25 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 18:40 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Radosław Smogura <rsmogura@softperience.eu>
2010-11-22 06:37 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Itagaki Takahiro <itagaki.takahiro@gmail.com>
2010-11-23 07:33 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kris Jurka <books@ejurka.com>
@ 2010-11-23 15:54 ` Robert Haas <robertmhaas@gmail.com>
0 siblings, 0 replies; 45+ messages in thread
From: Robert Haas @ 2010-11-23 15:54 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: Itagaki Takahiro <itagaki.takahiro@gmail.com>; Radosław Smogura <rsmogura@softperience.eu>; pgsql-jdbc@postgresql.org, Kevin Grittner <Kevin.Grittner@wicourts.gov>; david@fetter.org; pgsql-hackers@postgresql.org
On Tue, Nov 23, 2010 at 2:33 AM, Kris Jurka <books@ejurka.com> wrote:
>
>
> On Mon, 22 Nov 2010, Itagaki Takahiro wrote:
>
>> On Fri, Oct 15, 2010 at 03:40, Rados?aw Smogura
>> <rsmogura@softperience.eu> wrote:
>>>>
>>>> Regarding JDBC in the CF process -- other interfaces are handled
>>>> there. I haven't seen one patch this size for JDBC since I've been
>>>> involved, let alone two competing patches to implement the same
>>>> feature. Small patches which can be quickly handled don't make sense
>>>> to put into the process, but it seemed reasonable for these.
>>>
>>> In any way I'm sending this patch, and I will put this under
>>> Miscellaneous in
>>> CF. This cleared patch takes only 47k (in uncleared was some binary read
>>> classes) and about 50% it's big test case.
>>
>> I changed the patch's topic to "JDBC".
>> https://commitfest.postgresql.org/action/patch_view?id=399
>>
>
> I don't think it makes sense to try to manage anything other than core code
> in the commitfest app. The other patch touched the backend, so it made
> sense to put it in the commitfest, but as far as I understand it, this one
> is pure Java code. There is a backlog of JDBC issues to deal with, but I
> think it needs its own commitfest instead of trying to tack on to the main
> project's.
We could have separate JDBC CommitFests inside the app if that's
helpful - the CommitFests are by convention named YYYY-MM, but the app
will support arbitrary names. The only problem I see is that it would
mess up the calculation of "the currently open CF" and "the currently
in progress CF" and "the most recently closed CF". I'd be willing to
put in the work to fix that, though, if you guys want to use the app
too.
For now I suggest we mark this Returned with Feedback.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-14 17:25 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-14 21:57 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 45+ messages in thread
From: Tom Lane @ 2010-10-14 21:57 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: robertmhaas@gmail.com; david@fetter.org; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Robert Haas wrote:
>> I thought we had decided on the client-side approach, but maybe
>> I'm confused. I don't have a position one way or the other, just
>> trying to understand the state of the conversation.
> Well, I've been pretty vocal on supporting a client-side solution,
> and Rados*aw clearly is in that camp, but that hardly makes a
> consensus. David still has his patch out there, and Tom's comments
> seemed to imply that he supports a solution involving the
> statement_timeout GUC, so the question hardly seems settled.
No, no, I was trying to point out some reasons why depending on
statement_timeout would be problematic. I'm all for doing this
client-side.
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
@ 2010-10-15 16:02 Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-21 17:49 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 45+ messages in thread
From: Kevin Grittner @ 2010-10-15 16:02 UTC (permalink / raw)
To: tgl@sss.pgh.pa.us; +Cc: david@fetter.org; robertmhaas@gmail.com; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu
Tom Lane wrote:
> I'm all for doing this client-side.
Well, that makes a big difference. Unless someone can make a
convincing argument for why we should modify the server side to
support this, I think we should just focus on this one client-side
patch.
I'd be happy to give it a closer look, but I may not be able to do so
for a few weeks, and won't complain if someone beats me to it.
-Kevin
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-15 16:02 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-21 17:49 ` Bruce Momjian <bruce@momjian.us>
2010-10-21 17:57 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
2010-10-21 18:00 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 2 replies; 45+ messages in thread
From: Bruce Momjian @ 2010-10-21 17:49 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: tgl@sss.pgh.pa.us; david@fetter.org; robertmhaas@gmail.com; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu
Kevin Grittner wrote:
> Tom Lane wrote:
>
> > I'm all for doing this client-side.
>
> Well, that makes a big difference. Unless someone can make a
> convincing argument for why we should modify the server side to
> support this, I think we should just focus on this one client-side
> patch.
>
> I'd be happy to give it a closer look, but I may not be able to do so
> for a few weeks, and won't complain if someone beats me to it.
Uh, why would we do this client-side rather than server-side? If we do
it server-side, all interfaces get it.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-15 16:02 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-21 17:49 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Bruce Momjian <bruce@momjian.us>
@ 2010-10-21 17:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-21 17:59 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Bruce Momjian <bruce@momjian.us>
1 sibling, 1 reply; 45+ messages in thread
From: Tom Lane @ 2010-10-21 17:57 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; david@fetter.org; robertmhaas@gmail.com; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu
Bruce Momjian <bruce@momjian.us> writes:
>> Tom Lane wrote:
>>> I'm all for doing this client-side.
> Uh, why would we do this client-side rather than server-side? If we do
> it server-side, all interfaces get it.
1. The API that's being implemented is JDBC-specific.
2. Even if you want to argue that it would be generally useful to have
such a feature, it would certainly require additional client-side
programming to make each client interface make use of it.
regards, tom lane
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-15 16:02 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-21 17:49 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Bruce Momjian <bruce@momjian.us>
2010-10-21 17:57 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-10-21 17:59 ` Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 45+ messages in thread
From: Bruce Momjian @ 2010-10-21 17:59 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; david@fetter.org; robertmhaas@gmail.com; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> >> Tom Lane wrote:
> >>> I'm all for doing this client-side.
>
> > Uh, why would we do this client-side rather than server-side? If we do
> > it server-side, all interfaces get it.
>
> 1. The API that's being implemented is JDBC-specific.
>
> 2. Even if you want to argue that it would be generally useful to have
> such a feature, it would certainly require additional client-side
> programming to make each client interface make use of it.
Wouldn't it be simpler to code this in the server and have the client
use that facility, rather than have the each client implement it.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-15 16:02 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-21 17:49 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Bruce Momjian <bruce@momjian.us>
@ 2010-10-21 18:00 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-21 18:06 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Bruce Momjian <bruce@momjian.us>
1 sibling, 1 reply; 45+ messages in thread
From: Kevin Grittner @ 2010-10-21 18:00 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: david@fetter.org; robertmhaas@gmail.com; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu; tgl@sss.pgh.pa.us
Bruce Momjian <bruce@momjian.us> wrote:
> why would we do this client-side rather than server-side?
Because the timeout is supposed to be a limit on the time allowed
for specific Java methods to complete, which might be running a
large number of SQL statements within one invocation, and which may
include significant network latency. It's a lot of work to get
"pretty close" on the server side, and you can never really
implement exactly what the JDBC API is requesting.
What if you have an app which can draw data from any of a number of
remote databases, and you want to use this limit so if one becomes
unavailable for some reason you can re-run the request on another
within a reasonable time? The network connection goes down after
you submit your request, you've got a period of minutes or hours
until TCP gives up, and the user expects a response within a few
seconds...
If you implement something with server-side semantics, there's
nothing to prevent an application which is PostgreSQL-aware from
accessing it through JDBC, of course. statement_timeout and other
GUCs can be set locally to your heart's content.
-Kevin
^ permalink raw reply [nested|flat] 45+ messages in thread
* Re: [JDBC] Support for JDBC setQueryTimeout, et al.
2010-10-15 16:02 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-21 17:49 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Bruce Momjian <bruce@momjian.us>
2010-10-21 18:00 ` Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2010-10-21 18:06 ` Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 45+ messages in thread
From: Bruce Momjian @ 2010-10-21 18:06 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: david@fetter.org; robertmhaas@gmail.com; pgsql-hackers@postgresql.org; pgsql-jdbc; rsmogura@softperience.eu; tgl@sss.pgh.pa.us
Kevin Grittner wrote:
> Bruce Momjian <bruce@momjian.us> wrote:
>
> > why would we do this client-side rather than server-side?
>
> Because the timeout is supposed to be a limit on the time allowed
> for specific Java methods to complete, which might be running a
> large number of SQL statements within one invocation, and which may
> include significant network latency. It's a lot of work to get
> "pretty close" on the server side, and you can never really
> implement exactly what the JDBC API is requesting.
>
> What if you have an app which can draw data from any of a number of
> remote databases, and you want to use this limit so if one becomes
> unavailable for some reason you can re-run the request on another
> within a reasonable time? The network connection goes down after
> you submit your request, you've got a period of minutes or hours
> until TCP gives up, and the user expects a response within a few
> seconds...
>
> If you implement something with server-side semantics, there's
> nothing to prevent an application which is PostgreSQL-aware from
> accessing it through JDBC, of course. statement_timeout and other
> GUCs can be set locally to your heart's content.
OK, thanks. Just had to ask.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply [nested|flat] 45+ messages in thread
end of thread, other threads:[~2010-11-23 15:54 UTC | newest]
Thread overview: 45+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-10-11 06:46 Support for JDBC setQueryTimeout, et al. David Fetter <david@fetter.org>
2010-10-11 13:29 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-11 14:17 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-11 14:27 ` Magnus Hagander <magnus@hagander.net>
2010-10-11 14:31 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-12 09:04 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-12 14:14 ` David Fetter <david@fetter.org>
2010-10-12 15:37 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 15:55 ` David Fetter <david@fetter.org>
2010-10-12 16:23 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-12 18:03 ` Magnus Hagander <magnus@hagander.net>
2010-10-15 06:56 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 08:37 ` Magnus Hagander <magnus@hagander.net>
2010-10-15 09:11 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-15 14:21 ` Stephen Frost <sfrost@snowman.net>
2010-10-15 14:38 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 14:52 ` Stephen Frost <sfrost@snowman.net>
2010-10-15 20:03 ` Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2010-10-15 20:14 ` Stephen Frost <sfrost@snowman.net>
2010-10-15 20:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 20:58 ` Stephen Frost <sfrost@snowman.net>
2010-10-15 21:26 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-16 02:51 ` Craig Ringer <craig@postnewspapers.com.au>
2010-10-15 14:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-12 19:29 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-13 17:17 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-13 18:27 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 01:01 ` Robert Haas <robertmhaas@gmail.com>
2010-10-14 06:59 ` Radosław Smogura <rsmogura@softperience.eu>
2010-10-14 12:22 ` Robert Haas <robertmhaas@gmail.com>
2010-10-14 15:32 ` David Fetter <david@fetter.org>
2010-10-14 12:55 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 15:28 ` Robert Haas <robertmhaas@gmail.com>
2010-10-14 17:25 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-14 18:40 ` Radosław Smogura <rsmogura@softperience.eu>
2010-11-22 06:37 ` Itagaki Takahiro <itagaki.takahiro@gmail.com>
2010-11-23 07:33 ` Kris Jurka <books@ejurka.com>
2010-11-23 15:54 ` Robert Haas <robertmhaas@gmail.com>
2010-10-14 21:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-15 16:02 Re: [JDBC] Support for JDBC setQueryTimeout, et al. Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-21 17:49 ` Bruce Momjian <bruce@momjian.us>
2010-10-21 17:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-10-21 17:59 ` Bruce Momjian <bruce@momjian.us>
2010-10-21 18:00 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-21 18:06 ` Bruce Momjian <bruce@momjian.us>
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