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

Fixes recovery serde #143

Merged
merged 1 commit into from Sep 26, 2022
Merged

Fixes recovery serde #143

merged 1 commit into from Sep 26, 2022

Conversation

davidselassie
Copy link
Contributor

Makes all types for recovery serialization and deserialization
explicit and fixes them to match each other for each recoverable
operator.

This will fix panics during recovery loading.

This was also fixed in #137
but I'm breaking it out here separately because I keep discoverying
smaller recovery bugs and am fixing them separately.

Makes all types for recovery serialization and deserialization
explicit and fixes them to match each other for each recoverable
operator.

This will fix panics during recovery loading.

This was also fixed in #137
but I'm breaking it out here separately because I keep discoverying
smaller recovery bugs and am fixing them separately.
Copy link
Contributor

@whoahbot whoahbot left a comment

Choose a reason for hiding this comment

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

👍 Just left you a question for my own curiosity.

let acc = resume_acc_bytes.map(|resume_acc_bytes| resume_acc_bytes.de());
let acc = resume_acc_bytes
.map(StateBytes::de::<Option<TdPyAny>>)
.flatten();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why wasn't the flatten() call needed before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was actually needed, hence the panic, but type inference made the compiler assume the wrong types since it can't know what's in those bytes.

The previous version without the flatten was causing the compiler to infer the incorrect type for the deserialization step. So for reduce window, snapshot was serializing with StateBytes::ser(&self.acc) which was inferred (correctly) to be StateBytes::ser::<Option<TdPyAny>>(&self.acc) but the builder was deserializing with resume_acc_bytes.map(|resume_acc_bytes| resume_acc_bytes.de()) which was inferred to be resume_acc_bytes.map(|resume_acc_bytes| resume_acc_bytes.de::<TdPyAny>()) but by (bad) luck the final type of acc was correct, so it was like cool this must be correct.

By making the deserialization type explicit and match the serialization type, now if you forget the flatten it's a type error.

@davidselassie davidselassie merged commit da6081a into main Sep 26, 2022
@davidselassie davidselassie deleted the recovery-serde branch September 26, 2022 19:12
@davidselassie davidselassie mentioned this pull request Sep 27, 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.

None yet

2 participants