openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-878) Support default query hint for query timeout
Date Thu, 12 Mar 2009 17:26:50 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12681406#action_12681406
] 

Pinaki Poddar commented on OPENJPA-878:
---------------------------------------

The very fact that following code (or similar variants) appears 10+ times in the patch points
that a better solution/refactoring is required. 
It is not about that the patch is getting it wrong (in fact, the patch shows thoroughness)
but the way existing things are. 

Given that
1) the research finds that time outs may better be handled database server side
2) JDBC does not support a lockTimeOut and we are emulating it by query time out
3) databases employ specific techniques for server side time outs
4) the current timeout requires us to duplicate same code block +10 times
 
I suggest
a) move the duplicated code to DBDictionary -- this default implement will do what we do today
i.e. emulate locktimeout via querytimeout.
this will remove/minimize duplication of code and will localize the timeout function at one
place
b) incrementally add specific database time out functions for server side time out



+    protected void setTimeout(PreparedStatement stmnt, JDBCStore store,
+        JDBCFetchConfiguration fetch)
+        throws SQLException {
+        if (store.getDBDictionary().supportsQueryTimeout) {
+            int timeout = fetch.getQueryTimeout();
+            if (timeout >= 0) {
+                if (timeout > 0 && timeout < 1000) {
+                    timeout = 1000; 
+                    Log log = store.getConfiguration().getLog(JDBCConfiguration.LOG_JDBC);
+                    if (log.isWarnEnabled())
+                        log.warn(_loc.get("millis-query-timeout"));
+                }
+                stmnt.setQueryTimeout(timeout / 1000);
+            }
+        }
+    }
+    


> Support default query hint for query timeout
> --------------------------------------------
>
>                 Key: OPENJPA-878
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-878
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: query
>    Affects Versions: 2.0.0
>            Reporter: Donald Woods
>            Assignee: Donald Woods
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-878-20090305-draft.patch, OPENJPA-878-20090306.patch, OPENJPA-878-20090310-eclipse.patch,
OPENJPA-878-20090310.patch, OPENJPA-878-20090311-eclipse.patch, OPENJPA-878-20090311.patch,
OPENJPA-878-20090311.patch, OPENJPA-878-20090312-minimal.patch, OPENJPA-878-docs-20090311.patch
>
>
> Support default query hint for query timeout as defined in section 3.6.4 of the spec.
> A new hint can be supplied for Java SE and Java EE environments -
>     javax.persistence.query.timeout // query timeout in seconds
> Can be used in the following:
>     Methods - Query.setHint()
>     Annotations (via QueryHint) - NamedQuery, NativeNamedQuery 
>     Properties - Persistence.createEntityManagerFactory, persistence.xml
> The following methods can return a javax.persistence.QueryTimeoutException: getResultList(),
getSingleResult(), executeUpdate().
> If a QTE is thrown, the current transaction (if active) should not be marked for rollback.
> If the DB query timeout causes a rollback, then a PersistenceException should be thrown
instead (see 3.6.1).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message