Skip to content

Conversation

@lluki
Copy link
Contributor

@lluki lluki commented Aug 29, 2022

This PR implements option 2) of MaterializeInc/database-issues#3881 : Environmentd sends command only to the first process, which then uses timely internally to disseminate the command. Responses are still sent over the network from each process.

Fixes MaterializeInc/database-issues#3881

Motivation

  • This PR fixes a recognized bug.

Tips for reviewer

Checklist

Copy link
Member

@antiguru antiguru left a comment

Choose a reason for hiding this comment

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

This looks mostly fine. I think there are some cases that can be simplified, and we want to preserve the behavior that commands are acted on in batches.


move |output| {
//println!("w{:?} Calling non-blocking recv", &idx);
if idx == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

This is a suspenseful moment, because

  1. We don't drop cap if idx != 0
  2. What happens to commands received by a different process than process 0? It seems we would enqueue them indefinitely with this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this now to panic if idx != 0 receives a message.

Comment on lines 191 to 177
fn recv<A: Allocate>(&mut self, worker: &mut Worker<A>) -> Result<ComputeCommand, RecvError> {
// This takes the worker, so it can step timely while no result
// is available.
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there's an alternative design where we broadcast the initialization commands to all workers and only unicast once the initialization is done? This might have the downside of added complexity and making it harder to recover from errors during initialization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's a possibility. Also regarding #14379 . It might make the cloud deployment easier if computed's start as "empty shell" and receive their configuration in the CreateInstance. If we do this, broadcasting the CreateInstance is a requirement.

@lluki
Copy link
Contributor Author

lluki commented Aug 29, 2022

Thanks @antiguru, I first figure out what goes wrong with the tests then address your comments

@lluki lluki force-pushed the fix_13603_22 branch 3 times, most recently from 51f9b98 to 2707c9e Compare August 31, 2022 12:14
@lluki lluki marked this pull request as ready for review August 31, 2022 12:15
@lluki lluki requested a review from teskje August 31, 2022 12:16
@lluki lluki requested a review from antiguru August 31, 2022 12:18
@lluki
Copy link
Contributor Author

lluki commented Aug 31, 2022

I'm thinking of these lines (server.rs:382).

I'm pretty confident we can replaced them with a simple step_or_park. The race with the initial recv() does not exist anymore, as the sending back of the activator acts as a barrier.

Copy link
Contributor

@teskje teskje left a comment

Choose a reason for hiding this comment

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

I had a couple small comments. I think I need to spend a Friday learning about the computed server before I'm able to understand the changes there though!

@teskje
Copy link
Contributor

teskje commented Aug 31, 2022

I'm not sure about removing the step_or_park workaround. Even if the specific race condition that caused this to be added doesn't exist anymore, do we have any guarantee that we won't add a new one in the future? If not, it might be useful to keep this as a safety measure and just change the comment to remove the outdated reference to recv.

@lluki
Copy link
Contributor Author

lluki commented Aug 31, 2022

I'm not sure about removing the step_or_park workaround. Even if the specific race condition that caused this to be added doesn't exist anymore, do we have any guarantee that we won't add a new one in the future? If not, it might be useful to keep this as a safety measure and just change the comment to remove the outdated reference to recv.

We can't guarantee of course that we don't introduce one in the future. But as long as there are channels acting as barriers during setup, it shouldn't happen again. But as a safeguard we can also just keep it.

Copy link
Member

@antiguru antiguru left a comment

Choose a reason for hiding this comment

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

I think this looks good. Thanks!

Comment on lines +184 to +186
let mut r = vec![None; self.parts];
r[0] = Some(command);
r
Copy link
Member

Choose a reason for hiding this comment

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

I think I would have use iterator magic (once(command).chain(repeat(None, self.parts-1)) or something like this, but your version does the same job.

lluki added 3 commits August 31, 2022 18:44
Partitioned client send commands only to first part. The timely
worker at index 0 then uses timely to disseminate the commands
to the remaining workers.
The channel for sending back the rx_activator now
acts as a barrier, which fixes the same bug.
@lluki lluki merged commit ba0a793 into MaterializeInc:main Sep 1, 2022
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