Uploaded image for project: 'Spring Data Redis'
  1. Spring Data Redis
  2. DATAREDIS-560

save (update) operation on repository deletes the key and inserts it back

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Investigating
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7.4 (Hopper SR4)
    • Fix Version/s: None
    • Component/s: Repository Support
    • Labels:
      None
    • Environment:
      all environments

      Description

      When using the KeyValueRepository interface and enableRedisRepositories:

      After the initial creation - repository.save() - everything is fine here.
      When doing an update operation: calling repository.save() - correctly detects that this is an update and calls
      SimpleKeyValueRepository().save() --> KeyValueTemplate.update(....) --> which calls the callback method:
      doInRedis(RedisConnection connection ).. In this method I see an issue:

      Issue: A call is being made to delete the key
      boolean isNew = connection.del(objectKey) == 0;
      and it is promptly added back in the same callback method.

      During this period if another thread is looking up the key - it indicates the key is not there and shortly afterwards it reappears.

      Two issues here:
      1) Integrity of redis is not maintained - a key is being deleted in the process of an update.
      2) In the event of a crash around this critical section I believe the integrity of the data is getting compromised.

      How to reproduce this:
      Do an update operation on the repository in a debugger and suspend the thread after the delete operation. Use another client to look up the key.

      Should the connection.del(objectKey) be changed to connection.exisits(objectKey) to fix this.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cstrobl Christoph Strobl
              Reporter:
              sumanth.yamala@sas.com sumanth yamala
              Last updater:
              Josef Reichardt
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: