Skip to content

DATAREDIS-1955 - Phantom copy is not persisted when entity ttl is changed from positive to negative, causing phantom copy not updated to no expire and counting down, then RedisKeyExpiredEvent publishing #1961

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

Closed
wants to merge 3 commits into from

Conversation

muchnik
Copy link
Contributor

@muchnik muchnik commented Feb 8, 2021

DATAREDIS-1955 - Phantom copy is not persisted when entity ttl is changed from positive to negative, causing phantom copy not updated to no expire and counting down, then RedisKeyExpiredEvent publishing.

When updating an object that has a positive time to live to a negative time to live you must persist the phantom key.
Otherwise, after expiring time to live of the phantom, which was created when object with a positive time to live was saved - the indices are dropped and the keys are deleted from the sets as if entity is expired.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

…nged from positive to negative, causing phantom copy not updated to no expire and counting down, then RedisKeyExpiredEvent publishing

When updating an object that has a positive time to live to a negative time to live you must persist the phantom key.
Otherwise, after expiring time to live of the phantom, which was created when object with a positive time to live was saved - the indices are dropped and the keys are deleted from the sets as if entity is expired.
@christophstrobl
Copy link
Member

@muchnik thanks for the PR!
We can take it from here - I tend to switch from persisting the phantom key to removing it (also for the update scenario). This would reduce the footprint on server side. Objections?

… partial update, when phantom key is not needed - it now deletes instead of persisting.
@muchnik
Copy link
Contributor Author

muchnik commented Feb 10, 2021

@muchnik thanks for the PR!
We can take it from here - I tend to switch from persisting the phantom key to removing it (also for the update scenario). This would reduce the footprint on server side. Objections?

Nice idea, updated PR!

christophstrobl pushed a commit that referenced this pull request Feb 16, 2021
This commit makes sure to clean up resources when a previously expiring entity is persisted by setting the time to live to zero or negative.
In case a phantom copy exists for the changed entity, it is removed to free space on the server and prevent expiration events from being sent.

See #1955
Original Pull Request: #1961

# Conflicts:
#	src/test/java/org/springframework/data/redis/core/RedisKeyValueAdapterTests.java
christophstrobl added a commit that referenced this pull request Feb 16, 2021
Introduce helper method to unify expiry check and simplify control flow.

Original Pull Request: #1961
christophstrobl pushed a commit that referenced this pull request Feb 16, 2021
This commit makes sure to clean up resources when a previously expiring entity is persisted by setting the time to live to zero or negative.
In case a phantom copy exists for the changed entity, it is removed to free space on the server and prevent expiration events from being sent.

See #1955
Original Pull Request: #1961
christophstrobl added a commit that referenced this pull request Feb 16, 2021
Introduce helper method to unify expiry check and simplify control flow.

Original Pull Request: #1961
christophstrobl pushed a commit that referenced this pull request Feb 16, 2021
This commit makes sure to clean up resources when a previously expiring entity is persisted by setting the time to live to zero or negative.
In case a phantom copy exists for the changed entity, it is removed to free space on the server and prevent expiration events from being sent.

Closes #1955
Original Pull Request: #1961
christophstrobl added a commit that referenced this pull request Feb 16, 2021
Introduce helper method to unify expiry check and simplify control flow.

Original Pull Request: #1961
@christophstrobl
Copy link
Member

Thanks @muchnik! Merged to main branch and back ported to 2.3.x and 2.4.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository Repositories abstraction type: bug A general bug
Projects
None yet
3 participants