-
Notifications
You must be signed in to change notification settings - Fork 528
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
[Java] Precedence checks are false negative when decoding a older version message #988
Comments
@ZachBray any thoughts? |
Thank you for the report, @zyulyaev. |
@zyulyaev, it is worth noting that adding a group when there is already variable data isn't a permitted SBE schema evolution in version 1 of the specification. To decode, after such evolutions, an implementation requires the new header field, However, I think the issue you have raised is still valid. |
@ZachBray I was under impression that groups may be added without breaking backward compatibility. It does break forward-compatibility for sure though. |
Groups can be added without breaking compatibility as long as there are no variable-length data fields following. The SBE header has fields for:
In situations where you have a newer encoder and an older decoder, adding new groups after there is already variable-length data fails because:
SBE v2 introduces a |
Sorry, I must have mixed backward and forward compatibility then. What I meant was that with a newer decoder you should be able to decode a message encoded according to an older schema version. |
I've updated my response to remove that terminology for clarity, as I think it is context-dependent. |
Relates to issue #988. An SBE message might not change in every version of a schema. For example, another message might change. Previously, the field precedence checking model would expect an exact match for `actingVersion` in `wrap` to enter one of its initial states. However, it is only aware of the versions in which a message schema has changed. Therefore, it was possible for `actingVersion` not to match any of these versions, in which case the initial state that represented a codec wrapped around the latest known version of the format was picked. Now, we do _not_ expect an exact match in `wrap`. Instead, we select the "best" match. For example, if a codec was changed in v1 and v3, and the acting version is v2, we will decode using v1. However, if the acting version is v4, we would decode as v3.
…ersions. Relates to issue #988. An SBE message might not change in every version of a schema. For example, another message might change. Previously, the field precedence checking model would expect an exact match for `actingVersion` in `wrap` to enter one of its initial states. However, it is only aware of the versions in which a message schema has changed. Therefore, it was possible for `actingVersion` not to match any of these versions, in which case the initial state that represented a codec wrapped around the latest known version of the format was picked. Now, we do _not_ expect an exact match in `wrap`. Instead, we select the "best" match. For example, if a codec was changed in v1 and v3, and the acting version is v2, we will decode using v1. However, if the acting version is v4, we would decode as v3.
…ersions. (#989) Relates to issue #988. An SBE message might not change in every version of a schema. For example, another message might change. Previously, the field precedence checking model would expect an exact match for `actingVersion` in `wrap` to enter one of its initial states. However, it is only aware of the versions in which a message schema has changed. Therefore, it was possible for `actingVersion` not to match any of these versions, in which case the initial state that represented a codec wrapped around the latest known version of the format was picked. Now, we do _not_ expect an exact match in `wrap`. Instead, we select the "best" match. For example, if a codec was changed in v1 and v3, and the acting version is v2, we will decode using v1. However, if the acting version is v4, we would decode as v3.
Fixed in #989. |
Amazing, thanks a lot for addressing this so quickly, and for developing this awesome feature in the first place! |
…ersions. (aeron-io#989) Relates to issue aeron-io#988. An SBE message might not change in every version of a schema. For example, another message might change. Previously, the field precedence checking model would expect an exact match for `actingVersion` in `wrap` to enter one of its initial states. However, it is only aware of the versions in which a message schema has changed. Therefore, it was possible for `actingVersion` not to match any of these versions, in which case the initial state that represented a codec wrapped around the latest known version of the format was picked. Now, we do _not_ expect an exact match in `wrap`. Instead, we select the "best" match. For example, if a codec was changed in v1 and v3, and the acting version is v2, we will decode using v1. However, if the acting version is v4, we would decode as v3.
Decoders generated with
sbe.generate.precedence.checks=true
throwIllegalStateException
when message from a previous version, that is not mentioned in the message schema, is decoded in the correct order.For example the following schema:
results in the follow state machine:
and the following
onWrap
andgroup
methods generated:So if one tries to decode a message with version
2
, they will inevitably get anIllegalStateException
once try to decode thedata
field, since there is no way to transition fromV3_BLOCK
toV3_GROUP_DONE
.From my understanding, the fix should be to generate the following
onWrap
method instead:Here is the reproduction:
And here is the error:
The text was updated successfully, but these errors were encountered: