dbTalk Databases Forums  

About "DB_TXN->set_timeout"

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss About "DB_TXN->set_timeout" in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sunnyboy (Offline)
Junior Member
 
Posts: 4
Join Date: Jul 2006

Smile About "DB_TXN->set_timeout" - 08-02-2006 , 01:13 AM






Configure the timeout value for the transaction lifetime.

If the transaction runs longer than this time, the transaction may throw DatabaseException.

This is the question that where does the transaction lifetime begin, and where is the end?

Code:
/* Begin our transaction. */ ret = envp->txn_begin(envp, NULL, &txn, 0); //write transaction timeout 5 second ret = txn->set_timeout(txn, 5000000, DB_SET_TXN_TIMEOUT); for (j = 0; j < 10; j++) { ... ... ... ... /* Perform the database put. */ switch (ret = dbp->put(dbp, txn, &key, &value, 0)) { case 0: break; case DB_KEYEXIST: printf("Got keyexists.\n"); break; case DB_LOCK_DEADLOCK: (void)txn->abort(txn); if (retry_count < max_retries) { retry_count++; goto retry; } return (EXIT_FAILURE); default: envp->err(envp, ret, "db put failed"); ret = txn->abort(txn); if (ret != 0) envp->err(envp, ret, "txn abort failed"); return (EXIT_FAILURE); } /** End case statement **/ } /** End for loop **/ ret = txn->commit(txn, 0);

Last edited by sunnyboy : 08-02-2006 at 08:12 PM .

Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: About "DB_TXN->set_timeout" - 08-03-2006 , 11:01 AM






Hi SunnyBoy,

In case of DB_SET_TXN_TIMEOUT, the beginning of the time is from the
first lock request, until it will be checked and the timeout is
surpassed.

Timeout is checked is case of:
- lock requests (and DB_LOCK_NOTGRANTED will be returned if the
transaction has been longer than the specified timeout)
- deadlock detector is called.

Actually, transactions will continue to run after their timeout has
expired if they do not block on a lock request after that time, this is
why the exact time is indeterminate as described in the documentation
in more detail:
http://www.sleepycat.com/docs/ref/lock/timeout.html - also a short
"transaction timeout"/"lock timeout" example is provided here.
http://www.sleepycat.com/docs/ref/lock/intro.html
http://www.sleepycat.com/docs/api_c/...t_timeout.html

Thank you,
Bogdan Coman, Oracle


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.