Skip to content

Commit

Permalink
Merge branch 'master' into pr/5929
Browse files Browse the repository at this point in the history
  • Loading branch information
yikeke committed Apr 6, 2021
2 parents 7b74be7 + 5e4879c commit 2458bde
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 17 deletions.
1 change: 1 addition & 0 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@
+ v5.0
- [5.0.0-rc](/releases/release-5.0.0-rc.md)
+ v4.0
- [4.0.12](/releases/release-4.0.12.md)
- [4.0.11](/releases/release-4.0.11.md)
- [4.0.10](/releases/release-4.0.10.md)
- [4.0.9](/releases/release-4.0.9.md)
Expand Down
2 changes: 1 addition & 1 deletion configure-memory-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ aliases: ['/docs-cn/dev/configure-memory-usage/','/docs-cn/dev/how-to/configure/

```
# Valid options: ["log", "cancel"]
oom-action = "log"
oom-action = "cancel"
```

- 如果上面的配置项使用的是 "log",那么当一条 SQL 的内存使用超过一定阈值(由 session 变量 `tidb_mem_quota_query` 来控制)后,TiDB 会在 log 文件中打印一条 LOG,然后这条 SQL 继续执行,之后如果发生了 OOM 可以在 LOG 中找到对应的 SQL。
Expand Down
137 changes: 137 additions & 0 deletions releases/release-4.0.12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
title: TiDB 4.0.12 Release Notes
---

# TiDB 4.0.12 Release Notes

发版日期:2021 年 4 月 2 日

TiDB 版本:4.0.12

## 新功能

+ TiFlash

- 新增工具用于检测当前 `tiflash replica` 的状态

## 改进提升

+ TiDB

- 优化 `EXPLAIN` 语句在 `batch cop` 模式下的输出信息 [#23164](https://github.com/pingcap/tidb/pull/23164)
-`EXPLAIN` 语句的输出中,为无法下推到存储层的表达式增加告警信息 [#23020](https://github.com/pingcap/tidb/pull/23020)
- 调整 DDL 包中部分 `Execute`/`ExecRestricted` 的使用为安全 API (2) [#22935](https://github.com/pingcap/tidb/pull/22935)
- 调整 DDL 包中部分 `Execute`/`ExecRestricted` 的使用为安全 API (1) [#22929](https://github.com/pingcap/tidb/pull/22929)
- 添加 `optimization-time``wait-TS-time` 到慢日志中 [#22918](https://github.com/pingcap/tidb/pull/22918)
- 支持从 `infoschema.partitions` 表中查询 `partition_id` [#22489](https://github.com/pingcap/tidb/pull/22489)
- 添加 `last_plan_from_binding` 以帮助用户了解 SQL 执行计划是否与 binding 的 hint 相匹配 [#21430](https://github.com/pingcap/tidb/pull/21430)
- 支持在没有 `pre-split` 选项时也能执行 `TRUNCATE` 表操作 [#22872](https://github.com/pingcap/tidb/pull/22872)
-`str_to_date` 表达式添加三种新的格式限定符 [#22812](https://github.com/pingcap/tidb/pull/22812)
- 在 metrics 监控中记录 `PREPARE` 执行失败的问题为 `Failed Query OPM` [#22672](https://github.com/pingcap/tidb/pull/22672)
- 当设置了 `tidb_snapshot` 时,不对 `PREPARE` 语句的执行报错 [#22641](https://github.com/pingcap/tidb/pull/22641)

+ TiKV

- 消除短时间内大量重连接的现象 [#9879](https://github.com/tikv/tikv/pull/9879)
- 对多 Tombstones 场景下的写操作和 Batch Get 进行优化 [#9729](https://github.com/tikv/tikv/pull/9729)
-`leader-transfer-max-log-lag` 的默认值改为 `128`,以增加切换 leader 的成功率 [#9605](https://github.com/tikv/tikv/pull/9605)

+ PD

- 只有当 `pending-peer``down-peer` 变更时才更新 Region Cache,减少心跳更新压力 [#3471](https://github.com/pingcap/pd/pull/3471)
- 防止 `split-cache` 中的 Region 成为合并的目标 [#3459](https://github.com/pingcap/pd/pull/3459)

+ TiFlash

- 优化配置文件并删除无用项
- 减小 TiFlash 二进制文件大小
- 使用自适应的 GC 策略以减少内存使用

+ Tools

+ TiCDC

- 若任务的暂停同步时间超过 1 天,再次启动该任务时需要二次确认 [#1497](https://github.com/pingcap/ticdc/pull/1497)
- 为 Old Value 功能添加监控面板 [#1571](https://github.com/pingcap/ticdc/pull/1571)

+ Backup & Restore (BR)

- 记录 `HTTP_PROXY``HTTPS_PROXY` 环境变量 [#827](https://github.com/pingcap/br/pull/827)
- 提升多表场景下的备份性能 [#745](https://github.com/pingcap/br/pull/745)
- 在 service safe point 检查失败时报告错误 [#826](https://github.com/pingcap/br/pull/826)
-`backupmeta` 中记录集群版本和 BR 版本 [#803](https://github.com/pingcap/br/pull/803)
- 遇到外部存储错误时,重试备份以便提高备份成功率 [#851](https://github.com/pingcap/br/pull/851)
- 减少 BR 备份的内存使用 [#886](https://github.com/pingcap/br/pull/886)

+ TiDB Lightning

- 运行 TiDB Lightning 前检查 TiDB 集群版本以防止未知错误 [#787](https://github.com/pingcap/br/pull/787)
- 在遇到 cancel 错误时及时退出 [#867](https://github.com/pingcap/br/pull/867)
- 添加 `tikv-importer.engine-mem-cache-size``tikv-importer.local-writer-mem-cache-size` 参数以便调整内存占用和性能之间的平衡 [#866](https://github.com/pingcap/br/pull/866)
- Local-backend 并发运行 `batch split region` 以提高导入速度 [#868](https://github.com/pingcap/br/pull/868)
- 从 S3 存储导入数据时,TiDB Lightning 不再要求 `s3:ListBucket` 权限 [#919](https://github.com/pingcap/br/pull/919)
- 从 checkpoint 恢复时,TiDB Lightning 会继续使用之前的导入引擎 [#924](https://github.com/pingcap/br/pull/924)

## Bug 修复

+ TiDB

- 修复当变量为十六进制字面量时,`get` 表达式出错的问题 [#23372](https://github.com/pingcap/tidb/pull/23372)
- 修复生成 `Enum``Set` 类型的快速执行计划时使用了错误 Collation 的问题 [#23292](https://github.com/pingcap/tidb/pull/23292)
- 修复 `nullif``is-null` 表达式一起使用时可能出现结果错误的问题 [#23279](https://github.com/pingcap/tidb/pull/23279)
- 修复自动搜集统计信息在规定时间窗口外被触发的问题 [#23219](https://github.com/pingcap/tidb/pull/23219)
- 修复 `point-get` 计划中 `CAST` 函数可能忽略错误的问题 [#23211](https://github.com/pingcap/tidb/pull/23211)
- 修复 `CurrentDB` 为空时 SPM 可能不生效的问题 [#23209](https://github.com/pingcap/tidb/pull/23209)
- 修复 IndexMerge 执行计划中可能出现错误过滤条件的问题 [#23165](https://github.com/pingcap/tidb/pull/23165)
- 修复 `NULL` 常量的返回类型中可能出现 `NotNullFlag` 的问题 [#23135](https://github.com/pingcap/tidb/pull/23135)
- 修复 Text 类型可能遗漏处理 Collation 的问题 [#23092](https://github.com/pingcap/tidb/pull/23092)
- 修复 Range 分区表处理 `IN` 表达式可能出错的问题 [#23074](https://github.com/pingcap/tidb/pull/23074)
- 修复将 TiKV 标记为 Tombstone 后,在相同地址和端口启动不同 StoreID 的新 TiKV 会持续返回 `StoreNotMatch` 的问题 [#23071](https://github.com/pingcap/tidb/pull/23071)
- INT 类型为 `NULL` 且和 `YEAR` 进行比较时不进行类型调整 [#22844](https://github.com/pingcap/tidb/pull/22844)
- 修复当表含有 `auto_random` 列 load data 时失去连接的问题 [#22736](https://github.com/pingcap/tidb/pull/22736)
- 修复取消 DDL 操作 panic 时可能阻塞其他 DDL 操作的问题 [#23297](https://github.com/pingcap/tidb/pull/23297)
- 修复进行 `NULL``YEAR` 比较时可能生成错误 key range 的问题 [#23104](https://github.com/pingcap/tidb/pull/23104)
- 修复创建视图成功但是使用时可能失败的问题 [#23083](https://github.com/pingcap/tidb/pull/23083)

+ TiKV

- 修复 `IN` 表达式没有正确处理有符号和无符号整型数的问题 [#9850](https://github.com/tikv/tikv/pull/9850)
- 修复 Ingest 操作不可重入问题 [#9779](https://github.com/tikv/tikv/pull/9779)
- 修复 TiKV 在处理 JSON 向字符串转换时空格缺失的问题 [#9666](https://github.com/tikv/tikv/pull/9666)

+ PD

- 修复在 store 缺失 label 的情况下隔离级别错误的问题 [#3474](https://github.com/pingcap/pd/pull/3474)

+ TiFlash

- 修复当 `binary` 列的默认值前后包含 `0` 字节时查询结果错误的问题
- 修复当数据库名称中包含特殊字符时无法同步数据的问题
- 修复 `IN` 表达式中出现 `Decimal` 列时查询结果错误的问题
- 修复 Grafana 中已打开文件数指标过高的问题
- 修复当表达式中包含 `Timestamp` 类型时查询结果错误的问题
- 修复处理 `FROM_UNIXTIME` 表达式时可能发生的无响应的问题
- 修复字符串转换为整数结果不正确的问题
- 修复 `like` 表达式可能返回错误结果的问题

+ Tools

+ TiCDC

- 修复 `resolved ts` 时间乱序的问题 [#1464](https://github.com/pingcap/ticdc/pull/1464)
- 修复由于网络不稳定而导致的表调度出错引发的数据丢失问题 [#1508](https://github.com/pingcap/ticdc/pull/1508)
- 修复终止 processor 时不能及时释放资源的问题 [#1547](https://github.com/pingcap/ticdc/pull/1547)
- 修复因事务计数器未正确更新而导致下游数据库链接可能泄露的问题 [#1524](https://github.com/pingcap/ticdc/pull/1524)
- 修复因 PD 抖动时多个 owner 共存可能导致数据表丢失的问题 [#1540](https://github.com/pingcap/ticdc/pull/1540)

+ Backup & Restore (BR)

- 修复 `WalkDir` 在目标为 bucket name 的时候无返回值的问题 [#733](https://github.com/pingcap/br/pull/733)
- 修复 `status` 端口无 TLS 的问题 [#839](https://github.com/pingcap/br/pull/839)

+ TiDB Lightning

- 修复 TiKV Importer 可能忽略文件已存在的错误 [#848](https://github.com/pingcap/br/pull/848)
- 修复 TiDB Lightning 可能使用错误的时间戳而读到错误数据的问题 [#850](https://github.com/pingcap/br/pull/850)
- 修复 TiDB Lightning 非预期退出时可能造成 checkpoint 文件损坏的问题 [#889](https://github.com/pingcap/br/pull/889)
- 修复由于忽略 `cancel` 错误而可能导致的数据错误的问题 [#874](https://github.com/pingcap/br/pull/874)
1 change: 1 addition & 0 deletions releases/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ TiDB 历史版本发布声明如下:

## 4.0

- [4.0.12](/releases/release-4.0.12.md)
- [4.0.11](/releases/release-4.0.11.md)
- [4.0.10](/releases/release-4.0.10.md)
- [4.0.9](/releases/release-4.0.9.md)
Expand Down
3 changes: 2 additions & 1 deletion telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ TiDB、TiUP 及 TiDB Dashboard 默认会收集使用情况信息,并将这些
### TiDB

当 TiDB 遥测功能开启时,TiDB 集群将会以 24 小时为周期收集使用情况信息并分享给 PingCAP,包括(但不限于):
当 TiDB 遥测功能开启时,TiDB 集群将会以 6 小时为周期收集使用情况信息并分享给 PingCAP,包括(但不限于):

- 随机生成的遥测标示符
- 集群的部署情况,包括各个组件所在的硬件信息(CPU、内存、磁盘)、组件版本号、操作系统版本号等
- 系统组件的使用情况,例如 Async Commit 功能是否有被使用

可以通过执行以下 SQL 语句查看 TiDB 收集的使用情况信息内容:

Expand Down
4 changes: 0 additions & 4 deletions tidb-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ TiDB 配置文件比命令行参数支持更多的选项。你可以在 [config/

### `oom-action`

> **警告:**
>
> 目前 `oom-action` 为实验功能,会对写入过程中的内存进行统计。如果用户希望根据该特性取消写入操作,不建议在生产环境中将参数值配置为 `cancel`
+ 当 TiDB 中单条 SQL 的内存使用超出 `mem-quota-query` 限制且不能再利用临时磁盘时的行为。
+ 默认值:"log"
+ 目前合法的选项为 ["log", "cancel"]。设置为 "log" 时,仅输出日志。设置为 "cancel" 时,取消执行该 SQL 操作,并输出日志。
Expand Down
1 change: 1 addition & 0 deletions tiflash/tiflash-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ delta_index_cache_size = 0
data-dir = proxy 数据存储路径
config = proxy 配置文件路径
log-file = proxy log 路径
log-level = proxy log 级别,默认为 "info"
status-addr = 拉取 proxy metrics|status 信息的监听地址
advertise-status-addr = 外部访问 status-addr 的地址,不填则默认是 status-addr

Expand Down
56 changes: 45 additions & 11 deletions tiflash/use-tiflash.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ TiSpark 目前提供类似 TiDB 中 engine 隔离的方式读取 TiFlash,方
## TiFlash 支持的计算下推
> **注意:**
>
> TiDB 4.0.2 版本之前,TiFlash 不支持 TiDB 新排序规则框架,所以在 TiDB 开启[新框架下的排序规则支持](/character-set-and-collation.md#新框架下的排序规则支持)后不支持任何表达式的下推,TiDB 4.0.2 以及后续的版本取消了这个限制。
TiFlash 支持谓词、聚合下推计算以及表连接,下推的计算可以帮助 TiDB 进行分布式加速。暂不支持的计算类型是 `Full Outer Join` 和 `DISTINCT COUNT`,会在后续版本逐步优化。
目前下推连接 (`Join`) 的功能需要通过以下会话变量开启(暂不支持 `Full Outer Join`):
Expand Down Expand Up @@ -277,14 +273,52 @@ mysql> explain select count(*) from customer c join nation n on c.c_nationkey=n.

在执行计划中,出现了 `ExchangeReceiver``ExchangeSender` 算子。该执行计划表示 `nation` 表读取完毕后,经过 `ExchangeSender` 算子广播到各个节点中,与 `customer` 表先后进行 `HashJoin``HashAgg` 操作,再将结果返回至 TiDB 中。

> **注意:**
>
> MPP 模式不支持如下功能:
>
> - 不支持分区表,对于带有分区表的查询默认不选择 MPP 模式。
> - 在配置项 `new_collations_enabled_on_first_bootstrap`(/tidb-configuration-file.md#new_collations_enabled_on_first_bootstrap) 的值为 `true` 时,MPP 不支持 join 的连接键类型为字符串或 `group by` 聚合运算时列类型为字符串的情况。在处理这两类查询时,默认不选择 MPP 模式。
TiFlash 提供了两个全局/会话变量决定是否选择 Broadcast Hash Join,分别为:

- [`tidb_broadcast_join_threshold_size`](/system-variables.md#tidb_broadcast_join_threshold_count-从-v50-版本开始引入),单位为 bytes。如果表大小(字节数)小于该值,则选择 Broadcast Hash Join 算法。否则选择 Shuffled Hash Join 算法。
- [`tidb_broadcast_join_threshold_count`](/system-variables.md#tidb_broadcast_join_threshold_count-从-v50-版本开始引入),单位为行数。如果 join 的对象为子查询,优化器无法估计子查询结果集大小,在这种情况下通过结果集行数判断。如果子查询的行数估计值小于该变量,则选择 Broadcast Hash Join 算法。否则选择 Shuffled Hash Join 算法。

## 注意事项

TiFlash 目前尚不支持的一些功能,与原生 TiDB 可能存在不兼容的问题,具体如下:

* TiFlash 计算层:
* 不支持检查溢出的数值。例如将两个 `BIGINT` 类型的最大值相加 `9223372036854775807 + 9223372036854775807`,该计算在 TiDB 中预期的行为是返回错误 `ERROR 1690 (22003): BIGINT value is out of range`,但如果该计算在 TiFlash 中进行,则会得到溢出的结果 `-2` 且无报错。
* 不支持窗口函数。
* 不支持从 TiKV 读取数据。
* 目前 TiFlash 中的 `sum` 函数不支持传入字符串类型的参数,但 TiDB 在编译时无法检测出这种情况。所以当执行类似于 `select sum(string_col) from t` 的语句时,TiFlash 会报错 `[FLASH:Coprocessor:Unimplemented] CastStringAsReal is not supported.`。要避免这类报错,需要手动把 SQL 改写成 `select sum(cast(string_col as double)) from t`
* TiFlash 目前的 Decimal 除法计算和 TiDB 存在不兼容的情况。例如在进行 Decimal 相除的时候,TiFlash 会始终按照编译时推断出来的类型进行计算,而 TiDB 则在计算过程中采用精度高于编译时推断出来的类型。这导致在一些带有 Decimal 除法的 SQL 语句在 TiDB + TiKV 上的执行结果会和 TiDB + TiFlash 上的执行结果不一样,示例如下:

```sql
mysql> create table t (a decimal(3,0), b decimal(10, 0));
Query OK, 0 rows affected (0.07 sec)

mysql> insert into t values (43, 1044774912);
Query OK, 1 row affected (0.03 sec)

mysql> alter table t set tiflash replica 1;
Query OK, 0 rows affected (0.07 sec)

mysql> set session tidb_isolation_read_engines='tikv';
Query OK, 0 rows affected (0.00 sec)

mysql> select a/b, a/b + 0.0000000000001 from t where a/b;
+--------+-----------------------+
| a/b | a/b + 0.0000000000001 |
+--------+-----------------------+
| 0.0000 | 0.0000000410001 |
+--------+-----------------------+
1 row in set (0.00 sec)

mysql> set session tidb_isolation_read_engines='tiflash';
Query OK, 0 rows affected (0.00 sec)

mysql> select a/b, a/b + 0.0000000000001 from t where a/b;
Empty set (0.01 sec)
```

以上示例中,在 TiDB 和 TiFlash 中,`a/b` 在编译期推导出来的类型都为 `Decimal(7,4)`,而在 `Decimal(7,4)` 的约束下,`a/b` 返回的结果应该为 `0.0000`。但是在 TiDB 中,`a/b` 运行期的精度比 `Decimal(7,4)` 高,所以原表中的数据没有被 `where a/b` 过滤掉。而在 TiFlash 中 `a/b` 在运行期也是采用 `Decimal(7,4)` 作为结果类型,所以原表中的数据被 `where a/b` 过滤掉了。

* TiFlash MPP 模式不支持如下功能:
* 不支持分区表,对于带有分区表的查询默认不选择 MPP 模式。
* 在配置项 [`new_collations_enabled_on_first_bootstrap`](/tidb-configuration-file.md#new_collations_enabled_on_first_bootstrap) 的值为 `true` 时,MPP 不支持 join 的连接键类型为字符串或 `group by` 聚合运算时列类型为字符串的情况。在处理这两类查询时,默认不选择 MPP 模式。

0 comments on commit 2458bde

Please sign in to comment.