From 6168fb2de6e934e9d35c69dd7f7593d29545945e Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Tue, 27 Feb 2024 11:13:43 +0800 Subject: [PATCH] docs: sync bull document --- site/docs/extensions/bull.md | 17 ++++++++-- .../current/extensions/bull.md | 33 ++++++++++++++++++- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/site/docs/extensions/bull.md b/site/docs/extensions/bull.md index e9fd81fe27ab..c7fe9c1c2fbe 100644 --- a/site/docs/extensions/bull.md +++ b/site/docs/extensions/bull.md @@ -812,10 +812,12 @@ export default { 原因是 redis 会对 key 做 hash 来确定存储的 slot,集群下这一步 @midwayjs/bull 的 key 命中了不同的 slot。 -解决办法是 task 里的 prefix 配置用 {} 包括,强制 redis 只计算 {} 里的hash,例如 `prefix: '{midway-task}'`。 +解决方案: task 里的 prefix 配置用 {} 包括,强制 redis 只计算 {} 里的hash,例如 `prefix: '{midway-task}'`。 ### 2、EVAL inside MULTI is not allowed 错误 +表现为 `queue.createBulk()`、`job.moveToFailed()` 等任务队列 API 调用无效,并出现下面的错误。 + ``` ReplyError: EXECABORT Transaction discarded because of previous errors. at parseError (/node_modules/redis-parser/lib/parser.js:179:12) @@ -831,6 +833,15 @@ ReplyError: EXECABORT Transaction discarded because of previous errors. } ``` -问题表现为 queue.createBulk()、job.moveToFailed() 等任务队列 API 调用无效,这些 API 依赖的 Redis Lua 脚本中使用了 EVAL 或者 EVALSHA。报错的原因是阿里云 Redis 使用代理模式连接时,会对 Lua 脚本调用做额外限制,包括不允许在 MULTI 事务中执行 EVAL 命令(),文档中还提到可以通过参数配置 script_check_enable 关闭这一校验,但是验证无效。 +::: tip + +常出现与使用阿里云 Redis 服务时。 + +::: + +由于这些 API 依赖的 Redis Lua 脚本中使用了 EVAL 或者 EVALSHA,阿里云 Redis 使用代理模式连接时,会对 Lua 脚本调用做额外限制,包括 [不允许在 MULTI 事务中执行 EVAL 命令](https://help.aliyun.com/zh/redis/support/usage-of-lua-scripts?#section-8f7-qgv-dlv),文档中还提到可以通过参数配置 script_check_enable 关闭这一校验,但是验证无效。 + +解决方案: -好在切换到直连模式可以解决这个问题,可以在阿里云控制台操作开启直连地址,由于直连模式需要客户端切换成集群模式,需要参考前文中的「Redis 集群」章节,切换成 defaultQueueOptions.createClient 配置方式。 +* 1、在阿里云控制台操作开启直连地址,将服务切换到直连模式 +* 2、客户端切换成集群模式,参考上述「Redis 集群」章节,切换配置方式 diff --git a/site/i18n/en/docusaurus-plugin-content-docs/current/extensions/bull.md b/site/i18n/en/docusaurus-plugin-content-docs/current/extensions/bull.md index e15aa9016a1b..f32c85c98927 100644 --- a/site/i18n/en/docusaurus-plugin-content-docs/current/extensions/bull.md +++ b/site/i18n/en/docusaurus-plugin-content-docs/current/extensions/bull.md @@ -809,5 +809,36 @@ This problem is basically clear, the problem will appear on the clustered versio The reason is that redis does hash on the key to determine the storage slot, and the key of @midwayjs/bull hits a different slot in this step under the cluster. -The workaround is to include {} in the prefix configuration of the task and force redis to only calculate the hash in {}, e.g. `prefix: '{midway-task}'`. +Solution: The prefix configuration in the task is included with {} to force redis to only calculate the hash in {}, for example `prefix: '{midway-task}'`. +### 2. EVAL inside MULTI is not allowed error + +This shows that task queue API calls such as `queue.createBulk()` and `job.moveToFailed()` are invalid and the following error occurs. + +``` +ReplyError: EXECABORT Transaction discarded because of previous errors. + at parseError (/node_modules/redis-parser/lib/parser.js:179:12) + at parseType (/node_modules/redis-parser/lib/parser.js:302:14) { + command: { name: 'exec', args: [] }, + previousErrors: [ + ReplyError: ERR 'EVAL' inside MULTI is not allowed + at parseError (/node_modules/redis-parser/lib/parser.js:179:12) + at parseType (/node_modules/redis-parser/lib/parser.js:302:14) { + command: [Object] + } + ] +} +``` + +::: tip + +Often occurs when using Alibaba Cloud Redis service. + +::: + +Since EVAL or EVALSHA are used in the Redis Lua scripts that these APIs depend on, when Alibaba Cloud Redis uses proxy mode to connect, additional restrictions will be placed on Lua script calls, including [EVAL commands are not allowed to be executed in MULTI transactions] (https:// help.aliyun.com/zh/redis/support/usage-of-lua-scripts?#section-8f7-qgv-dlv), the document also mentions that this verification can be turned off through parameter configuration script_check_enable, but the verification is invalid. + +Solution: + +* 1. Open the direct connection address in the Alibaba Cloud console and switch the service to direct connection mode. +* 2. Switch the client to cluster mode. Refer to the above "Redis Cluster" chapter to switch the configuration mode.