Protocol buffer compatibility across library versions

4,539 views
Skip to first unread message

shani...@gmail.com

unread,
Jan 11, 2009, 11:47:42 PM1/11/09
to Protocol Buffers
Hi,
Lets say my proto (abcd.proto) is compiled with the protoc compiler
version 2.0.3 and my application also links to the corresponding
runtime libraries. I now run my app and store the bytes generated
from the proto object to some persistent store (say a database).

A month from now, I decide to upgrade to protocol buffer version 2.0.4
(which say is released) and recompile abcd.proto using the new
compiler to generate the new cpp classes. I hook my app to the new
runtime libraries and try to read the older bytes (v2.0.3) from the
persistent store. Will it be able to?

In other words, are the bytes that are written out (for an unchanged
proto file) compatible across protobuf library versions? Will this
always be guaranteed?

Thanks.

Chris

unread,
Jan 12, 2009, 5:38:13 AM1/12/09
to shani...@gmail.com, Protocol Buffers
If abcd.proto is unchanged and version 2.0.3 is bug free and version
2.0.4 is bug free then saving with 2.0.3 libraries and loading with
2.0.4 libraries will work. Also, saving with 2.0.4 should let you load
with 2.0.3 as well.

It is possible that the c++ class definitions change slightly, so the
actual in-memory object may be different. But the data should
roundtrip, regardless of the computer language used.

If fields are delete from abcd.proto and/or non-required fields are
added to abcd.proto then it should still let you load "old" data into
the "new" format. Removed fields get stored or dropped in a
language-library dependent way. New non-required fields will be unset
and have their default values. The only big difficulty is loading data
that does have a fields declared as required by the current code.

Cheers,
Chris

Marc Gravell

unread,
Jan 12, 2009, 9:52:14 AM1/12/09
to Protocol Buffers
If you think about it, what you describe is not much different to "if
I write the binary using C++, can I read it with java / C# /
ActionScript / etc" - since they all have different code describing
the same binary wire-format.

The answer is: yes, (assuming there are no significant bugs between
the versions). The wire format is designed not to be closely tied to
the compiler / language / etc - it should only care about the type
definitions you use.

I would /expect/ things to remain backwards compatible, for obvious
reasons. But life has few guarantees ;-p

Marc

murari

unread,
Jan 12, 2009, 12:40:45 PM1/12/09
to Protocol Buffers
This was a minor concern to me as well and I did try (for sanity's
sake) persisting the binary objects while upgrading my app to newer
versions of the protobuf library and reading the persisted objects
worked like a charm. Like Marc mentions, the underlying binary spec
has to be the same if it is to work across multiple platforms.

--murari

Kenton Varda

unread,
Jan 12, 2009, 12:42:41 PM1/12/09
to shani...@gmail.com, Protocol Buffers
Just to add an official response:  Yes, they will be compatible.  If they weren't, we would consider that a very serious bug.  Inside Google we have protobuf data written many years ago that we expect to be able to read with the latest code.  :)

Feng Xiao

unread,
Mar 14, 2013, 4:35:00 PM3/14/13
to Ernest Micklei, Protocol Buffers, shani...@gmail.com



On Thu, Mar 14, 2013 at 1:42 AM, Ernest Micklei <ernest....@gmail.com> wrote:
And what about a mixture: will (Java) classes generated by 2.4.1 work with the 2.5.0 library ?
No. Only serialized data is ensured to be wire-compatible across all protobuf versions, not the generated code. The runtime library must have the same version with the protocol compiler you use.
 

Op maandag 12 januari 2009 18:42:41 UTC+1 schreef Kenton Varda het volgende:

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ernest Micklei

unread,
Mar 14, 2013, 6:00:00 PM3/14/13
to prot...@googlegroups.com, Ernest Micklei, shani...@gmail.com
Thank you for confirming this.

^ Ernest

Op donderdag 14 maart 2013 21:35:00 UTC+1 schreef Feng Xiao het volgende:
Reply all
Reply to author
Forward
0 new messages