From 6d90e81a2ea1e21491d1acf5e7726865f9122607 Mon Sep 17 00:00:00 2001 From: crazycs Date: Tue, 2 Jul 2019 22:54:18 +0800 Subject: [PATCH] *: fix oom action cancel bug (#10993) (#11016) --- executor/executor_test.go | 12 ++++++++++++ store/tikv/coprocessor.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/executor/executor_test.go b/executor/executor_test.go index 73af6b58b0f4d..796d89e28c815 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -3681,6 +3681,18 @@ func (s *testOOMSuite) TestDistSQLMemoryControl(c *C) { tk.Se.GetSessionVars().MemQuotaDistSQL = -1 } +func (s *testSuite) TestOOMPanicAction(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("create table t (a int primary key, b double);") + tk.MustExec("insert into t values (1,1)") + config.GetGlobalConfig().OOMAction = config.OOMActionCancel + tk.MustExec("set @@tidb_mem_quota_query=1;") + err := tk.QueryToErr("select sum(b) from t group by a;") + c.Assert(err, NotNil) +} + type oomCapturer struct { zapcore.Core tracker string diff --git a/store/tikv/coprocessor.go b/store/tikv/coprocessor.go index b3e1956116daf..34115be88c280 100644 --- a/store/tikv/coprocessor.go +++ b/store/tikv/coprocessor.go @@ -617,7 +617,7 @@ func (worker *copIteratorWorker) handleTask(bo *Backoffer, task *copTask, respCh zap.Stack("stack trace")) resp := &copResponse{err: errors.Errorf("%v", r)} // if panic has happened, set checkOOM to false to avoid another panic. - worker.sendToRespCh(resp, task.respChan, false) + worker.sendToRespCh(resp, respCh, false) } }()