Skip to content

Add missed standard types during batch's size estimation - #19158

Merged
andsel merged 12 commits into
elastic:mainfrom
andsel:fix/avoid_type_errors_in_batch_estimate
May 28, 2026
Merged

Add missed standard types during batch's size estimation#19158
andsel merged 12 commits into
elastic:mainfrom
andsel:fix/avoid_type_errors_in_batch_estimate

Conversation

@andsel

@andsel andsel commented May 22, 2026

Copy link
Copy Markdown
Member

Release notes

Fixed error during event size estimation on non recognised types.

What does this PR do?

  • Handle the missed Timestamp branch during the estimation.
  • Adds a couple of safe guards during estimation
    1. if class is not belonging to the list of supported in Valufier (which should be a programming error) but it's serializable, use Java serialization
    2. if such class is neither serilizable log a warning error
  • Updates the BigDecimal estimation considering the inner BigInteger instance

The safeguards log messages contains also the field path to the offending field.

Why is it important/What is the impact to the user?

Avoid to log error messages where the user can't take any action to solve and that doesn't impact event processing but just the size calculation.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Test with the pipeline-to-pipeline as described in reproducer comment.

Related issues

@andsel andsel self-assigned this May 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • run exhaustive tests : Run the exhaustive tests Buildkite pipeline.

@mergify

mergify Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label. Could you fix it @andsel? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

@andsel
andsel force-pushed the fix/avoid_type_errors_in_batch_estimate branch from f18db90 to dd45906 Compare May 26, 2026 15:24
@andsel andsel added the bug label May 28, 2026
@andsel
andsel marked this pull request as ready for review May 28, 2026 08:11
@andsel
andsel force-pushed the fix/avoid_type_errors_in_batch_estimate branch from dd45906 to 11ed019 Compare May 28, 2026 08:11
@andsel
andsel requested a review from Copilot May 28, 2026 08:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes noisy error logging during pipeline batch-size estimation (issue #19066) caused by org.logstash.Timestamp values not being recognized by ConvertedMap.estimateMemory. Adds an explicit Timestamp branch, a Java-serialization fallback for unknown-but-Serializable types, threads a field path through the recursion to make diagnostic messages actionable, and downgrades the batch-metrics failure log from error to warn.

Changes:

  • Add a Timestamp branch and a Serializable fallback to ConvertedMap.estimateMemory, with field-path-enriched diagnostics.
  • Thread fieldPath through the recursive estimateMemory calls and update Event.estimateMemory to seed <data> / <meta> roots.
  • Downgrade the metric-failure log severity in QueueReadClientBatchMetrics and add unit/integration tests in ConvertedMapTest and EventTest.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
logstash-core/src/main/java/org/logstash/ConvertedMap.java Adds Timestamp branch, Serializable fallback, and field-path-aware recursion (private signature changed to (String, Object)).
logstash-core/src/main/java/org/logstash/Event.java Passes <data> / <meta> root field paths into ConvertedMap.estimateMemory.
logstash-core/src/main/java/org/logstash/execution/QueueReadClientBatchMetrics.java Downgrades the catch-all log from error to warn.
logstash-core/src/test/java/org/logstash/ConvertedMapTest.java Adds tests using ListAppender to cover serializable and non-serializable unknown types.
logstash-core/src/test/java/org/logstash/EventTest.java Adds roundtrip estimateMemory test for nested Timestamp field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread logstash-core/src/main/java/org/logstash/ConvertedMap.java
Comment thread logstash-core/src/main/java/org/logstash/ConvertedMap.java
Comment thread logstash-core/src/test/java/org/logstash/ConvertedMapTest.java Outdated
Comment thread logstash-core/src/test/java/org/logstash/ConvertedMapTest.java Outdated
@estolfo

estolfo commented May 28, 2026

Copy link
Copy Markdown
Contributor

Tested with the pipeline configuration in the comments of the linked issue and confirm I don't see the error and see the successful log lines estimating the batch metrics estimated memory consumption:

[2026-05-28T11:33:05,550][INFO ][org.logstash.execution.AbstractPipelineExt] Pipeline `upstream` batch metrics estimated memory consumption: 5191680 bytes
[2026-05-28T11:33:05,588][INFO ][org.logstash.execution.AbstractPipelineExt] Pipeline `downstream` batch metrics estimated memory consumption: 5191680 bytes

Comment thread logstash-core/src/main/java/org/logstash/ConvertedMap.java
Comment thread logstash-core/src/main/java/org/logstash/ConvertedMap.java Outdated
Comment thread logstash-core/src/main/java/org/logstash/ConvertedMap.java Outdated
@elasticmachine

Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @andsel

@andsel
andsel merged commit 0b09a83 into elastic:main May 28, 2026
11 checks passed
@andsel andsel added backport-9.3 Automated backport to the 9.3 branch backport-9.4 labels May 29, 2026
@andsel

andsel commented May 29, 2026

Copy link
Copy Markdown
Member Author

@Mergifyio backport 9.4

@mergify

mergify Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

backport 9.4

✅ Backports have been created

Details

andsel added a commit that referenced this pull request May 29, 2026
… estimation

Fixed error during event size estimation on non recognised types.

- Handle the missed `Timestamp` branch during the estimation.
- Adds a couple of safe guards during estimation
  1.  if class is not belonging to the list of supported in Valufier (which should be a programming error) but it's serializable, use Java serialization
  2. if such class is neither serilizable log a warning error
- Updates the BigDecimal estimation considering the inner BigInteger instance

The safeguards log messages contains also the field path to the offending field.

(cherry picked from commit 0b09a83)

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
andsel added a commit that referenced this pull request May 29, 2026
… estimation (#19179)

* Add missed standard types during batch's size estimation (#19158)

Fixed error during event size estimation on non recognised types.

- Handle the missed `Timestamp` branch during the estimation.
- Adds a couple of safe guards during estimation
  1.  if class is not belonging to the list of supported in Valufier (which should be a programming error) but it's serializable, use Java serialization
  2. if such class is neither serilizable log a warning error
- Updates the BigDecimal estimation considering the inner BigInteger instance

The safeguards log messages contains also the field path to the offending field.

(cherry picked from commit 0b09a83)

# Conflicts:
#	logstash-core/src/main/java/org/logstash/ConvertedMap.java

* [git conflict] Fixed

* Fixed API invocation, instead of use JRuby 10.0 use the 9.4 version

---------

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-9.3 Automated backport to the 9.3 branch backport-9.4 bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Batch metrics sampling fails when estimating memory for org.logstash.Timestamp type

4 participants