Opened 10 years ago

Last modified 5 years ago

#8088 new Patches

Limited Forward Compatibility

Reported by: Dmitry Shesterkin <dfb@…> Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.52.0 Severity: Problem
Keywords: Forward Compatibility Cc: pareshvarshney@…

Description

We use xml serialization for saving and loading several types of metadata and we have to support possibility of reading new versions of files with old versions of soft. Boost::serialization is very good at backward compatibility but does not provide anything with opposite problem.

So, This patch introduces new flag boost::archive::skip_unknown_tail_tags. When this flag is set and basic_xml_iarchive is faced with unknown tags at the end of element it will skip them (include nested). E.g., the first version of some file was:

<Test class_id="0" tracking_level="0" version="0">
    <a>31</a>
    <t2 class_id="1" tracking_level="0" version="0">
        <a>11</a>
        <b>12</b>
    </t2>
    <b>32</b>
</Test>

After a while, the second version could be:

<Test class_id="0" tracking_level="0" version="0">
    <a>31</a>
    <t2 class_id="1" tracking_level="0" version="1">
        <a>11</a>
        <b>12</b>
        <c>13</c>
        <d>14</d>
        <t1 class_id="2" tracking_level="0" version="0">
            <a>1</a>
            <b>2</b>
        </t1>
    </t2>
    <b>32</b>
</Test>

Therefore, if the first version software set skip_unknown_tail_tags it can read second version of file (if does not set then exception will be thrown).

Attachments (1)

skip_unknown_tail_tags.patch (2.8 KB ) - added by Dmitry Shesterkin <dfb@…> 10 years ago.

Download all attachments as: .zip

Change History (10)

by Dmitry Shesterkin <dfb@…>, 10 years ago

comment:1 by anonymous, 7 years ago

Does anyone know when or if this patch will be accepted? We use boost to serialize classes for transmitting over CORBA and have just now run into the problem where a newer client application is sending a version 1 buffer to an older version of the server which causes an exception to be raised upon de-serialization. This patch seems like it would solve our problem.

comment:2 by Robert Ramey, 7 years ago

well, this patch wouldn't change the behavior of the "older server" You'd have to upgrade that to include the new functionality. But then if you upgrade the server, you won't have the problem any more.

Never the less, I'll take a look at this.

in reply to:  2 comment:3 by anonymous, 7 years ago

Yes it is an interesting situation, but it would at least prevent the problem from arising again which is another concern.

Thanks for looking into it.

Replying to ramey:

well, this patch wouldn't change the behavior of the "older server" You'd have to upgrade that to include the new functionality. But then if you upgrade the server, you won't have the problem any more.

Never the less, I'll take a look at this.

comment:4 by anonymous, 6 years ago

Does anyone know if this patch has get into the codebase?

comment:4 by anonymous, 6 years ago

Does anyone know if this patch has get into the codebase?

comment:4 by anonymous, 6 years ago

Does anyone know if this patch has get into the codebase?

comment:5 by Dmitry Shesterkin <dfb@…>, 6 years ago

No, it hasn't. The current archive_flags enum doesn't contain skip_unknown_tail_tags https://github.com/boostorg/serialization/blob/develop/include/boost/archive/basic_archive.hpp#L237 You can apply this patch locally and rebuild the library.

ramey, does patch have any issues? I'm happy to change it according to your concerns. Also, it doesn't change a library behavior if the flag is not set

Replying to anonymous:

Does anyone know if this patch has get into the codebase?

comment:6 by Paresh Varshney <pareshvarshney@…>, 6 years ago

Cc: pareshvarshney@… added

Does boost supports (if this made it to actual boost code) this for binary archives?

in reply to:  6 comment:7 by sena@…, 5 years ago

Replying to Paresh Varshney <pareshvarshney@…>:

Does boost supports (if this made it to actual boost code) this for binary archives?

This will not be possible without 2 significant modifications:

  1. Store the name of the field in binary_oarchive, like it is done in xml_oarchive. This way binary_iarchive will be able to identify new fields.
  2. Store the size of the field in binary_oarchive, this way binary_iarchive will know how many bytes it should skip.

I created experimental archive which supports forward compatibility. It stores output in boost::property_tree::ptree, which can be serialized to json. Here is the link https://github.com/sena73/ptree_archive

Note: See TracTickets for help on using tickets.