Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 37612 invoked from network); 23 Apr 2007 06:13:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Apr 2007 06:13:38 -0000 Received: (qmail 56826 invoked by uid 500); 23 Apr 2007 06:13:43 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 56802 invoked by uid 500); 23 Apr 2007 06:13:43 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 56773 invoked by uid 99); 23 Apr 2007 06:13:43 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Apr 2007 23:13:43 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 Apr 2007 23:13:35 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5BB34714069 for ; Sun, 22 Apr 2007 23:13:15 -0700 (PDT) Message-ID: <8640059.1177308795372.JavaMail.jira@brutus> Date: Sun, 22 Apr 2007 23:13:15 -0700 (PDT) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-2566) OutOfMemory/Sanity-assert failed when updating database In-Reply-To: <29247575.1176987075976.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-2566?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Knut Anders Hatlen updated DERBY-2566: -------------------------------------- Fix Version/s: 10.2.2.1 Committed to the 10.2 branch with revision 531345. > OutOfMemory/Sanity-assert failed when updating database > ------------------------------------------------------- > > Key: DERBY-2566 > URL: https://issues.apache.org/jira/browse/DERBY-2566 > Project: Derby > Issue Type: Bug > Components: Store > Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.0.0 > Environment: Sun JDK 1.6-b105, Linux 2.6.20 > Sun JDK 1.5, Solaris 10 > Reporter: Kurt Huwig > Assigned To: Knut Anders Hatlen > Fix For: 10.2.2.1, 10.3.0.0 > > Attachments: closeactivation.diff, closeactivations_v2.diff, Derby2566Repro.java > > > If you run this application: > -------- 8< ------- > import java.sql.*; > import java.util.*; > public class DerbyBug4 { > private static String x; > private static Random random = new Random(0); > private static final int DB_SIZE = 10000; > public static void main(String[] args) throws Exception { > final StringBuilder sbX = new StringBuilder(); > for (int i = 0; i < 65535; i++) { > sbX.append('X'); > } > x = sbX.toString(); > Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); > final Connection con = > DriverManager.getConnection("jdbc:derby:bug;create=true"); > createAndFillDatabase(con); > updateDatabase(con); > con.close(); > } > private static void updateDatabase(final Connection con) throws SQLException { > final Statement stm = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, > ResultSet.CONCUR_UPDATABLE); > final ResultSet rs = stm.executeQuery("SELECT * FROM journal FOR UPDATE"); > for (int row = 1; rs.next(); row++) { > update(rs, "ip"); > update(rs, "sender"); > update(rs, "recipient"); > update(rs, "mailsender"); > update(rs, "mailfrom"); > update(rs, "mailto"); > update(rs, "cc"); > update(rs, "bcc"); > update(rs, "replyto"); > update(rs, "subject"); > update(rs, "attachments"); > update(rs, "status"); > update(rs, "reason"); > rs.updateInt("totallength", 0); > rs.updateDouble("spamscore", 0); > rs.updateRow(); > if (row % 500 == 0) { > System.out.println("update: " + row); > } > } > rs.close(); > stm.close(); > } > private static void createAndFillDatabase(Connection con) > throws SQLException { > final Statement stm = con.createStatement(); > stm.executeUpdate("CREATE TABLE journal(" > + "ID VARCHAR(20) PRIMARY KEY default '' NOT NULL," > + "IP VARCHAR(45) default '' NOT NULL," > + "SENDER VARCHAR(32000) default '' NOT NULL," > + "RECIPIENT VARCHAR(32000) default '' NOT NULL," > + "MAILSENDER VARCHAR(32000) default '' NOT NULL," > + "MAILFROM VARCHAR(32000) default '' NOT NULL," > + "MAILTO VARCHAR(32000) default '' NOT NULL," > + "CC VARCHAR(32000) default '' NOT NULL," > + "BCC VARCHAR(32000) default '' NOT NULL," > + "REPLYTO VARCHAR(32000) default '' NOT NULL," > + "MAILDATE TIMESTAMP default '0001-01-01 00:00:00'," > + "RECEIVEDDATE TIMESTAMP default '0001-01-01 00:00:00' NOT NULL," > + "SUBJECT VARCHAR(32000) default '' NOT NULL," > + "TOTALLENGTH BIGINT default 0 NOT NULL," > + "ATTACHMENTS VARCHAR(32000) default '' NOT NULL," > + "SPAMSCORE DOUBLE NOT NULL," > + "STATUS VARCHAR(11) default 'aborted' NOT NULL," > + "REASON VARCHAR(32000) NOT NULL)"); > con.commit(); > stm.close(); > > final PreparedStatement pstm = con.prepareStatement( > "INSERT INTO journal VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); > for (int i = 0; i < DB_SIZE; i++) { > int col = 1; > pstm.setString(col++, Integer.toHexString(i)); > doRandom(pstm, col++, 45); > doRandom(pstm, col++, 10); > doRandom(pstm, col++, 10); > doRandom(pstm, col++, 5); > doRandom(pstm, col++, 20); > doRandom(pstm, col++, 20); > doRandom(pstm, col++, 40); > doRandom(pstm, col++, 5); > doRandom(pstm, col++, 20); > pstm.setTimestamp(col++, random.nextBoolean() > ? new Timestamp(System.currentTimeMillis()) > : null); > pstm.setTimestamp(col++, new Timestamp(System.currentTimeMillis())); > doRandom(pstm, col++, 80); > pstm.setInt(col++, random.nextInt(10000000)); > doRandom(pstm, col++, 500); > pstm.setDouble(col++, random.nextDouble() * 10); > doRandom(pstm, col++, 11); > doRandom(pstm, col++, 100); > > pstm.executeUpdate(); > if (i % 500 == 0) { > con.commit(); > System.out.println("insert: " + i); > } > } > con.commit(); > pstm.close(); > } > private static void doRandom(PreparedStatement pstm, int pos, int length) > throws SQLException { > pstm.setString(pos, x.substring(0, random.nextInt(length))); > } > > private static void update(final ResultSet rs, final String field) > throws SQLException { > rs.updateString(field, x.substring(0, rs.getString(field).length())); > } > } > -------- 8< ------- > you will get this exception: > Exception in thread "main" java.lang.OutOfMemoryError: Java heap space > at org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream.(Unknown Source) > at org.apache.derby.impl.store.raw.data.StoredPage.storeRecordForUpdate(Unknown Source) > at org.apache.derby.impl.store.raw.data.StoredPage.storeRecord(Unknown Source) > at org.apache.derby.impl.store.raw.data.UpdateOperation.doMe(Unknown Source) > at org.apache.derby.impl.store.raw.log.FileLogger.logAndDo(Unknown Source) > at org.apache.derby.impl.store.raw.xact.Xact.logAndDo(Unknown Source) > at org.apache.derby.impl.store.raw.data.LoggableActions.doAction(Unknown Source) > at org.apache.derby.impl.store.raw.data.LoggableActions.actionUpdate(Unknown Source) > at org.apache.derby.impl.store.raw.data.StoredPage.doUpdateAtSlot(Unknown Source) > at org.apache.derby.impl.store.raw.data.BasePage.updateAtSlot(Unknown Source) > at org.apache.derby.impl.store.access.conglomerate.GenericConglomerateController.replace(Unknown Source) > at org.apache.derby.impl.sql.execute.RowChangerImpl.updateRow(Unknown Source) > at org.apache.derby.impl.sql.execute.UpdateResultSet.collectAffectedRows(Unknown Source) > at org.apache.derby.impl.sql.execute.UpdateResultSet.open(Unknown Source) > at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedResultSet.updateRow(Unknown Source) > at DerbyBug4.updateDatabase(DerbyBug4.java:43) > at DerbyBug4.main(DerbyBug4.java:19) > If you enable sanity checks, then this exception occurs: > Exception in thread "main" org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED statementContext is not expected to equal statementContexts[0] > at org.apache.derby.shared.common.sanity.SanityManager.ASSERT(SanityManager.java:120) > at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.popStatementContext(GenericLanguageConnectionContext.java:2095) > at org.apache.derby.impl.jdbc.EmbedResultSet.updateRow(EmbedResultSet.java:3773) > at DerbyBug4.updateDatabase(DerbyBug4.java:43) > at DerbyBug4.main(DerbyBug4.java:19) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.