8000 JPA Map storage doesn't downgrade entityVersion when modifying a row written with a future entityVersion · Issue #9716 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

JPA Map storage doesn't downgrade entityVersion when modifying a row written with a future entityVersion #9716

Closed

Description

@ahus1

Describe the bug

When the Map JPA store reads data from a row, it accepts data that is written by another Keycloak version with entityVersion N+1. Thereby it ignores new fields written by a later version during JSON de-serialization.

When it then writes the data back to the database, it uses its JSON serializer and writes the data in the format of its own JSON schema to the row. Therefore, it should downgrade the entityVersion to N as well, so that is future version of Keycloak can again migrate the data to a later entity version.

Version

17.0.0-SNAPSHOT

Expected behavior

  • when data is written to the row, the entity version is always the SUPPORTED_VERSION_* of the implementation

Actual behavior

  • when data is written to the row, the entity version is kept "as is", thereby leaving the N+1 version in the row. This prevents a future migration of the JSON and is inconsistent with the data in the JSON column.

How to Reproduce?

Manual testing with the database

Anything else?

There is a discussion on this topic here: #9640

Possible refactoring: Rework repetitive calls to checkEntityVersionForUpdate() in JpaClientEntity to a method annotated with @PreUpdate and @PrePersist, so that is called whenever a SQL insert or update is triggered.

This would prevent missing an update to the entity version in cases where Hibernate triggers an update to the database.

Activity

  1. added
    kind/bug
    area/storage
    on Jan 21, 2022
  2. moved this to Todo in Storageon Jan 21, 2022
  3. assigned and unassigned on Jan 25, 2022
  4. moved this from Todo to In Progress in Storageon Feb 1, 2022
  5. Repository owner moved this from In Progress to Done in Storageon Feb 7, 2022
  6. added a commit that references this issue on Feb 7, 2022
    de2c1fb
  7. added this to the 17.0.0 milestone on Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/storagekind/bug

Type

No type

Fields

No fields configured for issues without a type.

Projects

  • Status
    ✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

0