Skip to content

Invalid updateTime returned from the save operation when document does not change #2163

Closed

Description

@arturomelo-kareo

Describe the bug
If I use the FirestoreReactiveRepository.save method to updated an existing document that contains the same values as the document stored in the database, the field annotated with the @UpdateTime(version = true) annotation returns a new timestamp. However, the value reported by Firestore is the previous timestamp as nothing was really updated.

Sample
This behavior causes in my code a precondition error because we are passing an invalid version (timestamp in the future)

"message": "FAILED_PRECONDITION: the stored version (1694626589979859) does not match the required base version (1694626366831818)",

Version
spring-cloud-gcp-data-firestore:3.5.3
google-cloud-firestore:3.14.0

Activity

  1. self-assigned this
    on Sep 14, 2023
  2. meltsufin commented on Sep 14, 2023

    @meltsufin
    Contributor

    I'm able to repro with:

      @Test
      public void testUpdateTimeNoDocumentChange() throws InterruptedException {
        User user = new User();
        user.setName("Axle");
        user.setAge(25);
        userRepository.save(user).block();
        userRepository.save(user).block();
        user.setAge(26);
        userRepository.save(user).block();
      }
  3. added a commit that references this issue on Sep 14, 2023
    83c7f06
  4. added 3 commits that reference this issue on Sep 15, 2023
    bacdfe9
    4ca7ac2
    46ab69d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions