Skip to content

Fix IndexOutOfBoundsException in CompressingDecryptingPageDeserializer#29094

Open
trina242 wants to merge 1 commit intotrinodb:masterfrom
trina242:retry-policy-deserialization-error
Open

Fix IndexOutOfBoundsException in CompressingDecryptingPageDeserializer#29094
trina242 wants to merge 1 commit intotrinodb:masterfrom
trina242:retry-policy-deserialization-error

Conversation

@trina242
Copy link
Copy Markdown

@trina242 trina242 commented Apr 13, 2026

When fault-tolerant execution is enabled (retry-policy=TASK), small pages that fit within a single encrypted block cause an IndexOutOfBoundsException during deserialization. This happens because decrypt() unconditionally reads the next encrypted block header from the source buffer without checking if the source has been fully consumed. When ensureReadable() triggers a second decrypt() call after all encrypted blocks have already been processed, source.readInt() reads past the end of the buffer.

Add an early return in both decrypt() and decompress() when their respective source buffers have no remaining data, which is the correct behavior when all blocks have been consumed.

Fixes #23531

Description

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## General
* Fix `IndexOutOfBoundsException` during deserialization for fault-tolerant execution (https://github.com/trinodb/trino/issues/23531)

When fault-tolerant execution is enabled (retry-policy=TASK), small pages
that fit within a single encrypted block cause an
IndexOutOfBoundsException during deserialization. This happens because
decrypt() unconditionally reads the next encrypted block header from the
source buffer without checking if the source has been fully consumed.
When ensureReadable() triggers a second decrypt() call after all
encrypted blocks have already been processed, source.readInt() reads
past the end of the buffer.

Add an early return in both decrypt() and decompress() when their
respective source buffers have no remaining data, which is the correct
behavior when all blocks have been consumed.

Fixes trinodb#23531

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed label Apr 13, 2026
@raunaqmorarka raunaqmorarka requested a review from losipiuk April 13, 2026 20:42
@raunaqmorarka
Copy link
Copy Markdown
Member

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 914ce62d-a6b4-43fa-be7b-1b32bd9823f2

📥 Commits

Reviewing files that changed from the base of the PR and between 1db0b5e and 3b65d47.

📒 Files selected for processing (1)
  • core/trino-main/src/main/java/io/trino/execution/buffer/CompressingDecryptingPageDeserializer.java

📝 Walkthrough

Walkthrough

The pull request adds early-return guards to the decrypt() and decompress() methods in CompressingDecryptingPageDeserializer. The decrypt() method now returns immediately when its input buffer is empty, avoiding cipher operations on insufficient data. The decompress() method similarly returns when its input buffer is empty, skipping decompression logic. These guards are purely defensive additions that do not change the public API or overall behavior of the class.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@losipiuk
Copy link
Copy Markdown
Member

Thanks - can you add a test coverage for that? Let me know if you do not have time for that then I will take a look (eventually).

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack.

@github-actions github-actions Bot added the stale label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

IndexOutOfBoundsException with fault tolerance using RETRY-POLICY=TASK

3 participants