google-code-export / sqljet

Automatically exported from code.google.com/p/sqljet
0 stars 1 forks source link

Corruption after Rollback #146

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using trunk version and this test case fails.

public class JetCorruptionTest
{
  private File dbFile;
  private SqlJetDb db;
  @Before
  public void setUp() throws Exception {
    dbFile = new File("D:\\jetdbtest.db");
    db = SqlJetDb.open(dbFile, true);
    db.createTable("CREATE TABLE IF NOT EXISTS places (place_id INTEGER PRIMARY KEY AUTOINCREMENT,geoid INTEGER NOT NULL,class_id INTEGER NOT NULL,country_id INTEGER NOT NULL,name TEXT NOT NULL,user_defined INTEGER NOT NULL,location_lon INTEGER,location_lat INTEGER)");
    }
  @After
  public void tearDown() throws Exception {
    db.close();
    dbFile.delete();
  }

  @Test
  public void testTransaction() throws Exception {
    ISqlJetTable table = db.getTable("places");
    db.beginTransaction(SqlJetTransactionMode.WRITE);

    for (int i=0; i< 2000;++i)
    {
      table.insertOr(SqlJetConflictAction.REPLACE, null,i,i%2,i%3,4,"hhhh",6,7);
    }
    db.rollback();
    db.beginTransaction(SqlJetTransactionMode.WRITE);

    for (int i=0; i< 2000;++i)
    {
      table.insertOr(SqlJetConflictAction.REPLACE, null,i,i%2,i%3,4,"kkk",6,7);
    }
    db.commit();
  }
}

Stack:
org.tmatesoft.sqljet.core.SqlJetException: CORRUPT: error code is CORRUPT
    at org.tmatesoft.sqljet.core.internal.btree.SqlJetBtreeShared.getAndInitPage(SqlJetBtreeShared.java:980)
    at org.tmatesoft.sqljet.core.internal.btree.SqlJetBtreeCursor.moveToChild(SqlJetBtreeCursor.java:417)
    at org.tmatesoft.sqljet.core.internal.btree.SqlJetBtreeCursor.moveToLeftmost(SqlJetBtreeCursor.java:1974)
    at org.tmatesoft.sqljet.core.internal.btree.SqlJetBtreeCursor.first(SqlJetBtreeCursor.java:1951)
    at org.tmatesoft.sqljet.core.internal.table.SqlJetBtreeTable.first(SqlJetBtreeTable.java:152)
    at org.tmatesoft.sqljet.core.internal.table.SqlJetBtreeTable.init(SqlJetBtreeTable.java:90)
    at org.tmatesoft.sqljet.core.internal.table.SqlJetBtreeTable.<init>(SqlJetBtreeTable.java:65)
    at org.tmatesoft.sqljet.core.internal.table.SqlJetBtreeDataTable.<init>(SqlJetBtreeDataTable.java:74)
    at org.tmatesoft.sqljet.core.internal.table.SqlJetTable$3.run(SqlJetTable.java:157)
    at org.tmatesoft.sqljet.core.table.SqlJetDb$3.run(SqlJetDb.java:200)
    at org.tmatesoft.sqljet.core.table.engine.SqlJetEngine$8.runSynchronized(SqlJetEngine.java:400)
    at org.tmatesoft.sqljet.core.table.engine.SqlJetEngine.runSynchronized(SqlJetEngine.java:148)
    at org.tmatesoft.sqljet.core.table.engine.SqlJetEngine.runEngineTransaction(SqlJetEngine.java:394)
    at org.tmatesoft.sqljet.core.table.SqlJetDb.runTransaction(SqlJetDb.java:198)
    at org.tmatesoft.sqljet.core.table.SqlJetDb.runWriteTransaction(SqlJetDb.java:171)
    at org.tmatesoft.sqljet.core.internal.table.SqlJetTable.runWriteTransaction(SqlJetTable.java:155)
    at org.tmatesoft.sqljet.core.internal.table.SqlJetTable.insertOr(SqlJetTable.java:180)
    at cz.tdp.sqljet.JetCorruptionTest.testTransaction(JetCorruptionTest.java:86)

Original issue reported on code.google.com by jhruby....@gmail.com on 18 Jan 2011 at 3:16

GoogleCodeExporter commented 9 years ago

Original comment by sergey.s...@gmail.com on 18 Jan 2011 at 3:19

GoogleCodeExporter commented 9 years ago
Fixed in 'trunk'.

Thanks a lot for reporting.

Original comment by sergey.s...@gmail.com on 21 Jan 2011 at 2:26

GoogleCodeExporter commented 9 years ago
DB file corruption is real problem. :-)

Original comment by jhruby....@gmail.com on 21 Jan 2011 at 3:17

GoogleCodeExporter commented 9 years ago
Problem is still exist?

Original comment by sergey.s...@gmail.com on 21 Jan 2011 at 3:23

GoogleCodeExporter commented 9 years ago
I have not tested yet.

Original comment by jhruby....@gmail.com on 21 Jan 2011 at 3:26