Make BulkItemRequest immutable#20831
Conversation
PR Reviewer Guide 🔍(Review updated until commit 93814fc)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 93814fc Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 1201d59
Suggestions up to commit 0450fb9
|
|
❌ Gradle check result for 0450fb9: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
I was talking with @itschrispeck about some JIT optimization issues in BulkItemRequest's serialization. While looking at the code, the `volatile` keyword on the `primaryResponse` field made me cringe. Why is a `BulkItemRequest` mutable at all? It turns out that we modify the existing `BulkItemRequest` instances on the primary shard. These modified requests are send to the replicas. This change makes `BulkItemRequest` immutable. The primary execution context collects all of the primary responses, then produces a new `BulkShardRequest` that gets forwarded to replicas. Signed-off-by: Michael Froh <msfroh@apache.org>
0450fb9 to
1201d59
Compare
|
Persistent review updated to latest commit 1201d59 |
|
❌ Gradle check result for 1201d59: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
These tests relied on the assumption that the BulkShardRequest would be mutated on the primary. In particular, there were some ridiculous tests that were verifying that the output was unchanged from the input, when the output was the same object as the input, which had been changed in place. Signed-off-by: Michael Froh <msfroh@apache.org>
|
Persistent review updated to latest commit 93814fc |
| * | ||
| * @opensearch.internal | ||
| */ | ||
| public class BulkItemRequest implements Writeable, Accountable { |
There was a problem hiding this comment.
I feel like a broken record (no pun intended) because I suggest this all the time, but can you make this a record?
|
❌ Gradle check result for 93814fc: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Description
I was talking with @itschrispeck about some JIT optimization issues in BulkItemRequest's serialization. While looking at the code, the
volatilekeyword on theprimaryResponsefield made me cringe. Why is aBulkItemRequestmutable at all?It turns out that we modify the existing
BulkItemRequestinstances on the primary shard. These modified requests are send to the replicas.This change makes
BulkItemRequestimmutable. The primary execution context collects all of the primary responses, then produces a newBulkShardRequestthat gets forwarded to replicas.Related Issues
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.