Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036359Openbravo ERPA. Platformpublic2017-06-27 12:542017-09-21 16:49
ioritzCia 
alostale 
normalmajoralways
closedfixed 
5
 
3.0PR17Q4 
caristu
Core
No
0036359: Cached context for webservices should be regenerated when an organization is activated
We cache the context for all webservices inside it being the organization tree. When activating a store it is not inserted in the cached organization list and the security checker starts to fail.
- Launch a webservice to make sure that the context cache is generated.
- Activate a store without restarting tomcat
- Launch a webservice against a record of that store and see the error in the log (see note) of the organization not being in the organization list
Make an event when we activate a store/organization or in the copy store to drop that context and force to recreate it again next time
No tags attached.
Issue History
2017-06-27 12:54ioritzCiaNew Issue
2017-06-27 12:54ioritzCiaAssigned To => platform
2017-06-27 12:54ioritzCiaModules => Core
2017-06-27 12:54ioritzCiaResolution time => 1499724000
2017-06-27 12:54ioritzCiaTriggers an Emergency Pack => No
2017-06-27 12:54ioritzCiaNote Added: 0097710
2017-06-27 12:54ioritzCiaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=15430#r15430
2017-07-14 10:54alostaleStatusnew => acknowledged
2017-07-28 12:17alostaleStatusacknowledged => scheduled
2017-07-28 12:17alostaleAssigned Toplatform => alostale
2017-07-31 09:10hgbotCheckin
2017-07-31 09:10hgbotNote Added: 0098265
2017-07-31 09:10hgbotStatusscheduled => resolved
2017-07-31 09:10hgbotResolutionopen => fixed
2017-07-31 09:10hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/2c0b8265b9b10ea156368e9dcce50cead74d8b29 [^]
2017-08-04 09:33alostaleReview Assigned To => caristu
2017-08-04 12:32caristuNote Added: 0098391
2017-08-04 12:32caristuStatusresolved => closed
2017-08-04 12:32caristuFixed in Version => 3.0PR17Q4
2017-08-04 14:42caristuNote Added: 0098399
2017-08-04 14:42caristuStatusclosed => new
2017-08-04 14:42caristuResolutionfixed => open
2017-08-04 14:42caristuFixed in Version3.0PR17Q4 =>
2017-08-04 14:42caristuNote Edited: 0098399bug_revision_view_page.php?bugnote_id=0098399#r15600
2017-08-04 14:42caristuNote Edited: 0098399bug_revision_view_page.php?bugnote_id=0098399#r15601
2017-08-10 08:53hgbotCheckin
2017-08-10 08:53hgbotNote Added: 0098463
2017-08-10 08:53hgbotCheckin
2017-08-10 08:53hgbotNote Added: 0098464
2017-08-10 08:53hgbotStatusnew => resolved
2017-08-10 08:53hgbotResolutionopen => fixed
2017-08-10 08:53hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/2c0b8265b9b10ea156368e9dcce50cead74d8b29 [^] => http://code.openbravo.com/erp/devel/pi/rev/ce623b3c193862bac0863ac3418480b2cac0c0dc [^]
2017-08-11 10:18caristuNote Added: 0098483
2017-08-11 10:18caristuStatusresolved => closed
2017-08-11 10:18caristuFixed in Version => 3.0PR17Q4
2017-08-11 10:18caristuNote Deleted: 0098391
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099305
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099306

Notes
(0097710)
ioritzCia   
2017-06-27 12:54   
Organization 86069CF9D2754372AFEAEE7BE91488D4 of object (OBEDL_Request(9AA394B2B5C74C89B4C8646979FAEF03) (eDLProcess: 04ED002D368141208CA3A855E8A2041F)) is not present in OrganizationList [...]
at org.openbravo.dal.security.SecurityChecker.checkWriteAccess(SecurityChecker.java:167)
        at org.openbravo.dal.security.SecurityChecker.checkWriteAccess(SecurityChecker.java:105)
        at org.openbravo.dal.core.OBInterceptor.doEvent(OBInterceptor.java:349)
        at org.openbravo.dal.core.OBInterceptor.onSave(OBInterceptor.java:231)
        at org.hibernate.event.def.AbstractSaveEventListener.substituteValuesIfNecessary(AbstractSaveEventListener.java:413)
        at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:292)
        at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203)
        at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:143)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
        at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685)
        at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677)
        at org.openbravo.dal.core.SessionHandler.save(SessionHandler.java:245)
        at org.openbravo.dal.service.OBDal.save(OBDal.java:260)
(0098265)
hgbot   
2017-07-31 09:10   
Repository: erp/devel/pi
Changeset: 2c0b8265b9b10ea156368e9dcce50cead74d8b29
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Fri Jul 28 11:04:38 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/2c0b8265b9b10ea156368e9dcce50cead74d8b29 [^]

fixed 36359: can get stale cached WS user context

  When invoking WS, user context is cached in order to prevent its (heavy)
  creation on every request. This cache was not properly invalidated.

  Changes to improve this invalidation:
   1. Purge cache before trying to retrieve elements, not afterwards.
   2. Cache elements already had a valid period of 30 minutes, but this period
      was restarted everytime the element was used. Now the period starts when
      the context is cached and it never gets reset.
   3. In addition to this expiration time, ADUser.updated was checked when purging
      cache, and if it was modified since it was cached, it was removed. This
      implementation had some problems, that are now solved:
        * ADUser is not the only (nor even the main) entity that when modified
          can change permissions in cached contexts, therefore modifications in
          any other entity (ie. Organization) were not triggering cache invalidataion.
          A new EventObserver taking care of all entities that participate in the
          permissions definition has been created to invalidate cache.
        * For every WS request ADUser.updated for every cached context was checked
          querying DB, adding some performance overhead (specially when many contexts
          where already cached). As now invalidation occurs in memory, it is not
          necessary to query DB anymore.

  This mechanism provides a fully accurate cache when working in a single node.
  In case of clustered environments, it is possible that caches kept in a node
  different than the one modifying permissions to continue returning stale contexts,
  but, as per topic 2, this is restricted to, at most, 30 minutes.

---
M src/org/openbravo/service/web/UserContextCache.java
A src/org/openbravo/service/UserCtxCacheObserver.java
---
(0098399)
caristu   
2017-08-04 14:42   
Reopened due to failure in CI[1]

[1] http://ci.openbravo.com/job/int-checks-pgsql/3118/ [^]

(0098463)
hgbot   
2017-08-10 08:53   
Repository: erp/devel/pi
Changeset: f7c49ae6cfd18d5cb9bd4364fd7f976da3ded190
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Aug 10 08:47:31 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/f7c49ae6cfd18d5cb9bd4364fd7f976da3ded190 [^]

related to issue 36359: fixed related test case

  Test for preference to allow/disable unpaged datasource request was incorrectly
  affected by WS user cache beacuse it was mixing WS and datasource request sessions.

  Being PreferenceCache session scoped, it is not necessary to create Preference
  through WS, it can be directly created in test as far as it is ensured DS request
  is performed in a new session.

---
M src-test/src/org/openbravo/test/datasource/BaseDataSourceTestDal.java
M src-test/src/org/openbravo/test/datasource/TestAllowUnpagedDatasourcePreference.java
---
(0098464)
hgbot   
2017-08-10 08:53   
Repository: erp/devel/pi
Changeset: ce623b3c193862bac0863ac3418480b2cac0c0dc
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Aug 10 08:49:37 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/ce623b3c193862bac0863ac3418480b2cac0c0dc [^]

fixed bug 36359: can get stale cached WS user context

  Don't invalidate cache on Preference modifications as they occur very often and,
  in general, they shouldn't affect WS sessions.

---
M src/org/openbravo/service/UserCtxCacheObserver.java
---
(0098483)
caristu   
2017-08-11 10:18   
Code reviewed + tested OK.
(0099305)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0099306)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test