This discussion is archived
1 Reply Latest reply: Aug 9, 2012 7:05 AM by greybird RSS

Problem with SecondaryDatabase

954623 Newbie
Currently Being Moderated
I'm adding, searching and updating data using the primary Database and it's keys with no problem. However, when using a SecondaryDatabase to hold an additional index, I get an error.

More specifically. Here is my secondaryDataBase def:

SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setTransactional(!readOnly);
secConfig.setAllowCreate(!readOnly);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(new NameKeyCreator(solrValueBinding));
solrByNameDb = env.openSecondaryDatabase(null, Props.FIELDS.name.toString(), solrDb, secConfig)

Notice the secondaryDataBase supports multiple values per key ( secConfig.setSortedDuplicates(true); )

When searching for recrods using:
Cursor cursor = db.openCursor(null, null);
try{         
     os = cursor.getSearchKey(foundKey, foundData, null);
     
}catch (DatabaseException dbe){
     _log.error(dbe.getMessage());
     dbe.printStackTrace();
}

I'm getting ok result with the primary DB but with the secondary I get the below error.:

08:54:42.251 [main] ERROR com.fetch5.util.bdb.BdbHelper - (JE 5.0.58) Lock expired. Locker 1785326922 -1_main_ThreadLocker: waited for lock on database=name LockAddr:1348062170 LSN=0x0/0xd4f type=READ grant=WAIT_NEW timeoutMillis=500 startTime=1344491679284 endTime=1344491679785
Owners: [<LockInfo locker="1053738893 8_main_Txn" type="WRITE"/>]
Waiters: []

com.sleepycat.je.LockTimeoutException: (JE 5.0.58) Lock expired. Locker 1785326922 -1_main_ThreadLocker: waited for lock on database=name LockAddr:1348062170 LSN=0x0/0xd4f type=READ grant=WAIT_NEW timeoutMillis=500 startTime=1344491679284 endTime=1344491679785
Owners: [<LockInfo locker="1053738893 8_main_Txn" type="WRITE"/>]
Waiters: []

     at com.sleepycat.je.txn.LockManager.newLockTimeoutException(LockManager.java:664)
     at com.sleepycat.je.txn.LockManager.makeTimeoutMsgInternal(LockManager.java:623)
     at com.sleepycat.je.txn.SyncedLockManager.makeTimeoutMsg(SyncedLockManager.java:97)
     at com.sleepycat.je.txn.LockManager.lockInternal(LockManager.java:390)
     at com.sleepycat.je.txn.LockManager.lock(LockManager.java:276)
     at com.sleepycat.je.txn.BasicLocker.lockInternal(BasicLocker.java:118)
     at com.sleepycat.je.txn.Locker.lock(Locker.java:443)
     at com.sleepycat.je.dbi.CursorImpl.lockLN(CursorImpl.java:2589)
     at com.sleepycat.je.dbi.CursorImpl.lockLN(CursorImpl.java:2390)
     at com.sleepycat.je.dbi.CursorImpl.fetchCurrent(CursorImpl.java:2221)
     at com.sleepycat.je.dbi.CursorImpl.getCurrentAlreadyLatched(CursorImpl.java:1434)
     at com.sleepycat.je.dbi.CursorImpl.getNext(CursorImpl.java:1561)
     at com.sleepycat.je.Cursor.searchInternal(Cursor.java:2742)
     at com.sleepycat.je.Cursor.searchAllowPhantoms(Cursor.java:2576)
     at com.sleepycat.je.Cursor.searchNoDups(Cursor.java:2430)
     at com.sleepycat.je.Cursor.dupsGetSearchKey(Cursor.java:3550)
     at com.sleepycat.je.Cursor.searchHandleDups(Cursor.java:3520)
     at com.sleepycat.je.Cursor.search(Cursor.java:2395)
     at com.sleepycat.je.SecondaryCursor.search(SecondaryCursor.java:1365)
     at com.sleepycat.je.SecondaryCursor.getSearchKey(SecondaryCursor.java:1087)
     at com.sleepycat.je.SecondaryCursor.getSearchKey(SecondaryCursor.java:1025)
     at com.fetch5.util.bdb.BdbHelper.getSolrDocuments(BdbHelper.java:147)
     at com.fetch5.util.bdb.BdbHelper.addSolrDocuments(BdbHelper.java:86)
     at com.fetch5.util.bdb.BdbHelper$PopulateDatabase.doWork(BdbHelper.java:189)
     at com.sleepycat.collections.TransactionRunner.run(TransactionRunner.java:226)
     at com.fetch5.util.bdb.BdbHelper.runAddSolrDocuments(BdbHelper.java:52)
     at com.fetch5.util.bdb.BdbHelperTest.testPopulateDatabase(BdbHelperTest.java:76)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
     at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
     at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
     at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
     at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


Help is appreciated
Thanks
-Yair
  • 1. Re: Problem with SecondaryDatabase
    greybird Expert
    Currently Being Moderated
    Yair,

    When using secondary databases and when performing concurrent reads and writes, lock timeouts due to deadlocks are expected and must be handled by your application by retrying.

    Please refer to this material:
    http://www.oracle.com/technetwork/database/berkeleydb/je-faq-096044.html#HowdoIdebugalocktimeout
    http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/je/LockConflictException.html
    http://docs.oracle.com/cd/E17277_02/html/TransactionGettingStarted/jelock.html#jedeadlock

    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points