gRPC Service Rollback and Protobuf Schema Compatibility Boundary
0 reputation · 28 Nov 2020, 20:20 UTC
0 reputation · 28 Nov 2020, 20:20 UTC
Our team must decide whether rolling back a gRPC service to a previous protobuf schema is safe when clients and servers may not be updated simultaneously. Because gRPC does not automatically version services, compatibility depends entirely on protobuf field-number and type rules under standard protobuf semantics. We know that adding a new optional field with a unique number is safe, but removing a field, reusing its number, or changing an existing field type can cause deserialization failures on peers still using the old schema.
The uncertainty is whether our rollback plan can tolerate mixed-version traffic. Some clients may lag behind the new schema, and custom options or google.protobuf.Any fields may obscure standard compatibility guarantees. We need a clear boundary for when rollback is acceptable and when it requires coordinated client and server updates.
What specific protobuf schema changes make a gRPC service rollback unsafe under mixed client-server versions? How should we evaluate rollback safety when custom options or Any fields are present? Is there a documented gRPC behavior that enforces schema compatibility, or is it entirely the integrator's responsibility?
35775 reputation · 28 Nov 2020, 20:33 UTC
A gRPC service rollback is unsafe if the version being rolled back to cannot deserialize messages produced by the current (newer) version, or if the current clients cannot deserialize messages produced by the older server. Because gRPC does not provide built-in schema versioning, compatibility is governed strictly by the Protobuf wire format.
Rollback is unsafe (requiring coordinated updates) if any of the following occurred in the new version:
int32 to a string).optional to required (or vice versa) can cause the parser to reject messages that lack the field.When google.protobuf.Any or custom options are used, the boundary shifts from binary compatibility to application logic compatibility:
Any field that the old version's type registry does not recognize. The old version will be unable to unpack the message, potentially causing runtime exceptions.Schema compatibility is entirely the integrator's responsibility. gRPC ensures the transport of bytes, but it does not validate that the sender and receiver are using the same version of a .proto file.
To verify rollback safety, perform the following check:
# 1. Serialize a message using the NEW schema
# 2. Attempt to deserialize that binary blob using the OLD schema
# 3. Ensure no 'required' fields are missing and no type mismatches occur
Missing Diagnostic: Are you using proto2 or proto3? (The presence of required fields in proto2 significantly narrows the safety window for rollbacks.)
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.