Request Response Duplicate Correlation Token Validation#400
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #400 +/- ##
==========================================
+ Coverage 84.70% 84.71% +0.01%
==========================================
Files 25 25
Lines 10492 10517 +25
==========================================
+ Hits 8887 8910 +23
- Misses 1605 1607 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ration with aws_last_error()
…h decref/destruction
…into rr-dupe-token
…. Updated related tests
… is using the same correlation token.
… no business there.
| s_remove_correlation_token_from_in_use(operation); | ||
|
|
||
| if (operation->state == AWS_MRROS_PENDING_DESTROY) { |
There was a problem hiding this comment.
I think s_remove_correlation_token_from_in_use should be called only once in s_remove_operation_from_client_tables. I.e. an operation's token should become available for reuse only when there is no possibility for the operation to do something with it.
With current implementation, it's hard to reason about if it's possible or not for the previous operation to do something with its token when the token is already assigned to the next operation.
For example, take the following scenario.
Imagine there is an existing operation op_1 with a token token.
- a new operation
op_2with a tokentokenstarted by a user thread, soaws_mqtt_request_response_client_submit_requestexecutes:- schedule a task (for the next event loop iteration) which will perform this new operation initialization
event loop iteration N:
- a PUBLISH arrives for
op_1, sos_complete_operation_with_correlation_tokenexecutes:- rm
tokenfromcorrelation_tokens_in_use - ... perform the rest of the function
- rm
- Initialize
op_2, i.e. executes_mqtt_rr_client_submit_operationfunction:- add
tokentocorrelation_tokens_in_use - ... and do other stuff
- add
event loop iteration N + 1:
- the second PUBLISH arrives for
op_1(or alternatively there was an op failure on the previous iteration)- rm
tokenfromcorrelation_tokens_in_use
- rm
Now there is op_2 with a token token, but no token record in correlation_tokens_in_use.
To address this hypothetical scenario, we could just execute s_remove_correlation_token_from_in_use(operation); only if state not AWS_MRROS_PENDING_DESTROY. But I feel that this will be still kinda fragile.
There was a problem hiding this comment.
I think the reason I went with the way I did was that we need to have a separate check in s_complete_request_operation_with_failure() to insure we aren't removing a correlation token when the operation is cleaning up due to a duplicate correlation token error. I'll trace the logic and see if we can't combine it and work through your scenario.
If a Request-Response Operation attempts to use an already in-use correlation token it will now fail validation on submission of the operation to the RR Client.
Add a test for failing validation when a duplicate correlation token is submitted while the token is already in use.
Add a test for successful validation of a reused correlation token if the previous operation with the same correlation token has already completed.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.