Make BulkItemRequest immutable - #20831
Conversation
PR Reviewer Guide 🔍(Review updated until commit dffb34c)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to dffb34c Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 96da1db
Suggestions up to commit 5b520fd
Suggestions up to commit c49aeb5
Suggestions up to commit d2a6232
Suggestions up to commit 93814fc
|
|
❌ 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? |
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? |
|
Persistent review updated to latest commit 93814fc |
|
❌ 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? |
|
Persistent review updated to latest commit d2a6232 |
|
❌ Gradle check result for d2a6232: 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? |
d2a6232 to
8bde4b5
Compare
|
Failed to generate code suggestions for PR |
|
❌ Gradle check result for 8bde4b5: 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? |
8bde4b5 to
ea74e1a
Compare
|
Failed to generate code suggestions for PR |
ea74e1a to
3ca0f4a
Compare
|
Failed to generate code suggestions for PR |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #20831 +/- ##
============================================
+ Coverage 73.10% 73.16% +0.05%
- Complexity 73213 73220 +7
============================================
Files 5968 5968
Lines 334539 334532 -7
Branches 48174 48171 -3
============================================
+ Hits 244572 244766 +194
+ Misses 70421 70176 -245
- Partials 19546 19590 +44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The comments from the PR bot (#20831 (comment)) are not bad.
|
|
Persistent review updated to latest commit c49aeb5 |
|
Persistent review updated to latest commit 5b520fd |
|
❌ Gradle check result for 5b520fd: 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>
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>
Follow @andrross's suggestion of converting BulkItemRequest to a record, since it's immutable now. Also, we were seeing test failures because the cloned BulkShardRequest (that is propagated to replicas) did not copy the primary request's parent TaskId. Along with that, I made sure it copied all other properties from the primary shard request. Signed-off-by: Michael Froh <msfroh@apache.org>
1. Add null-check (assert) on primary responses when running on replica. 2. Move BulkShardRequest cloning logic from BulkPrimaryExecutionContext to BulkShardRequest and ReplicationRequest. Add a dedicated unit test for it. Signed-off-by: Michael Froh <msfroh@apache.org>
Signed-off-by: Michael Froh <msfroh@apache.org>
We previously weren't checking invariants for COMPLETED operations, so the assertions never ran. As called out by @andrross, there are two possible code paths that mark an operation as completed without setting requestToExecute. Signed-off-by: Michael Froh <msfroh@apache.org>
5b520fd to
96da1db
Compare
|
Persistent review updated to latest commit 96da1db |
|
❌ Gradle check result for 96da1db: 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? |
Signed-off-by: Michael Froh <msfroh@apache.org>
|
Persistent review updated to latest commit dffb34c |
|
❌ Gradle check result for dffb34c: 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? |
|
❕ Gradle check result for dffb34c: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
* Make BulkItemRequest immutable 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> * Fix TransportShardBulkActionTests 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> * Make BulkItemRequest a record and fix BulkShardRequest clone Follow @andrross's suggestion of converting BulkItemRequest to a record, since it's immutable now. Also, we were seeing test failures because the cloned BulkShardRequest (that is propagated to replicas) did not copy the primary request's parent TaskId. Along with that, I made sure it copied all other properties from the primary shard request. Signed-off-by: Michael Froh <msfroh@apache.org> * Address PR bot comments 1. Add null-check (assert) on primary responses when running on replica. 2. Move BulkShardRequest cloning logic from BulkPrimaryExecutionContext to BulkShardRequest and ReplicationRequest. Add a dedicated unit test for it. Signed-off-by: Michael Froh <msfroh@apache.org> * Fix (and use) broken branch in assertInvariants Signed-off-by: Michael Froh <msfroh@apache.org> * Remove assertion on requestToExecute We previously weren't checking invariants for COMPLETED operations, so the assertions never ran. As called out by @andrross, there are two possible code paths that mark an operation as completed without setting requestToExecute. Signed-off-by: Michael Froh <msfroh@apache.org> * Remove reference copy of primaryReponse Signed-off-by: Michael Froh <msfroh@apache.org> --------- Signed-off-by: Michael Froh <msfroh@apache.org> Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
* Make BulkItemRequest immutable 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> * Fix TransportShardBulkActionTests 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> * Make BulkItemRequest a record and fix BulkShardRequest clone Follow @andrross's suggestion of converting BulkItemRequest to a record, since it's immutable now. Also, we were seeing test failures because the cloned BulkShardRequest (that is propagated to replicas) did not copy the primary request's parent TaskId. Along with that, I made sure it copied all other properties from the primary shard request. Signed-off-by: Michael Froh <msfroh@apache.org> * Address PR bot comments 1. Add null-check (assert) on primary responses when running on replica. 2. Move BulkShardRequest cloning logic from BulkPrimaryExecutionContext to BulkShardRequest and ReplicationRequest. Add a dedicated unit test for it. Signed-off-by: Michael Froh <msfroh@apache.org> * Fix (and use) broken branch in assertInvariants Signed-off-by: Michael Froh <msfroh@apache.org> * Remove assertion on requestToExecute We previously weren't checking invariants for COMPLETED operations, so the assertions never ran. As called out by @andrross, there are two possible code paths that mark an operation as completed without setting requestToExecute. Signed-off-by: Michael Froh <msfroh@apache.org> * Remove reference copy of primaryReponse Signed-off-by: Michael Froh <msfroh@apache.org> --------- Signed-off-by: Michael Froh <msfroh@apache.org>
* Make BulkItemRequest immutable 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> * Fix TransportShardBulkActionTests 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> * Make BulkItemRequest a record and fix BulkShardRequest clone Follow @andrross's suggestion of converting BulkItemRequest to a record, since it's immutable now. Also, we were seeing test failures because the cloned BulkShardRequest (that is propagated to replicas) did not copy the primary request's parent TaskId. Along with that, I made sure it copied all other properties from the primary shard request. Signed-off-by: Michael Froh <msfroh@apache.org> * Address PR bot comments 1. Add null-check (assert) on primary responses when running on replica. 2. Move BulkShardRequest cloning logic from BulkPrimaryExecutionContext to BulkShardRequest and ReplicationRequest. Add a dedicated unit test for it. Signed-off-by: Michael Froh <msfroh@apache.org> * Fix (and use) broken branch in assertInvariants Signed-off-by: Michael Froh <msfroh@apache.org> * Remove assertion on requestToExecute We previously weren't checking invariants for COMPLETED operations, so the assertions never ran. As called out by @andrross, there are two possible code paths that mark an operation as completed without setting requestToExecute. Signed-off-by: Michael Froh <msfroh@apache.org> * Remove reference copy of primaryReponse Signed-off-by: Michael Froh <msfroh@apache.org> --------- Signed-off-by: Michael Froh <msfroh@apache.org>
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 (as part of aBulkShardRequest) are sent to the replicas. That is, thePrimaryExecutionContextreturns the modified-in-placeBulkShardRequestthat it was created with, which is sent to the replicas.This change makes
BulkItemRequestimmutable. ThePrimaryExecutionContextcollects all of the primary responses, then produces a newBulkShardRequestthat combines the originalBulkItemRequests with the responses, which 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.