Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL hang for analyze table when exceed tidb_mem_quota_analyze #48171

Closed
wshwsh12 opened this issue Nov 1, 2023 · 0 comments · Fixed by #48264
Closed

SQL hang for analyze table when exceed tidb_mem_quota_analyze #48171

wshwsh12 opened this issue Nov 1, 2023 · 0 comments · Fixed by #48264
Assignees
Labels
affects-6.5 affects-7.1 affects-7.5 feature/developing the related feature is in development severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@wshwsh12
Copy link
Contributor

wshwsh12 commented Nov 1, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Currently, the ANALYZE memory quota is an experimental feature.

use test;
drop table tbl_2;
create table tbl_2 ( col_20 decimal default 84232 , col_21 tinyint not null , col_22 int default 80814394 , col_23 mediumint default -8036687 not null , col_24 smallint default 9185 not null , col_25 tinyint unsigned default 65 , col_26 char(115) default 'ZyfroRODMbNDRZnPNRW' not null , col_27 bigint not null , col_28 tinyint not null , col_29 char(130) default 'UMApsVgzHblmY' , primary key idx_14 ( col_28,col_22 ) , unique key idx_15 ( col_24,col_22 ) , key idx_16 ( col_21,col_20,col_24,col_25,col_27,col_28,col_26,col_29 ) , key idx_17 ( col_24,col_25 ) , unique key idx_18 ( col_25,col_23,col_29,col_27,col_26,col_22 ) , key idx_19 ( col_25,col_22,col_26,col_23 ) , unique key idx_20 ( col_22,col_24,col_28,col_29,col_26,col_20 ) , key idx_21 ( col_25,col_24,col_26,col_29,col_27,col_22,col_28 ) ) partition by range ( col_22 ) ( partition p0 values less than (-1938341588), partition p1 values less than (-1727506184), partition p2 values less than (-1700184882), partition p3 values less than (-1596142809), partition p4 values less than (445165686) );
insert ignore into tbl_2 values ( 0,25,517800617,-263729,21254,134,'unTFEzIi',2320940296898283606,-77,'IFbHgEl' );
insert ignore into tbl_2 values ( 264,18,118982928,-4135028,23350,205,'kFVSFQJUIkxK',-471058966918296011,-83,'DepYYbJme' );
insert ignore into tbl_2 values ( 5,-93,1698970555,7297595,-20963,9,'JuemggmmuBStmDuS',7433529409982707371,21,'xRnDjLwK' );
insert ignore into tbl_2 values ( 3227,100,351916122,-2683707,3512,160,'LlnkbJ',-6699927124249581423,57,'yHKLZdoyWtMP' );
insert ignore into tbl_2 values ( 91789,102,-1243628659,-5663317,30438,120,'vjCoouPpMgtzvX',5721279486575681670,52,'kLaGUIuxAdo' );
insert ignore into tbl_2 values ( 95,71,1830704221,4318032,4583,21,'MORjMqdmCzTdrIeruwM',2049102098828428193,80,null );
insert ignore into tbl_2 values ( 0,1,1027823151,-6689007,-23031,142,'nBApAwXj',-853182707740160327,110,'' );
insert ignore into tbl_2 values ( 914663,70,-1458235540,-5269267,-23731,246,'NtIuo',-5058708626991512029,52,'LYIvUm' );
insert ignore into tbl_2 values ( 95,-90,-1453513144,-4766727,-60,84,'',-2784974021908540648,-70,'xxkTiCzAqlRZCm' );
insert ignore into tbl_2 values ( 3,-53,-1117057577,-3332170,26120,95,'NJYCeWbnnohdGF',-492111990366332432,-4,'ELOwrbyLJP' );
insert ignore into tbl_2 values ( 95,-112,1358985626,-228247,-15538,210,'YGoMrnIjXkTMpHzQc',-5076703034972376981,-57,'spTWtksXOzescOGkGoG' );
insert ignore into tbl_2 values ( 901,79,1288369371,-5100768,-2491,38,'MlqsVVEcsNTPFXPlR',859527189374137767,77,'a' );
insert ignore into tbl_2 values ( 783,-16,-158890628,-5459341,-14523,252,'BGOSsEMEGEIJfeY',2597314093051943679,0,'m' );
insert ignore into tbl_2 values ( 0,43,977581385,2840473,-20879,186,'EMjeyAUFbDvKnQnnyD',-3181878388218028301,113,'HFS' );
insert ignore into tbl_2 values ( 66599,-115,-180740362,-6598558,14946,null,'SlUofvpJFcaO',-2686760803778689953,-109,'crCRgWLsBuNyJBdNo' );
insert ignore into tbl_2 values ( 8,40,-543811204,2533845,32737,91,'tYocCpURHIR',4099505766829591722,8,'' );
insert ignore into tbl_2 values ( 85399,-119,-144507878,-7979013,-11145,133,'WXvHPgJNdOBiXNfDRXF',424512393110602985,-111,'dmZPvGFaBCwkiYKO' );
insert ignore into tbl_2 values ( 774672,-96,-1377338337,-4333291,31857,206,'MPal',-3631572124570980155,21,'vPFqFyvRal' );
insert ignore into tbl_2 values ( 87487,103,-744770749,6976678,-19192,59,'xDoxOARV',-2616258694157691727,93,'tppyxDUgwmafYaD' );
insert ignore into tbl_2 values ( 6,-120,-345848140,4756238,-17825,79,'hOO',-5822134718570751065,-27,'YfFKEIUCnMDksvQqxTg' );
insert ignore into tbl_2 values ( 458819,63,491019611,6951134,12229,112,'qqBFirStLqx',-650832789088221152,91,'OUnK' );
insert ignore into tbl_2 values ( 35427,30,-852943572,-2976826,-11667,67,'qAdmiCjgEfrBC',4345336742495935651,26,'UXdE' );
insert ignore into tbl_2 values ( 0,-85,1264321882,-5342835,28631,222,'lHGwyDCYPdYyXfpayK',2821157951078021585,77,'SkvIQ' );
insert ignore into tbl_2 values ( 489987,-79,926928378,4648733,11806,12,'WFLsuOfQWkWwLTWUojm',-9085582163695777219,90,'gNHbDZTSzhYYtDcaDQ' );
insert ignore into tbl_2 values ( 7075,22,-102433070,-609381,-30627,136,'lyhMJaRQ',2307674018702807701,53,'WJzQfUBYckcdiu' );
insert ignore into tbl_2 values ( 6,43,-1929648848,-6484859,-24698,170,'zrjuBFPpmybUeONeQ',6869726520888833425,91,'BmztCwZcsGoIub' );
insert ignore into tbl_2 values ( 574,-8,-1348729651,4015360,1417,149,'ObURubJLJ',-4720734553537376075,53,'M' );
insert ignore into tbl_2 values ( 84416,41,1588246920,2850019,1167,175,'GTKCDNFpimzHBqcEmV',1461589375741498968,5,'gKCnWRUEFBynLhbIh' );
insert ignore into tbl_2 values ( 39,89,-193404225,-2960359,25574,212,'jtxgpORK',-4541259343577427750,53,'RJRskcBuUXjTCzh' );
insert ignore into tbl_2 values ( null,0,-861274700,5299411,-943,69,'mhfzPtPqYoPZBzQ',7857877567682922501,39,'XlO' );
insert ignore into tbl_2 values ( 2101,108,5158474,1873502,-9941,196,'eS',-3760407742037296813,46,'uBoKYSpHOkGtAiW' );
insert ignore into tbl_2 values ( 9331,78,-465635109,-4573165,-11444,null,'MLqfHlLlwwFTcTXqXSi',5671670130021937337,29,'HDmynuBBb' );
insert ignore into tbl_2 values ( 1740,0,1406841308,-1337713,-20304,6,'gpqzqlZyeSRQBD',-8249147679596914701,-23,'ig' );
insert ignore into tbl_2 values ( 0,-68,-1678925132,-5893850,-17792,128,'BC',1821676934371500399,99,'uIqLzayWibPUL' );
insert ignore into tbl_2 values ( 16819,-21,-1647154967,1062855,16053,78,'zRKxEtNGzcQ',577603899266821553,93,'uhfyivYv' );
insert ignore into tbl_2 values ( 0,22,-2077700386,8185373,-15304,17,'cOvQglNwEGGKJkt',-603987886690369584,-121,'rBkzhKPB' );
insert ignore into tbl_2 values ( 284,-2,1513671156,6056538,12894,null,'ggssuPtqCBg',2062820520874443389,64,'phVa' );
insert ignore into tbl_2 values ( 0,-94,-211917420,3131572,30102,41,'Vpzym',-2473508229754723851,-84,'TYvEgWwgfjtJsliQA' );
insert ignore into tbl_2 values ( 49275,-35,122847409,-1794992,-10606,119,'dwcuim',-8636707089906452582,72,'np' );
insert ignore into tbl_2 values ( 0,52,701690364,6914611,20143,85,'CqqNvkODvsPjM',-2140060003875691003,-83,'Q' );
insert ignore into tbl_2 values ( 1932,97,1993334477,-3433152,29333,249,'cnoqwuiDIja',-4165014238942532673,-10,'IR' );
insert ignore into tbl_2 values ( 6189,29,77589083,-2804390,23522,83,'KWDENdQPiVebSlziAg',6636541619070186134,28,'hSoexyzubbYKMGAfEI' );
insert ignore into tbl_2 values ( 43,-9,-1416919655,-2123407,17681,8,'VOjjJGQ',9215520209851099149,-13,'clTwPJgvjZcSxKlS' );
insert ignore into tbl_2 values ( 1396,-102,-1315380781,4232893,-6085,182,'BEGehTtvnU',-2106190769756215649,-5,'jNZLXFSqGE' );
insert ignore into tbl_2 values ( 9,54,-940430011,5825138,-1858,105,'ChfmatPWAmG',-1770043336161206207,-20,'zisaROXe' );
insert ignore into tbl_2 values ( 9268,19,556057507,-7095689,-11465,155,'oWisRImHAgulJDPwM',-351233431257643830,92,'OHQY' );
insert ignore into tbl_2 values ( 4138,-127,1290072645,2734166,9712,147,'GHW',139379877040596513,41,'SohNjx' );
insert ignore into tbl_2 values ( 38418,68,-926076967,-4533711,1998,248,'peMJGqbVohmY',-4763657993885358571,-108,'BEWUQfRzcENTfwAj' );
insert ignore into tbl_2 values ( 8,-84,1029762871,-1481309,1176,100,'fMhfJMfcHQZYvoDj',271832822558587197,35,'sZWfaEgRTgIkAag' );
insert ignore into tbl_2 values ( 0,-21,-654236038,-5140791,-4161,61,'bLUxKwCSrqFmG',8601283215204362344,74,'bmBuWGtwVymF' );
insert ignore into tbl_2 values ( 9165,-33,-907252321,-2444548,11778,143,'jLFSSPBAQenPtRo',-4763009544963722127,120,'' );
insert ignore into tbl_2 values ( 995934,-9,781676449,492811,23754,37,'wMyKPJND',-897568324794347727,-7,'' );
insert ignore into tbl_2 values ( null,27,1451153742,-5048012,-8373,11,'WyVtSqYWUbiN',-3364648183143265528,9,'Y' );
insert ignore into tbl_2 values ( 33345,76,1815265855,-8226571,-24358,134,'kGJIzsnwkrIPF',5150890776700778022,-11,'' );
insert ignore into tbl_2 values ( 14627,-27,1271002753,-4130909,-9342,124,'Hs',5754010266033632257,-105,null );
insert ignore into tbl_2 values ( 39882,51,-1902128782,-2812003,-32210,206,'RZYnLj',8409408384032353548,2,'TjSmvbZwAeIgxad' );
insert ignore into tbl_2 values ( 73,-27,-1333629236,6120265,-31910,192,'UPdBBLe',4111347660644825451,58,'FDbeeuOQocFoneW' );
insert ignore into tbl_2 values ( 86,13,2086171320,-7071983,-19838,191,'yf',2180372824562203629,-117,'NJLOMuimPUwVSZuLWJI' );
insert ignore into tbl_2 values ( 722216,-29,183143334,-2419749,-4279,236,'rmlGUELYAERRo',-6245094512426625554,-71,'SDFZSq' );
insert ignore into tbl_2 values ( 5986,57,-724563950,7228393,5191,87,'AQMTwbfLvOriAVGlTT',4957597055588137561,-75,'DrqNAF' );
insert ignore into tbl_2 values ( 1,-101,-368762243,7524994,-18931,168,'',2379870955028492051,-45,'TAcfhpNWJKUnbDlZHu' );
insert ignore into tbl_2 values ( 262797,104,-1965391356,6154253,-25867,253,'mhcaPfFDJsWTBrxhYJ',5078116346311964580,-50,'UNbfOjHthSnQPEuqX' );
insert ignore into tbl_2 values ( 53,-14,1785304341,-258006,-21350,131,'nlSbTLEjFKjUHn',-1626223946422060868,111,'mDItIYBBDFHKIiJBq' );
insert ignore into tbl_2 values ( 2581,-104,1910660124,-1070856,-29420,41,'wbalgPcFgCj',-2885044042794935937,-62,'sbUHqhoVK' );
insert ignore into tbl_2 values ( 373217,68,1785529141,-4551636,-27946,58,'JDVAOKjARC',-5980900082274855729,4,'' );
insert ignore into tbl_2 values ( 4791,-109,1694423134,-8387764,-2779,208,'wGBYTO',3234094450829725361,-20,'ouMtueCSPLzoZrwxGM' );
insert ignore into tbl_2 values ( 942,33,-1915007317,3408149,-3699,193,'Trywdis',1876334369465184864,115,null );
insert ignore into tbl_2 values ( 7,-39,-1382727205,-2544981,-28075,88,'FDhOsTRKRLCwEk',-1239168882463214388,17,'WskQzCK' );
insert ignore into tbl_2 values ( null,55,-388460319,-2292918,10130,162,'UqjDlYvdcNY',4872802276956896607,-51,'ORBQjnumcXP' );
insert ignore into tbl_2 values ( 42,-19,-9677826,-1168338,16904,79,'TzOqH',8173610791128879419,65,'lNLcvOZDcRzWvDO' );
insert ignore into tbl_2 values ( 2,26,369867543,-6773303,-24953,41,'BvbdrKTNtvBgsjjnxt',5996954963897924308,-95,'wRJYPBahkIGDfz' );
insert ignore into tbl_2 values ( 6896,3,444460824,-2070971,-13095,167,'MvWNKbaOcnVuIrtbT',6968339995987739471,-5,'zWipNBxGeVmso' );
insert ignore into tbl_2 values ( 58761,112,-1535034546,-5837390,-14204,157,'',-8319786912755096816,15,'WBjsozfBfrPPHmKv' );
insert ignore into tbl_2 values ( 84923,113,-973946646,406140,25040,51,'THQdwkQvppWZnULm',5469507709881346105,94,'oGNmoxLLgHkdyDCT' );
insert ignore into tbl_2 values ( 0,-104,-488745187,-1941015,-2646,39,'jyKxfs',-5307175470406648836,46,'KZpfjFounVgFeRPa' );
insert ignore into tbl_2 values ( 4,97,2105289255,1034363,28385,192,'',4429378142102752351,8,'jOk' );
insert ignore into tbl_2 values ( 32,-19,1205054137,1362275,4598,78,'mVMUUAbUEamHnM',3144712845575296499,55,'FHlAcAbfPWDkXz' );
insert ignore into tbl_2 values ( 0,-2,387433856,5306079,-26174,146,'nzkVlDntYQSmGPsgyax',-2717189041129707848,101,'cKdeOFdgFuioMlEWS' );
insert ignore into tbl_2 values ( 0,103,1843954270,6740606,-24797,237,'cBTeuhCCwlkilGqDDz',-3339789406367037362,-71,'dDUr' );
insert ignore into tbl_2 values ( 1,-19,-1625205140,5239891,27912,210,'F',4468073288932507935,66,'UkPxsPsDbgNljIqUB' );
set global tidb_mem_quota_analyze=128;
analyze table tbl_2;
analyze table tbl_2;
analyze table tbl_2;
analyze table tbl_2;
analyze table tbl_2;
goroutine 20777 [semacquire, 3 minutes]:
sync.runtime_Semacquire(0xc0081ddfb8?)
	/usr/local/go/src/runtime/sema.go:62 +0x25
sync.(*WaitGroup).Wait(0xc008243440?)
	/usr/local/go/src/sync/waitgroup.go:116 +0x48
github.com/pingcap/tidb/pkg/executor.(*AnalyzeExec).Next(0xc0079eadc0, {0x62edd70?, 0xc008392750}, 0x1?)
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/executor/analyze.go:140 +0x51e
github.com/pingcap/tidb/pkg/executor/internal/exec.Next({0x62edd70, 0xc008392750}, {0x6305088, 0xc0079eadc0}, 0xc0081b48c0)
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/executor/internal/exec/executor.go:278 +0x2ba
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).next(0xc00800ec30, {0x62edd70, 0xc008392750}, {0x6305088, 0xc0079eadc0}, 0x22eee0?)
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/executor/adapter.go:1226 +0x6e
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).handleNoDelayExecutor(0xc00800ec30, {0x62edd70?, 0xc008392750?}, {0x6305088?, 0xc0079eadc0})
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/executor/adapter.go:971 +0x396
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).handleNoDelay(0xc00800ec30, {0x62edd70, 0xc008392750}, {0x6305088?, 0xc0079eadc0?}, 0x0)
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/executor/adapter.go:797 +0x252
github.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec(0xc00800ec30, {0x62edd70, 0xc008392750})
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/executor/adapter.go:578 +0xda5
github.com/pingcap/tidb/pkg/session.runStmt({0x62edd70?, 0xc0081242a0?}, 0xc008194780, {0x62fd820, 0xc00800ec30?})
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/session/session.go:2421 +0x422
github.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt(0xc008194780, {0x62edd70?, 0xc0081242a0?}, {0x6303668?, 0xc0079cb5f0?})
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/session/session.go:2271 +0x109b
github.com/pingcap/tidb/pkg/server.(*TiDBContext).ExecuteStmt(0xc00819a4e0, {0x62edd70, 0xc0081242a0}, {0x6303668?, 0xc0079cb5f0})
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/server/driver_tidb.go:292 +0xa7
github.com/pingcap/tidb/pkg/server.(*clientConn).handleStmt(0xc00818a480, {0x62edda8, 0xc0079fd770}, {0x6303668, 0xc0079cb5f0}, {0x0, 0x0, 0x0}, 0x1)
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/server/conn.go:2009 +0x153
github.com/pingcap/tidb/pkg/server.(*clientConn).handleQuery(0xc00818a480, {0x62edda8, 0xc0079fd770}, {0xc007bd95a9, 0x13})
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/server/conn.go:1800 +0x9a5
github.com/pingcap/tidb/pkg/server.(*clientConn).dispatch(0xc00818a480, {0x62edd70?, 0xc0081d6000?}, {0xc007bd95a8, 0x14, 0x14})
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/server/conn.go:1287 +0xf8b
github.com/pingcap/tidb/pkg/server.(*clientConn).Run(0xc00818a480, {0x62edd70, 0xc0081d6000})
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/server/conn.go:1066 +0x53e
github.com/pingcap/tidb/pkg/server.(*Server).onConn(0xc00082f400?, 0xc00818a480)
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/server/server.go:701 +0x89d
created by github.com/pingcap/tidb/pkg/server.(*Server).startNetworkListener in goroutine 17741
	/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/server/server.go:517 +0x78d

2. What did you expect to see? (Required)

Can cancel the sql or run successfully.

3. What did you see instead (Required)

Hang

4. What is your TiDB version? (Required)

master

@wshwsh12 wshwsh12 added the type/bug The issue is confirmed as a bug. label Nov 1, 2023
@jebter jebter added sig/execution SIG execution severity/major feature/developing the related feature is in development labels Nov 1, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 labels Nov 1, 2023
@zanmato1984 zanmato1984 added sig/planner SIG: Planner and removed sig/execution SIG execution labels Nov 1, 2023
@hawkingrei hawkingrei added affects-7.1 affects-6.5 and removed may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 affects-7.1 affects-7.5 feature/developing the related feature is in development severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants