Skip to content

feat: himport managed fieldsets - #2159

Merged
PavelPashov merged 6 commits into
redis:mainfrom
PavelPashov:feat/himport-managed-fieldsets
Jul 31, 2026
Merged

PavelPashov merged 6 commits into
redis:mainfrom
PavelPashov:feat/himport-managed-fieldsets

Conversation

@PavelPashov

@PavelPashov PavelPashov commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Changes the command send path for Redis, Cluster, and pipelines and introduces async gating around managed writes; behavior is experimental and documented ordering caveats apply, but coverage is broad.

Overview
Adds experimental HIMPORT support so clients can declare long-lived fieldsets via himportFieldsets on standalone Redis and Cluster, then issue HIMPORT SET without manually tracking PREPARE on every connection.

A new HimportCoordinator intercepts managed SET commands (and matching pipelines), issues internal HIMPORT PREPARE during connect/handshake and after reconnect or RESET, coalesces preparation per connection, and retries once when Redis reports a missing fieldset. Cluster wiring fans PREPARE / DISCARD / DISCARDALL to all masters, re-prepares on role changes and promoted nodes, and delays ASK redirects until the target master is ready. Unconfigured fieldsets and non-managed pipelines stay explicit/manual.

Also adds Command.isSettled (separate from isResolved) so timeouts and HIMPORT recovery do not race settled commands, exports HIMPORT typings and return types, documents the feature in the README with examples/himport.js, and adds functional/unit coverage.

Reviewed by Cursor Bugbot for commit ba2b6dc. Bugbot is set up for automated code reviews on this repo. Configure here.

@PavelPashov
PavelPashov requested a review from nkaradzhov July 31, 2026 09:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01115e6257

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lib/himport/HimportCoordinator.ts Resolved
Comment thread lib/autoPipelining.ts
"client",
"hello",
"readonly",
"himport",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize HIMPORT before skipping autopipelining

With enableAutoPipelining enabled, a user can issue the command as cluster.call("HIMPORT", "PREPARE", ...); this lowercase skip-list entry is compared case-sensitively, so the uppercase control command is auto-pipelined instead of going through the new direct cluster fan-out path. In that scenario only the selected pipeline node receives PREPARE, and later HIMPORT SET calls routed to other masters can fail with a missing fieldset; normalize commandName before checking this list.

AGENTS.md reference: AGENTS.md:L94-L94

Useful? React with 👍 / 👎.

Comment thread lib/autoPipelining.ts Resolved
Comment thread lib/Command.ts Resolved
* - _since_: 8.10.0
*/
himport(...args: [subcommand: 'PREPARE', fieldsetName: string | Buffer, ...fields: (string | Buffer)[], callback: Callback<'OK'>]): Result<'OK', Context>;
himport(...args: [subcommand: 'PREPARE', fieldsetName: string | Buffer, ...fields: (string | Buffer)[]]): Result<'OK', Context>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require a non-empty HIMPORT PREPARE field list

This overload lets redis.himport("PREPARE", "fieldset") type-check because the rest tuple can be empty, but Redis expects at least one field after the fieldset name. TS users can therefore compile calls that only fail at runtime; model the generator input as a required first field plus the remaining fields, and apply the same non-empty shape to SET values.

Useful? React with 👍 / 👎.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 2b4c6bf. Configure here.

Comment thread lib/himport/HimportCoordinator.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba2b6dc869

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +230 to +231
for (const command of commands) {
const preparation = this.prepareCommand(connection, command);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle RESET before pipelined HIMPORT SET

When a pipeline contains RESET before a configured HIMPORT SET, this loop either decides no preparation is needed because the cache is already prepared, or sends PREPARE before the batch; Redis then executes RESET ahead of the SET and clears the session fieldsets, so the SET fails with a missing-fieldset error and the pipeline has no recovery path. Please treat earlier RESET (and fieldset-discarding HIMPORT controls) in the same pipeline as invalidating when deciding how to prepare the managed SET.

Useful? React with 👍 / 👎.

Comment on lines +516 to +518
const preparation = binding.coordinator.prepareCommands(connection, commands);
if (!preparation) {
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reprepare pipelined HIMPORT SET after reconnect

When a managed HIMPORT pipeline is executed while the underlying Redis connection is reconnecting, this can return false because the old session cache still says the fieldset is prepared, so the batch is only queued in the offline queue. The reconnect path resets the HIMPORT session in beginSession, but offline pipeline replay calls sendCommand with a stream and bypasses HIMPORT interception, so the SET is written to the new physical connection without a matching PREPARE; invalidate on close or force preparation/recheck before replaying the streamed pipeline.

Useful? React with 👍 / 👎.

@PavelPashov
PavelPashov merged commit 729f174 into redis:main Jul 31, 2026
22 checks passed
@PavelPashov
PavelPashov deleted the feat/himport-managed-fieldsets branch July 31, 2026 14:41
github-actions Bot pushed a commit that referenced this pull request Jul 31, 2026
# [6.0.0](v5.11.1...v6.0.0) (2026-07-31)

* Add RESP3 ([#2127](#2127)) ([5d0862e](5d0862e))

### Bug Fixes

* clear stale socket timeout on reconnect ([#2148](#2148)) ([6455dbe](6455dbe))
* **cluster:** recreate stale connection on circular MOVED ([#2135](#2135)) ([08c8967](08c8967))
* **cluster:** validate MOVED slot to prevent Array.prototype pollution ([#2151](#2151)) ([9618206](9618206)), closes [#1267](#1267)
* **command:** serialize large integer arguments in decimal notation ([#2136](#2136)) ([09b8d04](09b8d04))
* **redis:** keep reconnecting when connection closes during client setup ([#2099](#2099)) ([#2123](#2123)) ([f9a66bc](f9a66bc))
* **sentinel:** preserve zero preferred slave priority ([#2129](#2129)) ([a3f9f2d](a3f9f2d))
* **tracing:** redact values for GETSET and PSETEX ([#2134](#2134)) ([832765d](832765d))
* **types:** export ScanStreamOptions, RedisStatus and ClusterStatus ([#2158](#2158)) ([cf3bf71](cf3bf71))

### Features

* add LMOVEM and BLMOVEM command support ([#2144](#2144)) ([c26af46](c26af46))
* add Redis 8.10 set cardinality commands ([#2143](#2143)) ([301099b](301099b))
* himport managed fieldsets ([#2159](#2159)) ([729f174](729f174))
* improve default connection resilience ([#2160](#2160)) ([6d0716e](6d0716e))
* support MAXCOUNT and MAXSIZE for stream reads ([#2142](#2142)) ([ae5e41b](ae5e41b))

### BREAKING CHANGES

* ioredis now requires Node.js 20 or newer and uses RESP3 by default. Set `protocol: 2` to retain the v5 wire protocol.
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant