-
Notifications
You must be signed in to change notification settings - Fork 1.1k
TTL index creation/verification fails when @Indexed(expireAfter)
expression result in 0
seconds
#4844
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
Comments
thanks for bringing this to our attention. It would be great if you could provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
demo.zip Executing "mvn test" the DemoApplicationTests class will compare the generated indexes. Or it can be deployed to see the differences between the two entities directly on mongodb |
We have the same problem. The source of the problem is MongoPersistentEntityIndexResolver:567 where 0 is ignored.
This behavior does not exist with expireAfterSeconds because it compares to greater than or equal to 0. |
@Indexed(expireAfter)
expression result in 0
seconds
with spring data mongodb 4.4.0 the annotation Indexed has deprecated the expireAfterSeconds in favor of expireAfter
https://docs.spring.io/spring-data/data-mongodb/docs/current/api/org/springframework/data/mongodb/core/index/Indexed.html#expireAfter()
so, according to documentation an entity mapped like this
@Indexed(expireAfterSeconds = 0) private LocalDateTime retentionDate;
should be changed in this
@Indexed(expireAfter = "0s") private LocalDateTime retentionDate;
here comes the problem: the new attribute seems ignore any value that result in 0 seconds
generating a non valid ttl index and in case of an existing index a relative validation failure
ttl indexes are generted succesfully only if the expression result in more than 0 secods, but this is a big problem for existing indexes
The text was updated successfully, but these errors were encountered: