鐩綍
杩欎釜闄勫綍甯姪浣犳妸MySQL绉绘鍒板叾瀹冩搷浣滅郴缁熴傝鍏堟煡鐪嬩竴涓嬪綋鍓嶆敮鎸佹搷浣滅郴缁熷垪琛ㄣ傝鍙傞槄2.1.1鑺傦紝鈥淢ySQL鏀寔鐨勬搷浣滅郴缁熲銆傚鏋滀綘鍒涘缓浜嗕竴涓柊鐨凪ySQL绉绘锛堢Щ妞嶅埌鍒楄〃涓婃病鏈夌殑鎿嶄綔绯荤粺锛夛紝璇烽氱煡鎴戜滑锛屼互渚挎垜浠兘鎶婅繖涓搷浣滅郴缁熷垪鍒版垜浠綉绔欎笂锛http://www.mysql.com/锛夛紝鎺ㄨ崘缁欏叾瀹冪殑鐢ㄦ埛銆
娉ㄦ剰锛氬鏋滀綘鍒涘缓涓涓柊鐨凪ySQL绉绘锛屼綘鍙互鍦℅PL璁稿彲璇佷笅浠绘剰澶嶅埗鍜屽彂甯冨畠锛屼絾杩欎笉鑳戒娇浣犳垚涓篗ySQL鐨勭増鏉冩寔鏈夎呫
杩欎釜鏈嶅姟鍣ㄩ渶瑕佷竴涓鍦ㄥ伐浣滅殑POSIX 绾跨▼搴撳湪銆傚湪Solaris 2.5 涓婃垜浠娇鐢⊿un PThreads 锛堝湪2.4鐗堝拰鏇存棭鐨勭増鏈笂锛屽師鐢熺嚎绋嬫敮鎸佸緱涓嶆槸寰堝ソ锛夛紝鍦↙inux涓婏紝鎴戜滑浣跨敤Xavier Leroy<Xavier.Leroy@inria.fr>鐨凩inuxThreads銆
瀵逛簬閭d簺瀵瑰師鐢熺嚎绋嬫敮鎸佷笉濂界殑鏂癠nix鍙樹綋锛岀Щ妞嶅埌鍏朵笂鐨勮壈闅鹃儴鍒嗗ぇ姒傚氨鏄Щ妞峂IT-pthreads鍖呫傝鍙傞槄mit-pthreads/README 鍜孭rogramming POSIX Threads (http://www.humanfactor.com/pthreads/)銆
鐩村埌MySQL 4.0.2鐗堬紝MySQL鍙戝竷鍖呭寘鎷潵鑷狹IT缁忚繃琛ヤ竵鐨凜hris Provenzano鐨凱threads锛堣鍙傞槄MIT Pthreads 缃戦〉http://www.mit.edu/afs/sipb/project/pthreads/ 浠ュ強http://www.mit.edu:8001/people/proven/IAP_2000/涓婄殑缂栫▼鎸囧锛夈傚浜庢煇浜涙病鏈塒OSIX绾跨▼鐨勬搷浣滅郴缁熷彲鑳芥湁鐢ㄣ傝鍙傞槄2.8.5鑺傦紝鈥淢IT-pthreads 娉ㄦ剰浜嬮」鈥銆
涔熷彲鑳戒細鐢ㄥ埌鍙︿竴涓悕涓 FSU Pthreads鐨勭敤鎴风骇绾跨▼杞欢鍖咃紙璇峰弬闃http://moss.csc.ncsu.edu/~mueller/pthreads/锛夈 杩欎釜宸ュ叿琚敤鏉ュ埌SCO鐨勭Щ妞嶃
鍙傞槄 mysys鐩綍涓嬬殑thr_lock.c 鍜宼hr_alarm.c 绋嬪簭鑾峰彇涓浜涘叧浜庤繖浜涢棶棰樼殑娴嬭瘯/渚嬪瓙銆
鏈嶅姟鍣ㄥ拰瀹㈡埛绔渶瑕佷竴涓兘鐢ㄧ殑C++缂栬瘧鍣ㄣ傛垜浠湪寰堝骞冲彴涓婁娇鐢gcc銆傚叾瀹冪紪璇戝櫒锛屾嵁浜嗚В锛屽彲鐢ㄧ殑缂栬瘧鍣ㄦ槸SPARCworks, Sun Forte, Irix cc, HP-UX aCC, IBM AIX xlC_r), Intel ecc/icc 鍜 Compaq cxx)銆
瑕佷粎缂栬瘧瀹㈡埛绔紝璇蜂娇鐢./configure --without-server.
鐜板湪涓嶆敮鎸佷粎缂栬瘧鏈嶅姟鍣紝涔熶笉鑳藉姞杩欎釜鍔熻兘锛岄櫎闈炴湁浜烘壘鍑轰竴涓ソ鐨勭悊鐢便
濡傛灉浣犳兂/闇瑕佹敼鍙樹换浣昅akefile 鎴栭厤缃剼鏈紝浣犱篃浼氶渶瑕佸埌GNU Automake 鍜 Autoconf銆傝鍙傞槄2.8.3鑺 锛屸滀粠寮鍙戞簮鏍戝畨瑁呪銆
鎵鏈夋楠ら渶瑕佷粠鏈鍩烘湰鐨勬枃浠堕噸鏂扮敓鎴愶紙remake锛夋墍鏈変笢瑗裤
/bin/rm */.deps/*.P /bin/rm -f config.cache aclocal autoheader aclocal automake autoconf ./configure --with-debug=full --prefix='your installation directory' # The makefiles generated above need GNU make 3.75 or newer. # (called gmake below) gmake clean all install init-db
濡傛灉鍦ㄦ柊绉绘MySQL涓婇亣鍒伴棶棰橈紝鏈濂藉仛涓浜涜皟璇曪紒璇峰弬闃E.1鑺傦紝鈥滆皟璇昅ySQL鏈嶅姟鍣ㄢ銆
娉ㄦ剰锛氬湪浣犲紑濮嬭皟璇mysqld涔嬪墠锛岄鍏堣璁╂祴璇曠▼搴mysys/thr_alarm鍜mysys/thr_lock宸ヤ綔銆傝繖浼氱‘淇濅綘鐨勭嚎绋嬪畨瑁呭彧鏈夐潪甯稿皬鐨勬満浼氳兘杩愯锛
濡傛灉浣犱娇鐢∕ySQL鏌愪簺闈炲父鏂扮殑鍔熻兘锛屼綘鍙互甯--skip-new鍙傛暟锛堣繖涓夐」绂佹鎺夋墍鏈夋柊鐨勬綔鍦ㄤ笉瀹夊叏鐨勫姛鑳斤級鎴栧甫 --safe-mode鍙傛暟锛堝畠绂佹鎺夊緢澶氬彲鑳藉鑷撮棶棰樼殑浼樺寲璁剧疆锛夋潵杩愯mysqld銆 璇峰弬闃A.4.2鑺傦紝鈥滃鏋淢ySQL渚濇棫宕╂簝锛屽簲璇ュ仛浠涔堚銆
濡傛灉 mysqld 涓嶅惎鍔紝浣犲簲璇ユ煡璇佹湁娌℃湁骞叉壈浣犵殑璁剧疆鐨刴y.cnf鏂囦欢銆備綘鍙互鐢mysqld --print-defaults...妫鏌y.cnf鍙傞噺锛屽苟鐢mysqld --no-defaults鏉ュ惎鍔ㄥ幓閬垮厤瀹冧滑銆
濡傛灉mysqld 鍚姩鑰楀敖CPU鎴栧唴瀛樿祫婧愶紝鎴栬呭畠鈥滄寕鈥濅簡璧锋潵锛屼綘鍙互浣跨敤 mysqladmin processlist status鍘绘壘鍑烘槸鍚︽湁浜烘墽琛屼簡涓涓崰鐢ㄥ緢闀挎椂闂寸殑鏌ヨ銆傚鏋滀綘姝i潰涓寸潃鎬ц兘闂鎴栨柊瀹㈡埛绔笉鑳借繛 涔嬫椂鐨勯棶棰橈紝鍦ㄦ煇浜涚獥鍙d腑杩愯mysqladmin -i10 processlist status鍙兘鏄涓涓ソ涓绘剰銆
mysqladmin debug 鍛戒护鎶婁竴浜涙湁鍏充娇鐢ㄤ腑鐨勯攣锛屼娇鐢ㄧ殑鍐呭瓨浠ュ強鏌ヨ浣跨敤鐨勪俊鎭浆鍌ㄥ埌MySQL鏃ュ織鏂囦欢閲屻傝繖灏嗘湁鍔╀簬瑙e喅涓浜涢棶棰樸傚嵆浣夸綘娌℃湁涓鸿皟璇曠紪璇慚ySQL锛岃繖涓懡浠や篃鎻愪緵涓浜涙湁鐢ㄧ殑淇℃伅锛
濡傛灉闂鏄竴浜涜〃鍙樺緱瓒婃潵瓒婃參锛屼綘搴旇璇曠潃鐢≒TIMIZE TABLE鎴myisamchk浼樺寲琛ㄣ侷璇峰弬闃呯5绔狅細鏁版嵁搴撶鐞銆備綘涔熷彲浠ョ敤EXPLAIN妫鏌ユ參 鐨勬煡璇€
瀵归偅浜涗簬浣犵殑鐜鏄嫭鐗圭殑闂锛屼綘涔熷簲璇ユ煡闃呰繖涓墜鍐岄噷OS瑙勬牸鐨勯儴鍒嗚鍙傞槄聽2.12鑺傦紝鈥滄搷浣滅郴缁熺郴缁熺殑娉ㄦ剰浜嬮」鈥銆
濡傛灉浣犻亣鍒颁竴浜涢潪甯告槑纭殑闂锛屼綘鍙互鎬绘槸璇曠潃璋冭瘯MySQL銆傝璋冭瘯MySQL锛屼綘蹇呴』鐢--with-debug鎴--with-debug=full閫夐」鏉ラ厤缃甅ySQL銆備綘鍙互妫鏌ySQL鏄惁鏄氳繃mysqld --help鏉ュ拰璋冭瘯涓璧风紪璇戠殑銆傚鏋--debug鏍囪鍜岄夐」涓璧疯鍒楀嚭浜嗭紝浣犲氨鍙互璋冭瘯浜嗐傚湪杩欑鎯呭喌mysqladmin ver涓嬫妸mysqld鐗堟湰鍒楁垚mysql ... --debug銆
濡傛灉浣犱娇鐢gcc 鎴 egcs锛屾帹鑽愮殑configure 琛屽涓嬶細
CC=gcc CFLAGS="-O2" CXX=gcc CXXFLAGS="-O2 -felide-constructors \ -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql \ --with-debug --with-extra-charsets=complex
杩欓伩鍏嶄簡libstdc++搴撳拰C++寮傚父锛堝緢澶氱紪璇戝櫒鍦ㄧ嚎绋嬩唬鐮侀噷鏈塁++寮傚父鐨勯棶棰橈級鐨勯棶棰橈紝骞剁紪璇戜簡涓涓敮鎸佹墍鏈夊瓧绗﹂泦鐨凪ySQL鐗堟湰銆
濡傛灉浣犳鐤戝唴瀛樻孩鍑洪敊璇紝浣犲彲浠ョ敤--with-debug=full鏉ラ厤缃甅ySQL锛岃繖浼氬畨瑁呬竴涓唴瀛樺垎閰嶏紙SAFEMALLOC锛夋鏌ュ櫒銆傚彲鏄紝杩愯SAFEMALLOC鏄潪甯告參鐨勶紝鎵浠ュ鏋滀綘閬囧埌鎬ц兘涓婄殑闂锛屼綘搴旇 鐢--skip-safemalloc閫夐」鍚姩mysqld銆傝繖鏍风姝㈡帀瀵硅皟鐢╩alloc()鍜宖ree()鐨勫唴瀛樻鏌ャ
褰撲綘鐢--with-debug缂栬瘧mysqld鏃讹紝濡傛灉瀹冧笉鍐嶅穿婧冿紝浣犲ぇ鑷村凡缁忓湪MySQL鍐呮壘鍒颁竴涓紪璇戝櫒缂洪櫡鎴栬鏃剁己闄枫傝繖绉嶆儏鍐典笅锛屼綘鍙互璇曠潃鎶-g鍔犲埌涓婇潰鐨CFLAGS鍜CXXFLAGS鍙橀噺锛屽苟涓斾笉浣跨敤--with-debug銆傚鏋mysqld澶辫触锛屼綘鑷冲皯鍙互gdb鐢ㄩ檮鐫涓婂畠鎴栦娇鐢ㄦ牳蹇冩枃浠朵笂鐨gdb鍘绘壘鍑哄彂鐢熶粈涔堥棶棰樸
褰撲綘涓鸿皟璇曢厤缃甅ySQL鏃讹紝浣犲氨鑷姩鍏佽璁稿棰濆鐨勭洃瑙mysqld鍋ュ悍鐨勫畨鍏ㄦ鏌ュ嚱鏁般傚鏋滃畠浠彂鐜颁竴浜涒滀笉鏈熸湜鈥濈殑浜嬶紝浼氬啓涓涓潯鐩埌stderr锛safe_mysqld锛鎸囧紩杩欎釜stderr鍒伴敊璇棩蹇楋紒杩欎篃鎰忓懗鐫濡傛灉MySQL鍙戠敓浠涔堟剰澶栫殑闂锛屽苟涓斾綘姝d娇鐢ㄤ竴涓簮鏂囦欢鍙戝竷鐗堟湰锛岄偅涔堜綘瑕佸仛鐨勭涓浠朵簨灏辨槸鍘讳负璋冭瘯閰嶇疆MySQL锛侊紙绗簩浠朵簨鏄彂閭欢鍒癕ySQL閭欢鍒楄〃璇锋眰甯姪锛夈傝鍙傞槄1.7.1.1鑺傦紝鈥淢ySQL閭欢鍒楄〃鈥銆傝鏍规嵁浣犱娇鐢ㄧ殑MySQL鐗堟湰瀵规墍鏈夌己闄锋姤鍛婃垨闂浣跨敤mysqlbug鑴氭湰锛
鍦╓indows MySQL鍙戝竷鍖呴噷锛宮ysqld.exe榛樿缂栬瘧涓烘敮鎸佽拷韪枃浠躲
濡傛灉mysqld 鏈嶅姟鍣ㄦ病鏈夊惎鍔ㄦ垨鑰呬綘鍙互蹇熷湴浣垮叾宕╂簝锛屼綘鍙互鍒涘缓涓涓窡韪枃浠舵潵鎵惧嚭闂銆
瑕佽繖涔堝仛鐨勮瘽锛屼綘蹇呴』鏈変竴涓紪璇戜簡鏀寔璋冭瘯鐨mysqld锛 浣犲彲浠ラ氳繃鎵цmysqld -V鏉ユ鏌ヤ竴涓嬨傚鏋滅増鏈彿鍚庨潰璺熺潃-debug锛屽畠灏辨槸琚紪璇戞垚鏀寔璺熻釜鏂囦欢銆傦紙鍦 Windows涓紝璋冭瘯鏈嶅姟鍣ㄨ鍛藉悕涓mysqld-debug 鑰屼笉鏄薄MySQL 4.1 閭f牱鐨mysqld 锛夈
濡備笅鍛戒护锛屽惎鍔ㄥ甫璺熻釜鏂囦欢鐨 mysqld 鏈嶅姟鍣紝璺熻釜鏂囦欢浣嶄簬Unix涓婄殑/tmp/mysqld.trace鐩綍閲岋紝Windows涓 鐨凜:\mysqld.trace鐩綍閲岋細
shell> mysqld --debug
鍦╓indows涓婏紝浣犱篃鍙互浣跨敤--standalone鍙傛暟锛屽惎鍔mysqld璁╁畠涓浣滀负鏈嶅姟銆傚湪鎺у埗鍙扮獥鍙o紝浣跨敤杩欎釜鍛戒护锛
C:\> mysqld-debug --debug --standalone
瀹屾瘯涔嬪悗锛屼綘鍙互浣跨敤绗簩涓獥鍙d腑鐨 mysql.exe 鍛戒护琛屽伐鍏烽噸鏂板埗閫犻棶棰樸備綘鍙互鐢mysqladmin shutdown鍛戒护鍋滄mysqld鏈嶅姟鍣ㄣ
娉ㄦ剰锛岃窡韪枃浠朵細鍙樺緱寰堝ぇ锛佸鏋滀綘鎯崇敓鎴愪竴涓皬涓鐐圭殑璺熻釜鏂囦欢锛屼綘鍙互浣跨敤绫讳技杩欐牱鐨勮皟鍒堕夐」锛
mysqld --debug=d,info,error,query,general,where:O,/tmp/mysqld.trace
杩欐牱灏变粎鎶婂甫鏈鎰熷叴瓒f爣璁扮殑淇℃伅鍐欒繘璺熻釜鏂囦欢閲.
濡傛灉浣犵敓鎴愪竴涓湁鍏充簬姝ょ殑缂洪櫡鎶ュ憡锛岃鍙敤鎶婅窡韪枃浠朵腑鐨勭浉鍏宠鍙戦佸埌鎭板綋鐨勯偖浠跺垪琛ㄥ幓锛岄偅閲屽叧娉ㄤ綘鎶ュ憡鍑洪棶棰樼殑閮ㄥ垎銆傚鏋滀綘涓嶈兘鎵惧嚭鍝噷鍑洪棶棰橈紝浣犲彲浠tp涓婅浇鏁翠釜璺熻釜鏂囦欢鍒ftp://ftp.mysql.com/pub/mysql/upload/锛屽苟闄勬湁瀹屽叏鐨勭己闄锋姤鍛婏紝MySQL寮鍙戜汉鍛樹細鐪嬪埌瀹冪殑銆
杩借釜鏂囦欢鏄敱Fred Fish鐢DBUG杞欢鍖呯敓鎴愮殑锛岃鍙傞槄E.3鑺傦紝鈥淒BUG杞欢鍖呪銆
濡傛灉mysqld宕╂簝浜嗭紝鍦ㄥぇ澶氭暟绯荤粺涓婏紝浣犱篃鍙槸浠gdb鍚姩mysqld鏉ヨ幏鍙栨洿澶氫俊鎭
Linux涓婏紝鏈変竴浜涜佺増鏈殑gdb锛屽鏋滀綘鎯宠鑳借皟璇mysqld绾跨▼锛屼綘蹇呴』浣跨敤run --one-threadsome銆傚湪杩欑鎯呭喌涓嬶紝浣犲彲浠ヤ竴娆″彧婵娲讳竴涓嚎绋嬨傛垜浠帹鑽愪綘鍗囩骇鍒癵db 5.1 ASAP 锛岃繖涓増鏈笂绾跨▼璋冭瘯宸ヤ綔寰楁洿濂斤紒
NTPL 绾跨▼锛圠inux涓婄殑鏂扮嚎绋嬪簱锛夊彲鑳戒細鍦gdb涓嬭繍琛mysqld鏃堕亣鍒伴棶棰樸備竴浜涚棁鐘跺涓嬶細
mysqld 鍦ㄥ惎鍔ㄨ繃绋嬩腑鎸傝捣锛堝湪瀹冨啓ready for connections涔嬪墠锛夈
mysqld 鍦ㄨ皟鐢╬thread_mutex_lock()鎴杙thread_mutex_unlock()杩囩▼涓穿婧冦
鍦ㄨ繖绉嶆儏鍐典笅浣犲簲璇ュ湪鍚姩gdb涔嬪墠鍦ㄥ澹充笂璁剧疆濡備笅鐜鍙橀噺锛
LD_ASSUME_KERNEL=2.4.1 export LD_ASSUME_KERNEL
鍦gdb涓嬭繍琛mysqld鏃讹紝浣犲簲璇ョ敤--skip-stack-trace鏉ョ姝㈠爢鏍堣窡韪紝浠ヤ究鑳芥崟鑾gdb鍐呯殑娈甸敊璇
鍦∕ySQL 4.0.14鍜屼互涓婄増鏈紝浣犲簲璇ュmysqld浣跨敤--gdb閫夐」銆 杩欎細涓篠IGINT瀹夎涓涓腑鏂鐞嗗櫒锛堥渶瑕佺敤^C鍋滄mysqld鏉ヨ缃柇鐐癸級锛屽苟涓旂姝㈠爢鏍堣窡韪拰鏍稿績鏂囦欢澶勭悊銆
褰gdb娌℃湁缁欐棫绾跨▼閲婃斁鍐呭瓨鐨勬暣涓椂闂撮噷锛屽鏋滀綘鍋氫簡澶ч噺鐨勬柊杩炴帴锛屽湪gdb涓嬭皟璇昅ySQL鏄潪甯稿洶闅剧殑銆備綘鍙互閫氳繃甯 -O thread_cache_size= 'max_connections +1' 鍚姩mysqld 鏉ラ伩鍏嶈繖涓棶棰樸傚湪澶氭暟鎯呭喌涓嬶紝鍙娇鐢-O thread_cache_size=5'灏卞彈鐩婃棤绌蜂簡锛
濡傛灉mysqld甯︾潃SIGSEGV淇″彿姝绘帀浜嗭紝鑰屼綘鎯冲湪Linux涓婅浆鍌ㄦ牳蹇冿紝浣犲彲浠ュ甫--core-file閫夐」鍚姩mysqld銆傝繖涓牳蹇冩枃浠跺彲浠ヨ鐢ㄦ潵鐢熸垚 鍚戝悗璺熻釜锛屽畠鍙互甯綘鎵惧嚭mysqld 涓轰綍姝绘帀锛
shell> gdb mysqld core gdb> backtrace full gdb> exit
璇峰弬闃A.4.2鑺傦紝鈥滃鏋淢ySQL渚濇棫宕╂簝锛岃濡備綍鍘诲仛鈥銆
濡傛灉浣犲湪Linux涓婁娇鐢gdb 4.17.x 鎴栦互涓婄増鏈紝浣犲簲璇ュ畨瑁呬竴涓甫鏈夊涓嬩俊鎭殑 .gdb 鏂囦欢鍒颁綘褰撳墠鐩綍锛
set print sevenbit off handle SIGUSR1 nostop noprint handle SIGUSR2 nostop noprint handle SIGWAITING nostop noprint handle SIGLWP nostop noprint handle SIGPIPE nostop handle SIGALRM nostop handle SIGHUP nostop handle SIGTERM nostop noprint
濡傛灉浣犵敤gdb璋冭瘯绾跨▼閬囧埌闂锛屼綘搴旇涓嬭浇gdb 5.x鐗堟湰骞剁敤瀹冭瘯涓涓嬭皟璇曘傛柊鐗堟湰鐨 gdb 澶уぇ鏀瑰杽浜嗙嚎绋嬪鐞嗭紒
涓嬮潰鏄浣曡皟璇昺ysqld鐨勪緥瀛愶細
shell> gdb /usr/local/libexec/mysqld gdb> run ... backtrace full # Do this when mysqld crashes
鎶婁笂闈㈢殑杈撳叆鍐欒繘涓涓敤mysqlbug鐢熸垚鐨勯偖浠堕噷锛屽彂閫佸埌缁煎悎MySQL閭欢鍒楄〃銆傝鍙傞槄1.7.1.1鑺傦紝鈥淢ySQL 閭欢鍒楄〃鈥銆
濡傛灉mysqld 鎸傝捣锛屼綘鍙互璇曠潃鐢ㄤ竴浜涜濡俿trace 鎴 /usr/proc/bin/pstack 杩欐牱鐨勭郴缁熷伐鍏疯繛妫鏌mysqld 鍦ㄥ摢閲屾寕璧枫
strace /tmp/log libexec/mysqld
濡傛灉浣犱娇鐢 Perl DBI 鎺ュ彛锛屼綘鍙互浣跨敤trace鏂规硶鎴栬缃瓺BI_TRACE鐜鍙橀噺鏉ユ墦寮璋冭瘯淇℃伅銆
鍦ㄤ竴浜涙搷浣滅郴缁熶笂锛屽鏋mysqld鎰忓姝绘帀锛岄敊璇棩蹇楀寘鍚竴涓爢鏍堣窡韪備綘鍙互鐢ㄥ畠鏉ユ壘鍑mysqld 鍦ㄥ摢閲岋紙涔熻鍙兘鎵惧嚭涓轰粈涔堬級姝绘帀銆傝鍙傞槄5.11.1鑺傦紝鈥滈敊璇棩蹇椻銆傝鑾峰緱鍫嗘爤璺熻釜锛屼綘涓嶈兘鐢-fomit-frame-pointer 閫夐」缂栬瘧mysqld 涓篻cc銆 璇峰弬闃E.1.1鑺傦紝鈥滈拡瀵硅皟璇曠紪璇慚ySQL鈥銆
濡傛灉閿欒鏂囦欢鍖呭惈绫讳技涓嬮潰鐨勪竴浜涘唴瀹癸細
mysqld got signal 11; The manual section 'Debugging a MySQL server' tells you how to use a stack trace and/or the core file to produce a readable backtrace that may help in finding out why mysqld died Attempting backtrace. You can use the following information to find out where mysqld died. If you see no messages after this, something went terribly wrong... stack range sanity check, ok, backtrace follows 0x40077552 0x81281a0 0x8128f47 0x8127be0 0x8127995 0x8104947 0x80ff28f 0x810131b 0x80ee4bc 0x80c3c91 0x80c6b43 0x80c1fd9 0x80c1686
浣犲彲浠ヤ娇鐢ㄥ涓嬫楠ゆ壘鍑mysqld鍦ㄤ粈涔堝湴鏂瑰嚭鐜伴棶棰橈細
澶嶅埗鍓嶉潰鐨勬暟瀛楀埌涓涓枃浠讹紝濡俶ysqld.stack銆
涓 mysqld 鏈嶅姟鍣ㄧ敓鎴愮鍙锋枃浠讹細
nm -n libexec/mysqld > /tmp/mysqld.sym
娉ㄦ剰锛屽鏁癕ySQL浜岃繘鍒跺彂甯冨寘锛"debug" 杞欢鍖咃紝鍖呭惈杩欎簺淇℃伅鐨勫湴鏂瑰氨鍦ㄤ簩杩涘埗鍙戝竷鍖呮湰韬箣鍐咃級甯︿笂杩版枃浠讹紝鍦ㄥ叾涓繖浜涙枃浠跺悕涓簃ysqld.sym.gz銆傚湪杩欑鎯呭喌涓嬶紝浣犲彲浠ョ畝鍗曞湴瑙e帇缂╁畠锛
gunzip < bin/mysqld.sym.gz > /tmp/mysqld.sym
鎵ц resolve_stack_dump -s /tmp/mysqld.sym -n mysqld.stack.
杩欎釜鍛戒护浼氭墦鍗板嚭mysqld姝诲湪鍝噷銆傚鏋滆繖涓笉鑳藉府浣犳壘鍑mysqld涓轰粈涔堟鎺夛紝浣犲簲璇ョ敓鎴愪竴涓己闄锋姤鍛婏紝骞跺湪缂洪櫡鎶ュ憡閲屽寘鍚笂杩板懡浠ょ殑杈撳嚭缁撴灉銆
娉ㄦ剰锛屽敖绠″湪澶氭暟鎯呭喌涓嬶紝浠呮湁涓涓爢鏍堣窡韪笉鑳藉府鍔╂垜浠壘鍑洪棶棰樼殑鍘熷洜銆備负浜嗗畾浣嶇己闄锋垨鎵惧埌涓涓ぇ鑷磋寖鍥达紝鎴戜滑鍦ㄥぇ澶氭暟鎯呭喌涓嬮渶瑕佺煡閬撴潃鎺mysqld鐨勬煡璇紝骞舵渶濂界煡閬撲竴涓祴璇曟渚 锛屼互渚挎垜浠兘閲嶅闂锛佽鍙傞槄1.7.1.3鑺傦紝鈥滃浣曟姤鍛婄己闄峰拰闂鈥銆
娉ㄦ剰锛屽湪甯--log閫夐」鍚姩 mysqld涔嬪墠锛屼綘搴旇鐢myisamchk妫鏌ユ墍鏈夌殑琛ㄣ傝鍙傞槄绗5绔狅細鏁版嵁搴撶鐞.
濡傛灉 mysqld 姝讳簡鎴栨寕璧凤紝浣犲簲璇ョ敤--log鍚姩 mysqld 銆傚綋mysqld 鍐嶆姝绘帀鏃讹紝浣犲彲浠ユ鏌ユ棩蹇楁枃浠剁殑鏈鍚庯紝鎵惧嚭鏉鎺mysqld鐨勬煡璇€
濡傛灉浣犱笉甯︽枃浠跺悕浣跨敤 --log 锛屾棩蹇楄淇濆瓨鍦鍚嶄负host_name.log鐨勬暟鎹簱鐩綍閲屻傚湪澶氭暟鎯呭喌涓嬶紝鏃ュ織鏂囦欢涓殑鏈鍚庝竴涓煡璇㈡潃鎺mysqld锛屼絾濡傛灉鏈夊彲鑳斤紝浣犲簲璇ラ噸鍚mysqld骞朵粠mysq鍛戒护琛屽伐鍏锋墽琛屾壘鍒扮殑鏌ヨ鏉ラ獙璇佷竴涓嬨傚鏋滆繖涓煡璇㈡潃鎺浜唌ysqld锛屼綘涔熷簲璇ユ祴璇曟墍鏈夋病鏈夊畬鎴愮殑澶嶆潅鏌ヨ銆
浣犱篃鍙互鍦ㄦ墍鏈夊崰鐢ㄩ暱鏃堕棿鐨凷ELECT澹版槑涓婄敤鍛戒护EXPLAIN鏉ョ‘璁 mysqld姝i傚綋鍦颁娇鐢ㄧ储寮曘傝鍙傞槄7.2.1鑺傦紝鈥淓XPLAIN 璇硶锛堣幏寰楀叧浜嶴ELECT鐨勪俊鎭锛夆銆
浣犲彲浠ュ甫 --log-slow-queries鍚姩mysqld鏉ユ壘鍑哄崰鐢ㄩ暱鏃堕棿鏉ユ墽琛岀殑鏌ヨ銆傝鍙傞槄5.11.4鑺 锛屸滅紦鎱㈡煡璇㈡棩蹇椻銆
濡傛灉浣犲湪閿欒鏃ュ織鏂囦欢锛堥氬父鍚嶄负hostname.err锛変腑鍙戠幇 mysqld restarted 瀛楁牱锛屼綘澶ц嚧宸茬粡鎵惧埌瀵艰嚧mysqld鐨勬煡璇€傚鏋滃彂鐢熻繖绉嶆儏鍐碉紝浣犲簲璇ョ敤myisamchk妫鏌ユ墍鏈夎〃锛堝弬闃 绗5绔狅細鏁版嵁搴撶鐞锛夛紝骞跺湪MySQL鏃ュ織鏂囦欢涓祴璇曡繖浜涙煡璇㈢湅鏄惁鏈変笉鎵ц鐨勩傚鏋滄壘鍒拌繖鏍蜂竴涓煡璇紝璇曠潃鍗囩骇鍒版渶鏂扮殑MySQL鐗堟湰銆傚鏋滆繖鏍蜂笉鑳藉府鍔╀綘锛屼綘涓嶈兘鍦╩ysql閭欢瀛樻。涓彂鐜颁换浣曠浉鍏冲唴瀹癸紝浣犲簲璇ユ妸缂洪櫡鎶ュ憡缁橫ySQL閭欢鍒楄〃銆傞偖浠跺垪琛ㄥ湪http://lists.mysql.com/璁㈤槄锛岃繖涓湴鍧涓婁篃鏈夎繛鍒板湪绾垮垪琛ㄥ瓨妗g殑閾炬帴銆
濡傛灉浣犲凡缁忕敤myisam-recover鍚姩浜mysqld锛孧ySQL鑷姩妫鏌ュ苟璇曠潃淇MyISAM 琛紝鐪嬫槸鍚﹀畠浠鏍囧織涓衡滄湭姝e父鍏抽棴鈥濇垨鈥滃穿婧冣濄傚鏋滃彂鐢熻繖绉嶆儏鍐碉紝MySQL鍦ㄦ枃浠秇ostname.err 鍐欎竴涓潯鐩'Warning: Checking table ...'锛屽悗闈㈣窡鐫璀﹀憡锛氬鏋滆〃闇瑕佷慨澶嶏紝璇蜂慨澶嶅畠銆傚鏋滀綘閬囦笂澶ч噺鐨勮繖浜涢敊璇mysqld娌℃湁鎰忓姝绘帀锛岄偅灏辨槸鏈夐棶棰樹簡锛岄渶瑕佽繘涓姝ヨ皟鏌ャ傝鍙傞槄5.3.1鑺傦紝鈥mysqld鍛戒护琛岄夐」鈥銆
濡傛灉mysqld鎰忓姝绘帀锛岃繖鍙笉鏄竴涓ソ鍏嗗ご锛屼絾鍦ㄨ繖绉嶆儏鍐典笅涓嶇敤鐮旂┒Checking table...淇℃伅锛岃屾槸瑕佹壘鍑mysqld涓轰粈涔堟鎺夈
濡傛灉鍦ㄤ竴浜涙洿鏂板懡浠や箣鍚庯紝mysqld鎬绘槸褰撴帀锛屾垨鑰呭鏋滀綘閬囧埌琚牬鍧忕殑琛紝浣犲彲浠ョ敤涓嬮潰鐨勬搷浣滄祴璇曠湅杩欎釜缂洪櫡鏄惁鏄彲閲嶅浜х敓鐨勶細
鍗告帀MySQL瀹堟姢杩涚▼锛堢敤mysqladmin shutdown锛夈
缁欒琛ㄥ仛澶囦唤锛堥槻姝慨澶嶆搷浣滃弽鑰屾悶鍧忚繖绉嶅緢涓嶅彲鑳藉嚭鐜扮殑鎯呭喌锛夈
鐢 myisamchk -s database/*.MYI 妫鏌ユ墍鏈夌殑琛紝鐢myisamchk -r database/table.MYI淇悊鏈夐敊璇殑琛ㄣ
瀵硅琛ㄥ仛绗簩娆″浠姐
濡傛灉闇瑕佹洿澶氱殑绌洪棿灏变粠MySQL鏁版嵁搴撶洰褰曞垹闄わ紙鎴栫Щ璧帮級鏃ф棩蹇楁枃浠躲
甯--log-bin鍚姩Start mysqld 銆傝鍙傞槄5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆傚鏋滀綘鎯虫壘鍑烘悶鍨mysqld鐨勬煡璇紝浣犲簲璇ヤ娇鐢╱se --log --log-bin銆
褰撲綘宸茬粡閬亣涓涓鐮村潖鐨勮〃鏃讹紝璇峰仠姝ysqld server 銆
杩樺師澶囦唤銆
涓嶅甫--log-bin閲嶅惎鍔mysqld 鏈嶅姟鍣ㄣ
閲嶆柊鎵цmysqlbinlog update-log-file | mysql鍛戒护銆傛洿鏂扮殑鏃ュ織鐢ㄥ悕瀛梙ostname-bin.#淇濆瓨鍦∕ySQL鏁版嵁搴撶洰褰曚笅銆
濡傛灉璇ヨ〃鍐嶆琚牬鍧忥紝鎴栬呬綘鍙敤涓婅瘔鍛戒护璁mysqld 姝绘帀锛屼綘灏卞凡缁忔壘鍒板彲閲嶅浜х敓鐨勭己闄凤紝瀹冨簲璇ュ緢瀹规槗琚慨澶嶏紒鍙互ftp涓婁紶琛ㄥ拰浜岃繘鍒舵棩蹇楀埌 ftp://ftp.mysql.com/pub/mysql/upload/ 鐒跺悗鎶婂畠杈撳叆鎴戜滑鍦 http://bugs.mysql.com/涓婄殑缂洪櫡绯荤粺銆傦紙璇锋敞鎰忥紝/pub/mysql/upload/ 鍦‵TP鏃舵槸涓嶅彲浠ュ垪鍑猴紙鍐呭锛夌殑锛屾墍浠ヤ笉鑳藉湪FTP瀹㈡埛绔湅瑙佷綘宸茬粡涓婅浇鐨勪笢瑗裤傦級濡傛灉浣犳槸涓涓敮鎸佸鎴凤紝浣犲彲浠ヤ娇鐢 MySQL瀹㈡埛鏀寔涓績https://support.mysql.com/ 鏉 鎻愰啋MySQL 鎶鏈汉鍛樿繖涓棶棰橈紝璁╄繖涓棶棰樺敖蹇緱鍒拌В鍐炽
濡傛灉浣犳兂缂╁皬闂鐨勮寖鍥达紝浣犱篃鍙互浣跨敤 mysql_find_rows鑴氭湰鏉ュ彧鎵ц涓浜 鏇存柊璇彞銆
涓鸿兘澶熺敤闆嗘垚鐨勮皟璇曡蒋浠跺寘璋冭瘯MySQL瀹㈡埛绔 锛屼綘搴旇鐢--with-debug鎴--with-debug=full閰嶇疆MySQL銆傝鍙傞槄2.8.2鑺傦紝鈥滃吀鍨嬬殑閰嶇疆閫夐」鈥銆
鍦ㄨ繍琛屽鎴风涔嬪墠锛屼綘搴旇璁剧疆 MYSQL_DEBUG鐜鍙橀噺锛
shell> MYSQL_DEBUG=d:t:O,/tmp/client.trace shell> export MYSQL_DEBUG
杩欎細瀵艰嚧瀹㈡埛绔湪 /tmp/client.trace鐩綍浜х敓涓涓窡韪枃浠躲
濡傛灉浣犺嚜宸辩殑瀹㈡埛绔唬鐮佹湁闂锛屼綘搴旇璇曠潃杩炴帴鍒版湇鍔″櫒锛岀敤宸茬煡鍙敤鐨勫鎴风杩愯浣犵殑鏌ヨ銆傚湪璋冭瘯妯″紡涓嬶紝鎸変笅闈㈠懡浠よ繍琛岋紙鍋囪浣犲凡缁忓甫璋冭瘯缂栬瘧浜哅ySQL锛夛細
shell> mysql --debug=d:t:O,/tmp/client.trace
涓囦竴浣犺鍙戦佷竴涓己闄锋姤鍛婇偖浠讹紝杩欎細鎻愪緵缁欎綘鏈夌敤鐨勪俊鎭傝鏌ラ槄鈥滃浣曟姤鍛婄己闄锋垨闂鈥銆
濡傛灉浣犵殑瀹㈡埛绔湪涓浜涚湅璧锋潵鍚堟硶鐨勪唬鐮佸宕╂簝浜嗭紝浣犲簲璇ユ鏌ヤ綘鐨刴ysql.h鏂囦欢鏄惁鍖呮嫭鍖归厤浣犵殑MySQL搴撴枃浠躲備竴涓父瑙佺殑閿欒灏辨槸鐢ㄦ柊鐨勭増鏈殑MySQL搴撲娇鐢ㄤ竴涓潵鑷佺増鏈畨瑁呯殑mysql.h鏂囦欢銆
MySQL鏈嶅姟鍣ㄥ拰澶氭暟MySQL瀹㈡埛绔兘甯︾潃鐢盕red Fish鍒濆垱鐨凞BUG 杞欢鍖呯紪璇戞垚鐨勩傚綋浣犱负璋冭瘯閰嶇疆MytSQL涔嬫椂锛岃繖涓蒋浠朵娇浣犲彲浠ュ緱鍒颁竴涓▼搴忔鍦ㄨ皟璇曚粈涔堢殑璺熻釜鏂囦欢銆傝鍙傞槄E.1.2鑺傦紝鈥滃垱寤鸿窡韪枃浠垛銆
杩欎竴鑺傛荤粨浜嗕綘瀵瑰凡寤虹珛鏀寔璋冭瘯鐨凪ySQL绋嬪簭鍦ㄥ懡浠よ鐨勮皟璇曢夐」澶勫彲浠ユ寚瀹氱殑鍙傞噺鍊笺傝鑾峰彇鏇村浣跨敤DBUG杞欢鍖呮潵缂栫▼鐨勪俊鎭紝璇峰弬闃匨ySQL婧愬彂甯冨寘閲宒bug鐩綍涓嬬殑DBUG鎵嬪唽銆傛渶濂戒娇鐢ㄦ渶杩戠殑MySQL 5.1鍙戝竷鍖呬互鑾峰緱鏈杩戞洿鏂扮殑DBUG鎵嬪唽銆
浣犻氳繃鐢--debug="..."鎴杢he -#... 閫夐」璋冪敤涓涓▼搴忔潵浣跨敤璋冭瘯杞欢鍖呫
澶氭暟MySQL绋嬪簭鏈夐粯璁ょ殑璋冭瘯瀛楃涓诧紝濡傛灉浣犱笉缁--debug鎸囧畾涓涓夐」锛屽氨浣跨敤杩欎釜榛樿鐨勩傞粯璁ょ殑璺熻釜鏂囦欢閫氬父鏄/tmp/program_name.trace锛堝湪Unix涓婏級鍜孿program_name.trace 锛堝湪Windows涓婏級銆
璋冭瘯瀛楃涓叉槸涓绯诲垪鍐掑彿闅斿紑鐨勫尯娈碉紝濡備笅锛
<field_1>:<field_2>:...:<field_N>
姣忎釜鍖烘鍖呭惈涓涓己鍒舵爣蹇楀瓧绗︼紝鍚庨潰璺熺潃宸插拰鍙夌殑 鈥,鈥 浠ュ強涓鍒楃敤閫楀彿闅斿紑鐨勪慨鏀归噺锛
flag[,modifier,modifier,...,modifier]
褰撳墠琚瘑鍒殑鏍囪绗﹀彿鏄細
鏍囪 | 鎻忚堪 |
d | 鍏佽瀵瑰綋鍓嶇姸鎬佷粠DBUG_<N>瀹忚緭鍑恒傚彲鑳借窡鐫涓鍒楀叧閿瘝锛岃繖浜涘叧閿瘝浠呭閭d簺甯︽湁鍏抽敭璇嶇殑DBUG瀹忛夋嫨杈撳嚭銆備竴涓┖鐨勫叧閿瘝鍒楁剰鍛崇潃瀵规墍鏈夊畯杈撳嚭銆 |
D | 鍦ㄦ瘡涓皟璇曡捣杈撳嚭琛屽悗寤惰繜銆傚弬閲忎竴涓崄鍒嗕箣涓绉掍负鍗曚綅鏉ュ欢杩熺殑鏁帮紝瀹冨彈闄愪簬鏈哄櫒鐨勮兘鍔涖傛瘮濡 -#D,20 鎸囧畾涓涓2绉掔殑寤惰繜銆 |
f | 闄愬埗璋冭瘯鍜/鎴栬窡韪紝浠ュ強绠鍗曡瀹氫簬鍒楀嚭鍚嶅瓧鐨勫嚱鏁般傛敞鎰忥紝绌哄垪灏嗙姝㈡墍鐢ㄥ嚱鏁般傚簲璇ョ粰鍑洪傚綋鐨刣 鎴 t 鏍囪锛屽鏋滃畠浠鍏佽浜嗭紝杩欎釜鏍囪浠呴檺鍒跺畠浠殑鍔ㄤ綔銆 |
F | 瀵硅皟璇曟垨璺熻釜杈撳嚭鐨勬瘡涓琛岃瘑鍒簮鏂囦欢鍚嶃 |
i | 瀵硅皟璇曟垨璺熻釜杈撳嚭鐨勬瘡涓琛岀敤PID鎴栫嚎绋婭D璇嗗埆杩涚▼銆 |
g | 鍏佽瑙f瀽锛屽垱寤哄悕涓虹殑dbugmon.out鏂囦欢锛屽畠鍖呭惈鍙敤鏉ョ畝鍗曡瀹氱▼搴忕殑淇℃伅銆傚彲鑳借窡鐫涓鍒楀叧閿瘝锛屽畠浠槸閫夋嫨鍙鍒椾腑鐨勫嚱鏁板仛绠鍗曡瀹氥備竴涓┖鍒楁剰鍛崇潃鎵鏈夊嚱鏁伴兘瑕佽冭檻鍒般 |
L | 涓鸿皟璇曟垨璺熻釜杈撳嚭鐨勬瘡涓琛岃瘑鍒簮鏂囦欢琛屽彿銆 |
n | 涓鸿皟璇曟垨璺熻釜杈撳嚭鐨勬瘡涓琛屾墦鍗板綋鍓嶅嚱鏁板祵濂楁繁搴︺ |
N | 缁欒皟璇曡緭鍑虹殑姣忎竴琛岀紪鍙枫 |
o | 閲嶅畾鍚戣皟璇曞櫒杈撳嚭娴佸埌鎸囧畾鏂囦欢銆傞粯璁よ緭鍑烘槸stderr 鏂囦欢銆 |
O | 绫讳技浜 o锛屼絾鏄枃浠跺湪姣忔鍐欐搷浣滀箣闂磋鍐插埛銆傚綋闇瑕佷箣鏃讹紝鏂囦欢鍦ㄦ瘡娆″啓鎿嶄綔涔嬮棿琚叧闂劧鍚庨噸鏂版墦寮銆 |
p | 闄愬埗璋冭瘯鍣ㄤ綔鐢ㄤ簬鎸囧畾杩涚▼銆備负浣胯皟璇曞櫒鍔ㄤ綔锛屼竴涓繘绋嬪繀椤荤敤DBUG_PROCESS瀹忔潵璇嗗埆锛屼笖鍖归厤鍒楄〃涓殑涓涓 |
P | 涓鸿皟璇曟垨璺熻釜杈撳嚭鐨勬瘡涓琛屾墦鍗板綋鍓嶈繘绋嬪悕瀛椼 |
r | 褰撴帹鍑轰竴涓柊鐘舵佹椂锛屼笉缁ф壙鍓嶇姸鎬佺殑鎿嶄綔宓屽娣卞害绾у埆銆傚綋杈撳嚭鍦ㄥ乏杈圭┖鐧藉紑濮嬫椂鏈夌敤銆 |
S | 鍦ㄦ瘡涓皟璇曡繃鐨勫嚱鏁板仛_sanity(_file_,_line_)鍑芥暟鐩村埌 _sanity() 杩斿洖涓嶅悓浜0鐨勭粨鏋溿傦紙澶у鏁扮殑鏃跺欎笌safemalloc 涓璧风敤鏉ユ壘鍑哄唴瀛樻紡娲烇級銆 |
t | 鍏佽鍑芥暟璋冪敤/閫鍑鸿窡韪銆傚彲鑳借窡鐫涓涓粰鍑烘渶澶ц窡韪骇鍒殑鏁板瓧鍒楋紙鍙惈涓涓慨鏀归噺锛夛紝瓒呰繃杩欎釜鏁板瓧锛岃皟璇曚腑鎴栬窡韪腑鐨勫畯涓嶈兘浜х敓浠讳綍杈撳嚭銆 榛樿涓轰竴涓紪璇戞椂闂撮夐」銆 |
鍙兘鍑虹幇鍦ㄥ澹冲懡浠よ锛-# 鍏稿瀷鍦拌鐢ㄦ潵寮曞叆涓涓帶鍒跺瓧绗︿覆鍒颁竴涓簲鐢ㄧ▼搴忎腑锛 鐨勮皟璇曟帶鍒跺瓧绗︿覆鐨勪竴浜涗緥瀛愬涓嬶細
-#d:t -#d:f,main,subr1:F:L:t,20 -#d,input,output,files:n -#d:t:i:O,\\mysqld.trace
鍦∕ySQL涓, 鎵撳嵃鐨勪竴鑸爣璁版槸锛堢敤 d 閫夐」锛夋槸 enter, exit, error, warning, info, 鍜 loop 銆
鎴戞浘灏濊瘯璁㎝ySQL浣跨敤RTS绾跨▼杞欢鍖咃紝浣嗘槸鍦ㄤ笅闈㈢殑闂涓婇亣鍒伴樆纰嶏細
RTS绾跨▼杞欢鍖呭緢澶氳佺増鏈殑POSIX璋冪敤锛屽鎵鏈夊嚱鏁扮殑鍐欏皝瑁呭氨寰堟灟鐕ャ傛垜鍊惧悜浜庤涓烘妸绾跨▼搴撴崲鎴愭渶鏂扮殑POSIX瑙勬牸锛屼細鏇村鏄撲簺銆傘
涓浜涘皝瑁呮鍦ㄧ紪鍐欎腑銆傛洿澶氫俊鎭鍙傞槄mysys/my_pthread.c 鏂囦欢銆
鑷冲皯涓嬮潰璇撮亾鐨勫簲璇ユ敼鍙樹竴涓嬶細
pthread_get_specific璇ヤ娇鐢ㄤ竴涓弬閲忋 sigwait搴旇浣跨敤涓や釜鍙傞噺銆傚緢澶氬嚱鏁帮紙鑷冲皯pthread_cond_wait, pthread_cond_timedwait()锛夊簲璇ヨ繑鍥為敊璇殑閿欒浠g爜銆傜幇鍦ㄥ畠浠繑鍥 -1 涓旇缃 errno銆
鍙︿竴涓棶棰樻槸锛岀敤鎴风骇绾跨▼浣跨敤ALRM淇″彿锛岃繖浼氱粓姝㈠緢澶氬嚱鏁帮紙read, write, open...锛夈侻ySQL搴旇閲嶈瘯涓涓嬫墍鏈夎繖涓婇潰鐨勪腑鏂紝浣嗘槸杩欏苟闈炲緢瀹规槗鍘婚獙璇併
鏈澶х殑鏈В鍐抽棶棰樺涓嬶細
瑕佽幏寰楃嚎绋嬬骇璀︽姤锛屾垜浣跨敤pthread_cond_timedwait()鏀瑰彉 mysys/thr_alarm.c锛岃瀹冨湪璀︽姤涔嬮棿绛夊緟銆備絾鏄畠鍙戠敓EINTR閿欒锛岀粓姝簡銆傛垜璇曠潃璋冭瘯绾跨▼搴撴壘鍑轰负浠涔堜細鍑鸿繖涓敊璇紝浣嗘槸鎵句笉鍒颁竴涓畝渚 鐨勮В鍐冲姙娉曘
濡傛灉浜轰汉鎯宠鐢≧TS绾跨▼璺戜竴涓婱ySQL锛屾垜寤鸿浠ヤ笅鍑犵偣锛
鎶奙ySQL浣跨敤鐨勫嚱鏁颁粠绾跨▼搴撳彉鍒癙OSIX銆傝繖涓嶄細鍗犳嵁閭d箞闀挎椂闂淬
鐢-DHAVE_rts_threads缂栬瘧鎵鏈夊簱銆
缂栬瘧thr_alarm銆
鑻ュ湪鎵ц涓湁涓浜涘皬鐨勫樊寮傦紝鍙互鏀瑰彉my_pthread.h鍜宮y_pthread.c鏉ヤ慨澶嶅畠浠
杩愯thr_alarm銆傚鏋滃畠娌℃湁浠讳綍璀﹀憡锛岄敊璇垨缁堟淇℃伅鍦拌繍琛岋紝浣犲氨鍋氬浜嗐傝繖閲屾槸涓涓湪Solaris鎴愬姛杩愯鐨勪緥瀛愶細
Main thread: 1 Thread 0 (5) started Thread: 5 Waiting process_alarm Thread 1 (6) started Thread: 6 Waiting process_alarm process_alarm thread_alarm Thread: 6 Slept for 1 (1) sec Thread: 6 Waiting process_alarm process_alarm thread_alarm Thread: 6 Slept for 2 (2) sec Thread: 6 Simulation of no alarm needed Thread: 6 Slept for 0 (3) sec Thread: 6 Waiting process_alarm process_alarm thread_alarm Thread: 6 Slept for 4 (4) sec Thread: 6 Waiting process_alarm thread_alarm Thread: 5 Slept for 10 (10) sec Thread: 5 Waiting process_alarm process_alarm thread_alarm Thread: 6 Slept for 5 (5) sec Thread: 6 Waiting process_alarm process_alarm ... thread_alarm Thread: 5 Slept for 0 (1) sec end
MySQL闈炲父渚濊禆浣跨敤涓殑绾跨▼杞欢鍖呫 鎵浠ュ綋涓篗ySQL閫夋嫨涓涓ソ骞冲彴鐨勬椂鍊欙紝绾跨▼杞欢鍖呭氨闈炲父閲嶈銆
鑷冲皯鏈変笁绉嶇嚎绋嬭蒋浠跺寘锛
鐢ㄦ埛绾跨▼鍦ㄥ崟涓繘绋嬩腑銆傜嚎绋嬪垏鎹㈢敤璀︽姤绠$悊锛岀嚎绋嬪簱鐢ㄩ攣绠$悊鎵鏈夐潪绾跨▼瀹夊叏鍑芥暟銆傝锛屽啓鍜岄夋嫨鎿嶄綔閫氬父琚嚎绋嬩笓鏈夌殑鍒囨崲鍣ㄧ鐞嗭紝 濡傛灉杩愯涓殑绾跨▼瑕佺瓑寰呮暟鎹紝杩欎釜鍒囨崲鍣ㄥ氨浼氬垏鎹㈡搷浣滃埌鍙︿竴涓嚎绋嬨傚鏋滅敤鎴风嚎绋嬭蒋浠跺寘闆嗘垚鍦ㄦ爣鍑嗗簱锛團reeBSD 鍜 BSDI 绾跨▼杞欢鍖咃級閲岋紝杩欐牱鐨 绾跨▼杞欢鍖呮瘮閭d簺涓嶅緱涓嶆槧灏勬墍鏈変笉瀹夊叏璋冪敤锛圡IT-pthreads, FSU Pthreads 鍜 RTS 绾跨▼杞欢鍖咃級鐨勭嚎绋嬭蒋浠跺寘闇瑕佹洿灏戠殑绯荤粺寮閿銆傚湪鏌愪簺鐜涓嬶紙濡係CO锛夛紝鎵鏈夌郴缁熻皟鐢ㄩ兘鏄嚎绋嬪畨鍏ㄧ殑锛屾墍浠ユ槧灏勯潪甯稿鏄擄紙SCO涓婄殑FSU Pthreads鍖咃級銆備笉瓒充箣澶勬槸锛氭墍鏈夋槧灏勭殑璋冪敤鍗犵敤寰堝皯鐨勬椂闂达紝浜庢槸鎯宠鑳藉鐞嗘墍鏈夌殑鎯呭喌灏辩浉褰撶箒鏉傘傛湁涓浜涚郴缁熻皟鐢ㄩ氬父涓嶈绾跨▼杞欢鍖咃紙绫讳技MIT-pthreads and sockets鍖咃級澶勭悊銆傜嚎绋嬭鍒掍笉鎬绘槸鏈浼樺寲鐨勩
鍦ㄥ垎绂昏繘绋嬩腑鐨勭敤鎴风嚎绋嬨傜嚎绋嬪垏鎹㈡槸鐢卞唴鏍告潵鍋氾紝涓旀墍鏈夌殑鏁版嵁鍦ㄧ嚎绋嬩箣闂村叡浜傜嚎绋嬭蒋浠跺寘绠$悊鏍囧噯绾跨▼璋冪敤锛屽厑璁稿湪绾跨▼涔嬮棿鍏变韩鏁版嵁銆侺inuxThreads鍖呭氨浣跨敤杩欑鏂规硶銆備笉瓒充箣澶勶細澶杩涚▼銆傜嚎绋嬪垱寤哄緱鎱紝濡傛灉涓涓嚎绋嬫鎺変簡锛屽叾浣欏緱绾跨▼閫氬父灏辨寕璧锋潵锛屼綘蹇呴』鍦ㄩ噸鍚箣鍓嶆潃鎺夎繖浜涙寕璧风殑绾跨▼銆傜嚎绋嬪垏鎹㈠紑閿鏈変簺澶с
鍐呮牳绾跨▼銆傜嚎绋嬪垏鎹㈢敱绾跨▼搴撴垨鍐呮牳鏉ュ仛锛屽苟涓旈潪甯稿揩銆備竴涓繘绋嬪氨鍙互浜嗐備絾鍦ㄤ竴浜涚郴缁熶腑ps鍙兘鏄剧ず涓嶅悓绾跨▼銆傚鏋滀竴涓嚎绋嬬粓姝紝鏁翠釜杩涚▼灏辩粓姝簡銆傚鏁扮郴缁 璋冪敤鏄嚎绋嬪畨鍏ㄧ殑锛屽苟涓斿彧瑕侀潪甯稿皬鐨勭郴缁熷紑閿銆Solaris, HP-UX, AIX 鍜孫SF/1 閮芥湁鍐呮牳绾跨▼銆
鍦ㄤ竴浜涚郴缁熶腑鍐呮牳绾跨▼琚郴缁熷簱涓暣鍚堢敤鎴风骇绾跨▼绠$悊銆傚湪杩欑鎯呭喌涓嬶紝绾跨▼鍒囨崲鍙兘鐢辩嚎绋嬪簱鏉ュ仛锛岃屽唴鏍稿苟涓嶆槸鐪熸鐨勨滅嚎绋嬫劅鐭モ濈殑銆
杩欐槸MySQL鍙傝冩墜鍐岀殑缈昏瘧鐗堟湰锛屽叧浜嶮ySQL鍙傝冩墜鍐岋紝璇疯闂dev.mysql.com銆 鍘熷鍙傝冩墜鍐屼负鑻辨枃鐗堬紝涓庤嫳鏂囩増鍙傝冩墜鍐岀浉姣旓紝鏈炕璇戠増鍙兘涓嶆槸鏈鏂扮殑銆