How to update a running system using protobuf from int32 to 64?
Asked Answered
I

1

6

We have a running/production system, where an int32 protobuf field is being communicated to and fro between components. We need to update it to int64 on the fly without getting the current system down. And deployment would also take a lot of time so one component can get updated to int64 while the other is still at int32. We need to update without any failures.

How can this be done?

Imco answered 26/2, 2018 at 11:25 Comment(0)
T
10

int32 and int64 are both communicated as "varint" (wire-type zero) - they are already wire compatible. So: as long as neither client nor server is currently sending 64-bit values, you can update each end independently - just change the .proto to use int64 instead of int32 and re-generate the generated code, and get it deployed. The data is wire compatible and will not change the seriaization format.

Note: you should not actually use values in the 64-bit range until both ends have been updated.

If you were changing from fixed32/sfixed32 to fixed64/sfixed64, then this would represent a much bigger change and would require careful thought, usually involving introducing a new field (with a new number) for the 64-bit value, and migrating to it - probably putting the 32-bit value into both fields until both ends are deployed, then removing the old field and using just the 64-bit field.

Trowel answered 26/2, 2018 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.