| Summary: | When Guvnor is down, KnowledgeAgent keeps rebuilding kbase from cached files | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [JBoss] JBoss Enterprise BRMS Platform 5 | Reporter: | Toshiya Kobayashi <tkobayas> | ||||||
| Component: | BRE (Expert, Fusion) | Assignee: | Mario Fusco <mfusco> | ||||||
| Status: | VERIFIED --- | QA Contact: | Lukáš Petrovický <lpetrovi> | ||||||
| Severity: | high | Docs Contact: | |||||||
| Priority: | unspecified | ||||||||
| Version: | BRMS 5.3.1 | CC: | kverlaen, nwallace | ||||||
| Target Milestone: | GA | ||||||||
| Target Release: | --- | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Whiteboard: | |||||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||||
| Doc Text: | Story Points: | --- | |||||||
| Clone Of: | Environment: | ||||||||
| Last Closed: | Type: | Bug | |||||||
| Regression: | --- | Mount Type: | --- | ||||||
| Documentation: | --- | CRM: | |||||||
| Verified Versions: | Category: | --- | |||||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||||
| Bug Depends On: | |||||||||
| Bug Blocks: | 1022758 | ||||||||
| Attachments: |
|
||||||||
Created attachment 820295 [details]
DroolsTest.java
Created attachment 820296 [details]
ChangeSet.xml
Attached DroolsTest.java and ChangeSet.xml to reproduce the issue. Sent a pull request: https://github.com/droolsjbpm/drools/pull/279 Verified fixed in 5.3.1-P05. |
Description of problem: Assuming you configure KnowledgeAgent/ResourceChangeScanner with ChangeSet.xml to connect to Guvnor. In addition, you configure drools.resource.urlcache to enable local file cache. When Guvnor is down, KnowledgeAgent keeps rebuilding kbase from cached files every time ResourceChangeScanner scans. This is because lastModified is always greater than lastRead. I added some comments in source codes after "<=" to explain. UrlResource.java: ===== public InputStream getInputStream() throws IOException { try { long lastMod = grabLastMod(); <= conn.getLastModified() of HTTP HEAD if (lastMod == 0) { //we will try the cache... if (cacheFileExists()) return fromCache(); } if (lastMod > 0 && lastMod > lastRead) { if (CACHE_DIR != null && url.getProtocol().equals("http") || url.getProtocol().equals("https")) { //lets grab a copy and cache it in case we need it in future... cacheStream(); <= A cache file is created. The cache file's lastModified is older than 'lastMod' above } } this.lastRead = lastMod; <= So lastRead is younger than cache file's lastModified return grabStream(); } catch (IOException e) { if (cacheFileExists()) { return fromCache(); } else { throw e; } } } ===== ResourceChangeScannerImpl.java: ===== public void scan() { ... for ( Entry<Resource, Set<ResourceChangeNotifier>> entry : this.resources.entrySet() ) { Resource resource = entry.getKey(); Set<ResourceChangeNotifier> notifiers = entry.getValue(); if ( !((InternalResource) resource).isDirectory() ) { // detect if Resource has been removed long lastModified = ((InternalResource) resource).getLastModified(); <= In case that Guvnor is down, lastModified is cache file's lastModified. long lastRead = ((InternalResource) resource).getLastRead(); ... } else if ( lastRead < lastModified && lastRead >= 0 ) { <= kbase rebuild this.listener.debug( "ResourceChangeScanner modified resource=" + resource + " : " + lastRead + " : " + lastModified ); // it's modified ===== Steps to Reproduce: 1. Start BRMS under GMT timezone (e.g. start with -Duser.timezone=GMT). If you test under other timezones, we need to fix BZ1027216 first. 2. Run a client with KnowledgeAgent 3. Shutdown BRMS Actual results: KnowledgeAgent rebuilds kbase from cached files every time ResourceChangeScanner scans. You will see log messages like: [2013-11-06 20:46:49,202:debug] KnowledgeAgent rebuilding KnowledgeBase using ChangeSet Expected results: KnowledgeAgent doesn't rebuild kbase until the resource in Guvnor is updated. Additional info: If packages are large, this would be a severe issue.