Skip to content

Commit d14fc3d

Browse files
hawkingreiti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#56614
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 278a67c commit d14fc3d

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

pkg/statistics/handle/syncload/stats_syncload.go

Lines changed: 12 additions & 4 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
"time"
2121

@@ -77,7 +77,6 @@ func (s *statsSyncLoad) SendLoadRequests(sc *stmtctx.StatementContext, neededHis
7777
}
7878
}
7979
})
80-
8180
if len(remainedItems) <= 0 {
8281
return nil
8382
}
@@ -323,7 +322,14 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
323322
}
324323
t := time.Now()
325324
needUpdate := false
325+
<<<<<<< HEAD
326326
wrapper, err = s.readStatsForOneItem(sctx, item, wrapper, tbl.IsPkIsHandle, task.Item.FullLoad)
327+
=======
328+
wrapper, err = s.readStatsForOneItem(sctx, item, wrapper, isPkIsHandle, task.Item.FullLoad)
329+
if stderrors.Is(err, errGetHistMeta) {
330+
return nil
331+
}
332+
>>>>>>> 10647c9d733 (statstics: avoid unnecessary try when to sync load (#56614))
327333
if err != nil {
328334
return err
329335
}
@@ -343,6 +349,8 @@ func (s *statsSyncLoad) handleOneItemTask(task *statstypes.NeededItemTask) (err
343349
return nil
344350
}
345351

352+
var errGetHistMeta = errors.New("fail to get hist meta")
353+
346354
// readStatsForOneItem reads hist for one column/index, TODO load data via kv-get asynchronously
347355
func (*statsSyncLoad) readStatsForOneItem(sctx sessionctx.Context, item model.TableItemID, w *statsWrapper, isPkIsHandle bool, fullLoad bool) (*statsWrapper, error) {
348356
failpoint.Inject("mockReadStatsForOnePanic", nil)
@@ -360,9 +368,9 @@ func (*statsSyncLoad) readStatsForOneItem(sctx sessionctx.Context, item model.Ta
360368
return nil, err
361369
}
362370
if hg == nil {
363-
logutil.BgLogger().Error("fail to get hist meta for this histogram, possibly a deleted one", zap.Int64("table_id", item.TableID),
371+
logutil.BgLogger().Warn("fail to get hist meta for this histogram, possibly a deleted one", zap.Int64("table_id", item.TableID),
364372
zap.Int64("hist_id", item.ID), zap.Bool("is_index", item.IsIndex))
365-
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))
373+
return nil, errGetHistMeta
366374
}
367375
if item.IsIndex {
368376
isIndexFlag = 1

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ JOIN tceb7972c ON tceb7972c.col_19 = t61a85298.col_71
681681
WHERE 16739493649928310215 MEMBER OF (derived_table.col_60767)
682682
OR NOT (JSON_CONTAINS(derived_table.col_60767, '6019730272580550835'));
683683
id estRows task access object operator info
684+
<<<<<<< HEAD
684685
Projection_12 10000.00 root 1->Column#19
685686
└─HashJoin_13 10000.00 root inner join, equal:[eq(planner__core__issuetest__planner_issue.tceb7972c.col_19, Column#20)]
686687
├─Projection_19(Build) 10000.00 root cast(planner__core__issuetest__planner_issue.t61a85298.col_71, double BINARY)->Column#20
@@ -691,3 +692,45 @@ Projection_12 10000.00 root 1->Column#19
691692
└─Selection_17 8000.00 cop[tikv] or(json_memberof(cast(16739493649928310215, json BINARY), planner__core__issuetest__planner_issue.tceb7972c.col_17), not(istrue_with_null(json_contains(planner__core__issuetest__planner_issue.tceb7972c.col_17, cast("6019730272580550835", json BINARY)))))
692693
└─TableFullScan_16 10000.00 cop[tikv] table:tceb7972c keep order:false, stats:pseudo
693694
set @@tidb_enable_global_index=0;
695+
=======
696+
Projection_11 6.00 root 1->Column#18
697+
└─HashJoin_13 6.00 root inner join, equal:[eq(test.tceb7972c.col_19, Column#19)]
698+
├─TableReader_16(Build) 4.80 root partition:all data:Selection_15
699+
│ └─Selection_15 4.80 cop[tikv] or(json_memberof(cast(16739493649928310215, json BINARY), test.tceb7972c.col_17), not(istrue_with_null(json_contains(test.tceb7972c.col_17, cast("6019730272580550835", json BINARY)))))
700+
│ └─TableFullScan_14 6.00 cop[tikv] table:tceb7972c keep order:false, stats:partial[col_17:missing]
701+
└─Projection_17(Probe) 10000.00 root cast(test.t61a85298.col_71, double BINARY)->Column#19
702+
└─TableReader_19 10000.00 root data:TableFullScan_18
703+
└─TableFullScan_18 10000.00 cop[tikv] table:t61a85298 keep order:false, stats:pseudo
704+
drop table if exists t0, t1;
705+
CREATE TABLE t0(c0 int);
706+
CREATE TABLE t1(c0 int);
707+
SELECT t0.c0, t1.c0 FROM t0 NATURAL JOIN t1 WHERE '1' AND (t0.c0 IN (SELECT c0 FROM t0));
708+
c0 c0
709+
drop table if exists t1, t2, t3, t4;
710+
CREATE TABLE t1 (a int, b int, c int);
711+
CREATE TABLE t2 (a int, b int, c int);
712+
CREATE TABLE t3 (a int, b int, c int);
713+
CREATE TABLE t4 (a int, b int, c int);
714+
INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0);
715+
INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0);
716+
INSERT INTO t3 VALUES (1,2,0), (2,2,0);
717+
INSERT INTO t4 VALUES (3,2,0), (4,2,0);
718+
CREATE INDEX idx_b ON t2(b);
719+
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
720+
FROM (t3,t4)
721+
LEFT JOIN
722+
(t1,t2)
723+
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b order by 1, 2, 3, 4, 5;
724+
a b a b a b
725+
NULL NULL 2 2 3 2
726+
NULL NULL 2 2 4 2
727+
4 2 1 2 3 2
728+
4 2 1 2 3 2
729+
4 2 1 2 3 2
730+
4 2 1 2 4 2
731+
4 2 1 2 4 2
732+
4 2 1 2 4 2
733+
show warnings;
734+
Level Code Message
735+
drop table if exists t1, t2, t3, t4;
736+
>>>>>>> 10647c9d733 (statstics: avoid unnecessary try when to sync load (#56614))

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,32 @@ FROM (
477477
) AS derived_table
478478
WHERE 16739493649928310215 MEMBER OF (derived_table.col_60767)
479479
OR NOT (JSON_CONTAINS(derived_table.col_60767, '6019730272580550835'));
480+
<<<<<<< HEAD
480481
set @@tidb_enable_global_index=0;
482+
=======
483+
484+
# TestIssue53766
485+
drop table if exists t0, t1;
486+
CREATE TABLE t0(c0 int);
487+
CREATE TABLE t1(c0 int);
488+
SELECT t0.c0, t1.c0 FROM t0 NATURAL JOIN t1 WHERE '1' AND (t0.c0 IN (SELECT c0 FROM t0));
489+
490+
# TestIssue56472
491+
drop table if exists t1, t2, t3, t4;
492+
CREATE TABLE t1 (a int, b int, c int);
493+
CREATE TABLE t2 (a int, b int, c int);
494+
CREATE TABLE t3 (a int, b int, c int);
495+
CREATE TABLE t4 (a int, b int, c int);
496+
INSERT INTO t1 VALUES (1,3,0), (2,2,0), (3,2,0);
497+
INSERT INTO t2 VALUES (3,3,0), (4,2,0), (5,3,0);
498+
INSERT INTO t3 VALUES (1,2,0), (2,2,0);
499+
INSERT INTO t4 VALUES (3,2,0), (4,2,0);
500+
CREATE INDEX idx_b ON t2(b);
501+
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
502+
FROM (t3,t4)
503+
LEFT JOIN
504+
(t1,t2)
505+
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b order by 1, 2, 3, 4, 5;
506+
show warnings;
507+
drop table if exists t1, t2, t3, t4;
508+
>>>>>>> 10647c9d733 (statstics: avoid unnecessary try when to sync load (#56614))

0 commit comments

Comments
 (0)