Skip to content

Commit af2b750

Browse files
committed
pkg
1 parent dda0139 commit af2b750

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

pkg/planner/core/rule_collect_plan_stats.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ func RequestLoadStats(ctx base.PlanContext, neededHistItems []model.StatsLoadIte
106106
if maxExecutionTime > 0 && maxExecutionTime < uint64(syncWait) {
107107
syncWait = int64(maxExecutionTime)
108108
}
109-
logutil.BgLogger().Info("wwz")
110109
failpoint.Inject("assertSyncWaitFailed", func(val failpoint.Value) {
111110
if val.(bool) {
112111
if syncWait != 1 {

pkg/statistics/handle/syncload/stats_syncload.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package syncload
1616

1717
import (
18-
"fmt"
18+
stderrors "errors"
1919
"math/rand"
2020
"runtime"
2121
"time"
@@ -94,7 +94,6 @@ func (s *statsSyncLoad) SendLoadRequests(sc *stmtctx.StatementContext, neededHis
9494
}
9595
}
9696
})
97-
logutil.BgLogger().Info("wtf start work")
9897
if len(remainedItems) <= 0 {
9998
return nil
10099
}
@@ -302,7 +301,6 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
302301
}
303302
}()
304303
item := task.Item.TableItemID
305-
logutil.BgLogger().Info("wtf start")
306304
tbl, ok := s.statsHandle.Get(item.TableID)
307305

308306
if !ok {
@@ -311,7 +309,6 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
311309
is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
312310
tblInfo, ok := s.statsHandle.TableInfoByID(is, item.TableID)
313311
if !ok {
314-
logutil.BgLogger().Info("wtf no find")
315312
return nil
316313
}
317314
isPkIsHandle := tblInfo.Meta().PKIsHandle
@@ -324,7 +321,6 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
324321
if index != nil {
325322
wrapper.idxInfo = index.Info
326323
} else {
327-
logutil.BgLogger().Info("debug WTF")
328324
wrapper.idxInfo = tblInfo.Meta().FindIndexByID(item.ID)
329325
}
330326
} else {
@@ -355,7 +351,7 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
355351
t := time.Now()
356352
needUpdate := false
357353
wrapper, err = s.readStatsForOneItem(sctx, item, wrapper, isPkIsHandle, task.Item.FullLoad)
358-
if err != nil {
354+
if err != nil || stderrors.As(err, failToGetHistMeta) {
359355
return err
360356
}
361357
if item.IsIndex {
@@ -374,9 +370,10 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
374370
return nil
375371
}
376372

373+
var failToGetHistMeta = errors.New("fail to get hist meta")
374+
377375
// readStatsForOneItem reads hist for one column/index, TODO load data via kv-get asynchronously
378376
func (*statsSyncLoad) readStatsForOneItem(sctx sessionctx.Context, item model.TableItemID, w *statsWrapper, isPkIsHandle bool, fullLoad bool) (*statsWrapper, error) {
379-
logutil.BgLogger().Info("debug readStatsForOneItem", zap.Int64("table_id", item.TableID), zap.Int64("hist_id", item.ID), zap.Bool("is_index", item.IsIndex))
380377
failpoint.Inject("mockReadStatsForOnePanic", nil)
381378
failpoint.Inject("mockReadStatsForOneFail", func(val failpoint.Value) {
382379
if val.(bool) {
@@ -394,7 +391,8 @@ func (*statsSyncLoad) readStatsForOneItem(sctx sessionctx.Context, item model.Ta
394391
if hg == nil {
395392
logutil.BgLogger().Error("fail to get hist meta for this histogram, possibly a deleted one", zap.Int64("table_id", item.TableID),
396393
zap.Int64("hist_id", item.ID), zap.Bool("is_index", item.IsIndex))
397-
return nil, errors.Trace(fmt.Errorf("fail to get hist meta for this histogram, table_id:%v, hist_id:%v, is_index:%v", item.TableID, item.ID, item.IsIndex))
394+
// Although it is errors, we don't return err, because raise error will have to retry. it is unnecessay.
395+
return nil, failToGetHistMeta
398396
}
399397
if item.IsIndex {
400398
isIndexFlag = 1

tests/integrationtest/r/planner/core/issuetest/planner_issue.result

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,3 +723,30 @@ CREATE TABLE t0(c0 int);
723723
CREATE TABLE t1(c0 int);
724724
SELECT t0.c0, t1.c0 FROM t0 NATURAL JOIN t1 WHERE '1' AND (t0.c0 IN (SELECT c0 FROM t0));
725725
c0 c0
726+
drop table if exists t1, t2, t3, t4;
727+
CREATE TABLE t1 (a int, b int, c int);
728+
CREATE TABLE t2 (a int, b int, c int);
729+
CREATE TABLE t3 (a int, b int, c int);
730+
CREATE TABLE t4 (a int, b int, c int);
731+
INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0);
732+
INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0);
733+
INSERT INTO t3 VALUES (1,2,0), (2,2,0);
734+
INSERT INTO t4 VALUES (3,2,0), (4,2,0);
735+
CREATE INDEX idx_b ON t2(b);
736+
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
737+
FROM (t3,t4)
738+
LEFT JOIN
739+
(t1,t2)
740+
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b order by 1, 2, 3, 4, 5;
741+
a b a b a b
742+
NULL NULL 2 2 3 2
743+
NULL NULL 2 2 4 2
744+
4 2 1 2 3 2
745+
4 2 1 2 3 2
746+
4 2 1 2 3 2
747+
4 2 1 2 4 2
748+
4 2 1 2 4 2
749+
4 2 1 2 4 2
750+
show warnings;
751+
Level Code Message
752+
drop table if exists t1, t2, t3, t4;

tests/integrationtest/t/planner/core/issuetest/planner_issue.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,3 +498,22 @@ drop table if exists t0, t1;
498498
CREATE TABLE t0(c0 int);
499499
CREATE TABLE t1(c0 int);
500500
SELECT t0.c0, t1.c0 FROM t0 NATURAL JOIN t1 WHERE '1' AND (t0.c0 IN (SELECT c0 FROM t0));
501+
502+
# TestIssue56472
503+
drop table if exists t1, t2, t3, t4;
504+
CREATE TABLE t1 (a int, b int, c int);
505+
CREATE TABLE t2 (a int, b int, c int);
506+
CREATE TABLE t3 (a int, b int, c int);
507+
CREATE TABLE t4 (a int, b int, c int);
508+
INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0);
509+
INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0);
510+
INSERT INTO t3 VALUES (1,2,0), (2,2,0);
511+
INSERT INTO t4 VALUES (3,2,0), (4,2,0);
512+
CREATE INDEX idx_b ON t2(b);
513+
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
514+
FROM (t3,t4)
515+
LEFT JOIN
516+
(t1,t2)
517+
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b order by 1, 2, 3, 4, 5;
518+
show warnings;
519+
drop table if exists t1, t2, t3, t4;

0 commit comments

Comments
 (0)