jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1060431 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: journal/DatabaseJournal.java util/db/ConnectionHelper.java
Date Tue, 18 Jan 2011 16:05:03 GMT
Author: jukka
Date: Tue Jan 18 16:05:03 2011
New Revision: 1060431

URL: http://svn.apache.org/viewvc?rev=1060431&view=rev
Log:
JCR-2832: Crash when adding node to cluster with big journal on PSQL DB

Patch by Omid Milani

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java?rev=1060431&r1=1060430&r2=1060431&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
Tue Jan 18 16:05:03 2011
@@ -435,6 +435,32 @@ public class DatabaseJournal extends Abs
     }
 
     /**
+     * Synchronize contents from journal. May be overridden by subclasses.
+     * Override to do it in batchMode, since some databases (PSQL) when 
+     * not in transactional mode, load all results in memory which causes
+     * out of memory.
+     *
+     * @param startRevision start point (exclusive)
+     * @throws JournalException if an error occurs
+     */
+    @Override
+    protected void doSync(long startRevision) throws JournalException {
+        try {
+            conHelper.startBatch();
+            super.doSync(startRevision);
+        } catch (SQLException e) {
+            // Should throw journal exception instead of just logging it?
+            log.error("couldn't sync the cluster node", e);
+        } finally {
+            try {
+                conHelper.endBatch(true);
+            } catch (SQLException e) {
+                log.warn("couldn't close connection", e);
+            }
+        }
+    }
+
+    /**
      * {@inheritDoc}
      * <p/>
      * This journal is locked by incrementing the current value in the table

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java?rev=1060431&r1=1060430&r2=1060431&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Tue Jan 18 16:05:03 2011
@@ -355,6 +355,7 @@ public class ConnectionHelper {
                 stmt = con.prepareStatement(sql);
             }
             stmt.setMaxRows(maxRows);
+            stmt.setFetchSize(10000);
             execute(stmt, params);
             if (returnGeneratedKeys) {
                 rs = stmt.getGeneratedKeys();



Mime
View raw message