Skip to content

Enhance error handling and resync logic in stream module - #77

Open
twisti-dev wants to merge 1 commit into
masterfrom
chore/some-code-changes
Open

Enhance error handling and resync logic in stream module#77
twisti-dev wants to merge 1 commit into
masterfrom
chore/some-code-changes

Conversation

@twisti-dev

Copy link
Copy Markdown
Contributor

This pull request includes a version bump and several improvements and fixes across the Redis API and core modules. The most important changes address container deserialization safety, diagnostics for custom event publishing, cache refresh logic, error handling in sync structures, and improved handling of empty remote data.

Serialization and Deserialization Safety:

  • Added lower-bound guards (checkReadableElementBytes) to all container deserialization methods in byte-buf-extensions.kt to prevent malformed payloads from causing oversized allocations, improving security and robustness. [1] [2] [3] [4] [5] [6]

Diagnostics and Logging:

  • Introduced diagnostics for custom event publishing in RedisEventBusImpl, including limiting repeated logs and providing detailed information when events are published on binary channels or when decoding fails. [1] [2] [3] [4]

Cache and Data Consistency Improvements:

  • Improved SimpleRedisCacheImpl refresh gate expiration to scale with TTL, ensuring more efficient cache refreshes.
  • Enhanced SimpleSetRedisCacheImpl to invalidate and re-fetch cache entries from Redis when a value is missing locally but present in Redis, reducing stale cache issues.

Sync Structure Robustness:

  • Enhanced error handling in AbstractStreamSyncStructure by triggering resyncs on Lua script errors and logging failures during resync, ensuring better recovery from remote errors. [1] [2] [3]
  • Updated SyncListImpl, SyncMapImpl, and SyncSetImpl to default to empty collections if remote data is missing, preventing null-related issues. [1] [2] [3]

Other Notable Changes:

  • Bumped project version to 1.10.2 in gradle.properties.
  • Set ignoreUnknownKeys = true for JSON serialization to improve compatibility with evolving data schemas.
  • Minor code and dependency updates, including import adjustments and username handling in Redisson config. [1] [2] [3]

These changes collectively improve the reliability, safety, and maintainability of the Redis API and its core components.

- add requestResync call on Lua script execution errors
- log resync failures with detailed messages
- ensure resyncInFlight is reset after completion
- validate readable element bytes for collections and arrays
@twisti-dev twisti-dev self-assigned this Jul 29, 2026
Copilot AI review requested due to automatic review settings July 29, 2026 10:20

This comment was marked as low quality.

@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: 33d7a2fdbe

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

fun <T, C : MutableCollection<T>> ByteBuf.readCollection(creator: (Int) -> C, reader: (ByteBuf) -> T): C {
val size = readVarInt()
checkContainerSize("Collection", size)
checkReadableElementBytes("Collection", size)

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 Allow zero-byte elements in generic container readers

When a caller uses a valid zero-byte element encoding, such as writeCollection(listOf(Unit)) { _, _ -> } paired with a reader that returns Unit without consuming bytes, this new guard rejects the payload because only the length prefix remains readable. The public writer and reader callbacks do not require each element to occupy a byte, so the same assumption added to generic arrays and maps also breaks previously supported codecs; avoid applying a fixed per-element byte lower bound to these callback-based readers.

Useful? React with 👍 / 👎.

val redisURI = details.redisURI

val config = Config()
.setUsername(redisURI.username)

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 Treat an empty URI username as absent

When a caller supplies the conventional password-only form redis://:secret@host, RedisURI.username represents the empty user-info component rather than an absent username. Passing that value directly to Redisson makes authentication use the username/password form with an empty ACL username, so a server expecting password authentication for the default user rejects the connection; normalize a blank username to null before setting it.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants