# Manticore Search 4.0.2: full columnar store support, auto index compaction, locks system revamp, pseudo sharding

### Major new features
- **完全支持 [Manticore Columnar Library](https://github.com/manticoresoftware/columnar)**。之前 Manticore Columnar Library 仅支持普通索引。现在支持：
- 在实时索引中用于 `INSERT`、`REPLACE`、`DELETE`、`OPTIMIZE`
- 在复制中
- 在 `ALTER` 中
- 在 `indextool --check` 中
- **自动索引压缩** ([\#478](https://github.com/manticoresoftware/manticoresearch/issues/478))。终于你不需要手动调用 OPTIMIZE 或通过 crontask 或其他自动化方式。Manticore 现在会自动为你执行。你可以通过 [optimize_cutoff](https://manual.manticoresearch.com/Server_settings/Searchd#optimize_cutoff) 设置默认压缩阈值。
- **分块快照和锁系统升级**。这些更改乍看之下可能对外部不可见，但它们显著改善了实时索引中许多操作的行为。简而言之，之前大多数 Manticore 数据操作依赖于锁，现在我们使用磁盘分块快照。具体来说：
    - 读取操作（例如 SELECT、复制）通过快照执行
    - 仅改变内部索引结构而不修改模式/文档的操作（例如合并 RAM 段、保存磁盘分块、合并磁盘分块）通过只读快照执行，并最终替换现有分块
    - UPDATE 和 DELETE 针对现有分块执行，但在合并的情况下，写入会被收集并应用于新分块
    - UPDATE 为每个分块按顺序获取独占锁。合并在进入从分块收集属性的阶段时获取共享锁。因此，同一时间只有一个（合并或更新）操作可以访问分块的属性。
    - 当合并进入需要属性的阶段时，会设置一个特殊标志。当 UPDATE 完成时，它会检查该标志，如果已设置，整个更新会被存储在一个特殊集合中。最后当合并完成时，它会将设置的更新应用到新生成的磁盘分块上
    - ALTER 通过独占锁运行
    - 复制作为常规读取操作运行，但此外在 SST 之前保存属性并禁止在 SST 期间更新
- **[ALTER](https://manual.manticoresearch.com/Updating_index_schema) 可以添加/删除全文字段**。之前只能添加/删除属性。
- 🔬 **实验性功能：伪分片用于全扫描查询** - 允许并行执行任何非全文搜索查询。现在只需启用新选项 [searchd.pseudo_sharding](https://manual.manticoresearch.com/Server_settings/Searchd#pseudo_sharding)，即可期待非全文搜索查询的响应时间降低至 `CPU 核心数`。请注意，它可能会轻松占用所有现有 CPU 核心，因此如果你不仅关注延迟，还关注吞吐量，请谨慎使用。



### Minor changes
- Linux Mint 和 Ubuntu Hirsute Hippo 通过 [APT 仓库](https://manual.manticoresearch.com/Installation/Debian_and_Ubuntu#APT-repository) 支持
- 在某些情况下，通过 HTTP 在大型索引中通过 ID 更新更快（取决于 ID 分布）
- [systemd 的自定义启动标志](https://manual.manticoresearch.com/Starting_the_server/Linux#Custom-startup-flags-using-systemd)。现在如果你需要以特定启动标志运行 Manticore，无需手动启动 searchd
- 新增函数 [LEVENSHTEIN()](https://manual.manticoresearch.com/Functions/String_functions#LEVENSHTEIN%28%29) 用于计算 Levenshtein 距离
- 新增 [searchd 启动标志](https://manual.manticoresearch.com/Starting_the_server/Manually#searchd-command-line-options) `--replay-flags=ignore-trx-errors` 和 `--replay-flags=ignore-all-errors`，以便在 binlog 损坏时仍可启动 searchd
- [\#621](https://github.com/manticoresoftware/manticoresearch/issues/621) - 暴露 RE2 的错误
- 对由本地普通索引组成的分布式索引，[COUNT(DISTINCT)](https://manual.manticoresearch.com/Searching/Grouping#COUNT%28DISTINCT-field%29) 更加准确
- [FACET DISTINCT](https://manual.manticoresearch.com/Searching/Faceted_search#Faceting-without-duplicates) 用于在进行分面搜索时去除重复项
- [精确形式修饰符](https://manual.manticoresearch.com/Searching/Full_text_matching/Operators#Exact-form-modifier) 现在不再需要 [形态](https://manual.manticoresearch.com/Creating_a_table/NLP_and_tokenization/Morphology#morphology)，并且适用于启用了 [前缀/中缀](https://manual.manticoresearch.com/Creating_a_table/NLP_and_tokenization/Wildcard_searching_settings#Wildcard-searching-settings) 搜索的索引



### 突破性变更
- 新版本可以读取旧索引，但旧版本无法读取 Manticore 4 的索引
- 移除了按 id 的隐式排序。如需排序请显式指定
- `charset_table` 的默认值从 `0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F, U+401->U+451, U+451` 更改为 `non_cjk`
- `OPTIMIZE` 会自动执行。如果不需要请确保在配置文件的 `searchd` 部分设置 `auto_optimize=0`
- [\#616](https://github.com/manticoresoftware/manticoresearch/issues/616) `ondisk_attrs_default` 已弃用，现在已被移除
- 对于贡献者：我们现在使用 Clang 编译器进行 Linux 构建，根据我们的测试，它可以构建更快的 Manticore Search 和 Manticore Columnar Library
- 如果在搜索查询中未指定 [max\_matches](https://manual.manticoresearch.com/Searching/Options#max_matches)，它会根据新列式存储的性能隐式更新为最低所需值。这可能会影响 [SHOW META](https://manual.manticoresearch.com/Profiling_and_monitoring/SHOW_META#SHOW-META) 中的指标 `total`，但不会影响 `total_found`，后者是实际找到的文档数量。



### 从 Manticore 3 迁移
- 确保你干净地停止 Manticore 3：
- `/var/lib/manticore/binlog/` 目录中不应有 binlog 文件（目录中应仅包含 `binlog.meta`）
- 否则 Manticore 4 将无法运行用于回放 binlog 的索引
- 新版本可以读取旧索引，但旧版本无法读取 Manticore 4 的索引，因此如果你希望轻松回滚新版本，请确保进行备份
- 如果你运行的是复制集群，请确保：
- 首先干净地停止所有节点
- 然后使用 `--new-cluster` 参数启动最后停止的节点（在 Linux 中运行工具 `manticore_new_cluster`）。
- 了解更多关于 [重启集群](https://manual.manticoresearch.com/Creating_a_cluster/Setting_up_replication/Restarting_a_cluster#Restarting-a-cluster) 的详细信息



### 修复
- 修复了许多复制问题：
- [696f8649](https://github.com/manticoresoftware/manticoresearch/commit/696f8649535f2b5285b878c9581c0d2b1139ae09) - 修复了在 joiner 节点上进行 SST 时的崩溃；在 joiner 节点写入文件块时添加了 sha1 验证以加快索引加载速度；在 joiner 节点加载索引时添加了已更改索引文件的轮换；当活动索引被来自 donor 节点的新索引替换时，添加了在 joiner 节点删除索引文件；在 donor 节点添加了用于发送文件和块的复制日志点
- [b296c55a](https://github.com/manticoresoftware/manticoresearch/commit/b296c55af68314a8fc66f8b104e7301d673c3b68) - 在 JOIN CLUSTER 时地址不正确导致崩溃
- [418bf880](https://github.com/manticoresoftware/manticoresearch/commit/418bf880a5e05ffbb68f311a1c23006a9df3220e) - 在初始复制大型索引时，joining 节点可能会失败并显示 `ERROR 1064 (42000): invalid GTID, (null)`，donor 节点在另一个节点加入时可能变得无响应
- [6fd350d2](https://github.com/manticoresoftware/manticoresearch/commit/6fd350d28e4905211cf8a7298cbf7cdda101c83d) - 大型索引的哈希计算错误可能导致复制失败
- [\#615](https://github.com/manticoresoftware/manticoresearch/issues/615) - 集群重启时复制失败
- [\#574](https://github.com/manticoresoftware/manticoresearch/issues/574) - `indextool --help` 不显示参数 `--rotate`
- [\#578](https://github.com/manticoresoftware/manticoresearch/issues/578) - searchd 在空闲约一天后 CPU 使用率过高
- [\#587](https://github.com/manticoresoftware/manticoresearch/issues/587) - 立即刷新 .meta
- [\#617](https://github.com/manticoresoftware/manticoresearch/issues/617) - manticore.json 被清空
- [\#618](https://github.com/manticoresoftware/manticoresearch/issues/618) - searchd --stopwait 在 root 下失败。它还修复了 systemctl 的行为（之前它会显示 ExecStop 的失败且未等待足够时间让 searchd 正常停止）
- [\#619](https://github.com/manticoresoftware/manticoresearch/issues/619) - INSERT/REPLACE/DELETE 与 SHOW STATUS。`command_insert`、`command_replace` 等显示了错误的指标
- [\#620](https://github.com/manticoresoftware/manticoresearch/issues/620) - 普通索引的 `charset_table` 有错误的默认值
- [8f753688](https://github.com/manticoresoftware/manticoresearch/commit/8f7536887d4b58a5bab5647fc067b2d0482c2038) - 新的磁盘块不会被锁定
- [\#607](https://github.com/manticoresoftware/manticoresearch/issues/607) - 当无法通过名称解析节点时，Manticore 集群节点崩溃
- [\#623](https://github.com/manticoresoftware/manticoresearch/issues/623) - 更新索引的复制可能导致未定义状态
- [ca03d228](https://github.com/manticoresoftware/manticoresearch/commit/ca03d2280c5197e9b311f0f03f551e3b702a8130) - 在对带有 json 属性的普通索引源进行索引时，indexer 可能会挂起
- [53c75305](https://github.com/manticoresoftware/manticoresearch/commit/53c753054558ff3f82c7af365273d32537c5338b) - 修复了 PQ 索引上的不等表达式过滤器
- [ccf94e02](https://github.com/manticoresoftware/manticoresearch/commit/ccf94e022ba6763d6286ab5bac767b6f6a846846) - 修复了列表查询中超过 1000 个匹配项的窗口选择。`SELECT * FROM pq ORDER BY id desc LIMIT 1000 , 100 OPTION max_matches=1100` 之前无法正常工作
- [a0483fe9](https://github.com/manticoresoftware/manticoresearch/commit/a0483fe9bef3c45dffe96f5df4f4382aee29c072) - 对 Manticore 的 HTTPS 请求可能导致类似 "max packet size(8388608) exceeded" 的警告
