Skip to content

refactor: remove is_oom flag from ConnectionContext #5216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

BorysTheDev
Copy link
Contributor

fixes: #5196

@BorysTheDev BorysTheDev requested review from mkaruza and kostasrim and removed request for mkaruza June 2, 2025 11:24
@BorysTheDev BorysTheDev force-pushed the refactor_command_context branch from 43c0949 to fe4d813 Compare June 2, 2025 12:19
Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

What I would have considered is to change the return type of InvokeCmd from bool to an enum (no error code as it has virtual members -- even for SystemCategory as it's basically a static global object and not a thread local). And then I would propagate the error (if any) from DispatchCommand back to the caller. My rationale for this is:

  1. We already return if we succeed or not from InvokeCmd. Why not just supplement that?
  2. CommandContext belongs logically within DispatchCommand because this is where we have all the information to create it. See dfly_cntx->transaction = dist_trans.get(); . Now we overwrite dfly_cntx && the CommandContext passed to DispatchCommand and I find it slightly confusing that we do the extra bookeeping

This is not something I gave much thought but rather thinking out loud here

@kostasrim kostasrim requested a review from adiholden June 2, 2025 13:16
@BorysTheDev
Copy link
Contributor Author

@kostasrim I need these changes not only for OOM, but for cluster slots too. I agree that this is also not the best solution, but better than before. Let's consider InvokeResult separately.

@adiholden
Copy link
Collaborator

@kostasrim I need these changes not only for OOM, but for cluster slots too. I agree that this is also not the best solution, but better than before. Let's consider InvokeResult separately.

I think that for cluster slots you already have the slot information inside the Transaction class and therefore you dont need to add it to CommandCntx. you can have the tx->GetDbContext() return the slots data as well.

For this PR change I think that you dont need the is_oom in CommandCntx. If you can access the conn_context_->transaction->local_result_ after calling dispatch command in JournalExecutor::Execute

@BorysTheDev
Copy link
Contributor Author

@adiholden I want to remove the cluster code from the transaction, because we do slot calculations several times even before transaction

@BorysTheDev
Copy link
Contributor Author

@kostasrim I like your idea regarding InvokeCmd. If you want, I can remove OOM refactoring from this PR, but I still need other changes regarding CommandContext. Or we can merge the current refactoring and, in the future, return to your idea regarding the InvokeCmd result. I don't want to do these changes here because in this case the PR will have 2 absolutely different refactorings.

@BorysTheDev BorysTheDev force-pushed the refactor_command_context branch 3 times, most recently from 9371eb4 to 46060b7 Compare June 11, 2025 11:52
@BorysTheDev BorysTheDev force-pushed the refactor_command_context branch from 46060b7 to 112afdd Compare June 11, 2025 13:58
@BorysTheDev BorysTheDev changed the title refactor: move is_oom flag to commandContext refactor: remove is_oom flag from ConnectionContext Jun 11, 2025
Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

🚀 very much needed for the fix in #5277

LGTM

@@ -143,12 +143,13 @@ class ClusterShardMigration {
}

private:
void ExecuteTx(TransactionData&& tx_data, ExecutionState* cntx) {
std::error_code ExecuteTx(TransactionData&& tx_data, ExecutionState* cntx) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! We need the same for replication ;)

@BorysTheDev BorysTheDev merged commit 57a075d into main Jun 13, 2025
10 checks passed
@BorysTheDev BorysTheDev deleted the refactor_command_context branch June 13, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move boolean variable is_oom_ from ConnectionContext object
3 participants