Uploaded image for project: 'Crowd Data Center'
  1. Crowd Data Center
  2. CWD-4055

Crowd doesn't update hibernate's User/Group caches with Attribute changes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • High
    • 2.8
    • 2.8
    • None
    • None

    Description

      The new reverse mapping for InternalUserAttributes to InternalUser added in CWD-4016 causes problems with Hibernate's caches, because we aren't explicitly updating the user's attributes in the hibernate mapped entity, which Hibernate uses to populate/update its caches. The same thing applies for groups.

      Problematic hibernate definition added in InternalUser.hbm.xml:

          <class name="com.atlassian.crowd.model.user.InternalUser" table="cwd_user" lazy="true">
              <!-- snipped out irrelevant details -->
              <set name="attributes" lazy="true" inverse="true">
                  <key column="user_id" not-null="true"/>
      
                  <one-to-many class="com.atlassian.crowd.model.user.InternalUserAttribute"/>
              </set>
          </class&gt;
      

      This means that when we create or update an InternalUserAttribute for a given user then it has to be added to InternalUser.attributes. For example:

          private void addAttribute(InternalUser user, String attributeName, String attributeValue)
          {
              InternalUserAttribute attribute = new InternalUserAttribute(user, attributeName, attributeValue);
              session().save(attribute);
              // 2 lines below are what we need to do now
              user.attributes.add(attribute)
              session().save(user);
          }
      

      In theory this doesn't actually save to the database; it just updates hibernate's caches. Of course we need to do it in all places that we modify a user's (or group's) attributes.

      Consequences of not doing so are that hibernate will give different views onto user attributes depending on how you ask the question; i.e. inconsistent data.

      Reported by bryan.turner after upgrading Stash to the latest Crowd & seeing strange behaviour under load.

      Attachments

        Issue Links

          Activity

            People

              jwalton joe
              ckrieger Caspar Krieger (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: