# Copyright 2023 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#TODO: mpp hang detect is disabled, so this test should not be used
#RETURN

mysql> drop table if exists test.t;
mysql> create table test.t(id int, value int);
mysql> alter table test.t set tiflash replica 1;

func> wait_table test t


mysql> insert into test.t values (1, 1),(1,2)

# ensure table is sync to tiflash
mysql> select table_schema,table_name,replica_count,location_labels,available from information_schema.tiflash_replica where table_schema='test' and table_name='t';
+--------------+------------+---------------+-----------------+-----------+
| table_schema | table_name | replica_count | location_labels | available |
+--------------+------------+---------------+-----------------+-----------+
| test         | t          |             1 |                 |         1 |
+--------------+------------+---------------+-----------------+-----------+
>> DBGInvoke __init_fail_point()

>> DBGInvoke __enable_fail_point(hang_in_execution)

mysql> set session tidb_isolation_read_engines='tiflash'; set session tidb_allow_mpp = 1; set session tidb_opt_cpu_factor=10000000; select count(*) from test.t;
ERROR 1105 (HY000) at line 1: other error for mpp stream: MPP Task canceled because it seems hangs

>> DBGInvoke __disable_fail_point(hang_in_execution)

mysql> drop table if exists test.t
