diff options
author | unknown <mronstrom@mysql.com> | 2004-06-14 14:23:48 +0200 |
---|---|---|
committer | unknown <mronstrom@mysql.com> | 2004-06-14 14:23:48 +0200 |
commit | 0495242ff98986886b2495f0bf66c8f35f8c8f06 (patch) | |
tree | 7b8d4c7f1f84dfc877c596d185bdf6d11a85b50b /ndb | |
parent | 4e3b3bc8350779e8f7d5a14aa1fa66fc4c9241ac (diff) | |
parent | 3469cc22e73cf402ce8fdc3cc329d6f206284170 (diff) | |
download | mariadb-git-0495242ff98986886b2495f0bf66c8f35f8c8f06.tar.gz |
Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb
into mysql.com:/Users/mikron/wl1823
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 106 |
1 files changed, 57 insertions, 49 deletions
diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 1c916c2754c..1c03d70adb8 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -5950,62 +5950,70 @@ void Dbtc::checkStartFragTimeout(Signal* signal) /* BEEN DELAYED FOR SO LONG THAT WE ARE FORCED TO PERFORM */ /* SOME ACTION, EITHER ABORT OR RESEND OR REMOVE A NODE FROM */ /* THE WAITING PART OF A PROTOCOL. */ +/* +The algorithm used here is to check 1024 transactions at a time before +doing a real-time break. +To avoid aborting both transactions in a deadlock detected by time-out +we insert a random extra time-out of upto 630 ms by using the lowest +six bits of the api connect reference. +We spread it out from 0 to 630 ms if base time-out is larger than 3 sec, +we spread it out from 0 to 70 ms if base time-out is smaller than 300 msec, +and otherwise we spread it out 310 ms. +*/ /*------------------------------------------------------------------*/ -void Dbtc::timeOutLoopStartLab(Signal* signal, Uint32 TapiConPtr) +void Dbtc::timeOutLoopStartLab(Signal* signal, Uint32 api_con_ptr) { - UintR texpiredTime[8]; - UintR TloopCount = 0; + Uint32 end_ptr, time_passed, time_out_value, mask_value; + const Uint32 api_con_sz= capiConnectFilesize; + const Uint32 tc_timer= ctcTimer; + const Uint32 time_out_param= ctimeOutValue; - ctimeOutCheckHeartbeat = ctcTimer; + ctimeOutCheckHeartbeat = tc_timer; - const Uint32 TapiConSz = capiConnectFilesize; - const Uint32 TtcTimer = ctcTimer; - const Uint32 TtimeOutValue = ctimeOutValue; - - while ((TapiConPtr + 8) < TapiConSz) { - jam(); - texpiredTime[0] = TtcTimer - getApiConTimer(TapiConPtr + 0); - texpiredTime[1] = TtcTimer - getApiConTimer(TapiConPtr + 1); - texpiredTime[2] = TtcTimer - getApiConTimer(TapiConPtr + 2); - texpiredTime[3] = TtcTimer - getApiConTimer(TapiConPtr + 3); - texpiredTime[4] = TtcTimer - getApiConTimer(TapiConPtr + 4); - texpiredTime[5] = TtcTimer - getApiConTimer(TapiConPtr + 5); - texpiredTime[6] = TtcTimer - getApiConTimer(TapiConPtr + 6); - texpiredTime[7] = TtcTimer - getApiConTimer(TapiConPtr + 7); - for (Uint32 Ti = 0; Ti < 8; Ti++) { - if (getApiConTimer(TapiConPtr + Ti) != 0) { - if (texpiredTime[Ti] > TtimeOutValue) { - jam(); - timeOutFoundLab(signal, TapiConPtr + Ti); - return; - }//if - }//if - }//for - TapiConPtr += 8; - if (TloopCount++ > 128) { - jam(); - sendContinueTimeOutControl(signal, TapiConPtr); - return; - }//if - }//while - for ( ; TapiConPtr < TapiConSz; TapiConPtr++) { + if (api_con_ptr + 1024 < api_con_sz) { + jam(); + end_ptr= api_con_ptr + 1024; + } else { + jam(); + end_ptr= api_con_sz; + } + if (time_out_param > 300) { + jam(); + mask_value= 63; + } else if (time_out_param < 30) { + jam(); + mask_value= 7; + } else { + jam(); + mask_value= 31; + } + for ( ; api_con_ptr < end_ptr; api_con_ptr++) { + Uint32 api_timer= getApiConTimer(api_con_ptr); jam(); - if (getApiConTimer(TapiConPtr) != 0) { - texpiredTime[0] = TtcTimer - getApiConTimer(TapiConPtr); - if (texpiredTime[0] > TtimeOutValue) { + if (api_timer != 0) { + time_out_value= time_out_param + (api_con_ptr & mask_value); + time_passed= tc_timer - api_timer; + if (time_passed > time_out_value) { jam(); - timeOutFoundLab(signal, TapiConPtr); + timeOutFoundLab(signal, api_con_ptr); return; - }//if - }//if - }//for - /*------------------------------------------------------------------*/ - /* */ - /* WE HAVE NOW CHECKED ALL TRANSACTIONS FOR TIME-OUT AND ALSO */ - /* STARTED TIME-OUT HANDLING OF THOSE WE FOUND. WE ARE NOW */ - /* READY AND CAN WAIT FOR THE NEXT TIME-OUT CHECK. */ - /*------------------------------------------------------------------*/ - ctimeOutCheckActive = TOCS_FALSE; + } + } + } + if (api_con_ptr == api_con_sz) { + jam(); + /*------------------------------------------------------------------*/ + /* */ + /* WE HAVE NOW CHECKED ALL TRANSACTIONS FOR TIME-OUT AND ALSO */ + /* STARTED TIME-OUT HANDLING OF THOSE WE FOUND. WE ARE NOW */ + /* READY AND CAN WAIT FOR THE NEXT TIME-OUT CHECK. */ + /*------------------------------------------------------------------*/ + ctimeOutCheckActive = TOCS_FALSE; + } else { + jam(); + sendContinueTimeOutControl(signal, api_con_ptr); + } + return; }//Dbtc::timeOutLoopStartLab() void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr) |