Skip to content
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

Refactor process_own_message to not mutate intent state directly #985

Conversation

neekolas
Copy link
Contributor

@neekolas neekolas commented Aug 22, 2024

tl;dr

  • Simplifies process_own_message to return the desired intent state, instead of having a bunch of DB operations happen in the method

Copy link
Contributor Author

neekolas commented Aug 22, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @neekolas and the rest of your teammates on Graphite Graphite

@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 51dbd6e to 38f29c6 Compare August 22, 2024 21:33
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from 4ffa958 to 9bc52b9 Compare August 22, 2024 21:33
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 38f29c6 to d8dd680 Compare August 22, 2024 21:33
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from 9bc52b9 to 18f59d8 Compare August 22, 2024 21:33
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from d8dd680 to 492e673 Compare August 23, 2024 00:11
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from 18f59d8 to 03677ae Compare August 23, 2024 00:11
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 492e673 to 58bbcd2 Compare August 23, 2024 00:24
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from 03677ae to c2a3bd8 Compare August 23, 2024 00:24
@neekolas neekolas mentioned this pull request Aug 23, 2024
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 58bbcd2 to 5902193 Compare August 23, 2024 02:25
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from c2a3bd8 to a01133c Compare August 23, 2024 02:26
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 5902193 to 0e1c68f Compare August 23, 2024 02:32
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from a01133c to 2cec1d2 Compare August 23, 2024 02:32
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 0e1c68f to 2c6cb9e Compare August 23, 2024 05:45
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from 2cec1d2 to c855664 Compare August 23, 2024 05:45
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 2c6cb9e to 1e535db Compare August 23, 2024 05:48
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from c855664 to 89c3113 Compare August 23, 2024 05:48
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 1e535db to 5d277d6 Compare August 23, 2024 05:58
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from 89c3113 to cb49a01 Compare August 23, 2024 05:58
@neekolas neekolas force-pushed the 08-22-move_staged_commit_to_intents branch from 5d277d6 to c9f0f10 Compare August 23, 2024 15:34
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from cb49a01 to 3492510 Compare August 23, 2024 15:34
@neekolas neekolas marked this pull request as ready for review August 23, 2024 15:51
@neekolas neekolas requested a review from a team as a code owner August 23, 2024 15:51
Copy link
Contributor Author

neekolas commented Aug 23, 2024

Merge activity

  • Aug 23, 3:37 PM PDT: @neekolas started a stack merge that includes this pull request via Graphite.
  • Aug 23, 3:40 PM PDT: Graphite rebased this pull request as part of a merge.
  • Aug 23, 3:45 PM PDT: @neekolas merged this pull request with Graphite.

@neekolas neekolas changed the base branch from 08-22-move_staged_commit_to_intents to graphite-base/985 August 23, 2024 22:38
@neekolas neekolas changed the base branch from graphite-base/985 to main August 23, 2024 22:38
@neekolas neekolas force-pushed the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch from 3492510 to 5afdbc3 Compare August 23, 2024 22:40
@@ -345,7 +343,7 @@ impl MlsGroup {
);
if let Err(err) = openmls_group.merge_staged_commit(&provider, pending_commit) {
log::error!("error merging commit: {}", err);
conn.set_group_intent_to_publish(intent.id)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, I wonder if this was a bug before? In the previous code it would have continued to L371 and set it to committed

@neekolas neekolas merged commit 68d90b2 into main Aug 23, 2024
6 checks passed
@neekolas neekolas deleted the 08-22-refactor_process_own_message_to_not_mutate_intent_state_directly branch August 23, 2024 22:45
Ok(provider.conn_ref().set_group_intent_committed(intent_id)?)
}
IntentState::Published => {
log::warn!("Unexpected behaviour: returned intent state published from process_own_message");
Copy link
Contributor

Choose a reason for hiding this comment

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

For unexpected behavior, I think we should log errors, so that we are more likely to see them. Especially if we choose not to update the state here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that we aren't returning the error in a lot of cases. We only return the error if we want to hard fail without changing the intent status (like a DB connection error). That'll get returned to the calling function, which does log it.

So, we have to log inside process_own_message before returning OK

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant is, as a general rule, we should do log::error instead of log::warn for cases we expect never to happen - not that we need to return an error to the caller

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I see. I can update that

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.

3 participants