-
Notifications
You must be signed in to change notification settings - Fork 19
Decision Issue Sync
Currently Decision Issue Sync
(DIS) will sync a request issue attached to an End Product Establishment (EPE) with VBMS. If the attached EPE has a sync_status of CLR, then a decision issue sync gets triggered on that request issue. The sync_decision_issue!
checks if the request issue is processed, submitted and ready. Then, finds the veteran attached to the EPE and starts the transaction. This creates decision issues and once the sync is completed a remand supplemental claim is created. A problem we experienced is when more than one request issue that is attached to the EPE can inadvertently be bypassed if they're being synced at the same time. This results in the remand supplemental claim not being generated.
request_issue.rb
def sync_decision_issues!
return if processed?
fail NotYetSubmitted unless submitted_and_ready?
clear_error!
attempted!
# pre-fetch the internal veteran record before we start the transaction
# to avoid a slow BGS call causing the transaction to timeout
end_product_establishment.veteran
transaction do
return unless create_decision_issues
end_product_establishment.on_decision_issue_sync_processed(self)
clear_error!
close_decided_issue!
processed!
end
end
A solution for this problem, was implemented with the hlr_sync_lock. This method can be found in sync_lock.rb file and is called in RequestIssue
(request_issue.rb). Within the sync_decision_issues
method, hlr_sync_lock wraps around the transaction. This will create a lock key: hlr_sync_lock:#{EPE.id} in redis and this will create the sync lock with the key value pair if it doesn't already exist and an expiration time is given upon creation. Once the sync has been completed, the lock key is removed.
updated request_issue.rb with hlr_sync_lock
def sync_decision_issues!
return if processed?
fail NotYetSubmitted unless submitted_and_ready?
clear_error!
attempted!
# pre-fetch the internal veteran record before we start the transaction
# to avoid a slow BGS call causing the transaction to timeout
end_product_establishment.veteran
hlr_sync_lock do
transaction do
return unless create_decision_issues
end_product_establishment.on_decision_issue_sync_processed(self)
clear_error!
close_decided_issue!
processed!
end
end
end
hlr_sync_lock will stop any other request issues associated with the current EPE from syncing with BGS concurrently if the claim is a Higher Level Review. This will ensure that the remand supplemental claim generation that occurs within on_decision_issue_sync_processed will not be inadvertently bypassed due to two request issues from the same claim being synced at the same time. If this situation does occur, one of the request issues will error out with Caseflow::Error:SyncLockFailed and be picked up to sync again later
sync_lock.rb
def hlr_sync_lock
if decision_review.is_a?(HigherLevelReview) && block_given?
redis = Redis.new(url: Rails.application.secrets.redis_url_cache)
lock_key = "hlr_sync_lock:#{end_product_establishment.id}"
begin
# create the sync lock with a key, value pair only
# IF it doesn't already exist and give it an expiration time upon creation
sync_lock_acquired = redis.set(lock_key, "lock is set", :nx => true, :ex => LOCK_TIMEOUT.to_i)
fail Caseflow::Error::SyncLockFailed, message: "#{Time.zone.now}" unless sync_lock_acquired
# set expire as another failsafe
redis.expire(lock_key, LOCK_TIMEOUT.to_i)
yield
ensure
redis.del(lock_key)
end
elsif block_given?
yield
end
end
- Home
- Acronyms and Glossary
- Caseflow products
- Caseflow Intake
- Caseflow Queue
- Appeals Consumer
- Caseflow Reader
- Caseflow eFolder
- Caseflow Hearings
- Caseflow Certification
- Caseflow APIs
- Appeal Status API
- Caseflow Dispatch
-
CSUM Roles
- System Admin
- VHA Team Management
- Active Record Queries Resource
- External Integrations
- Caseflow Demo
- Caseflow ProdTest
- Background
- Stuck Jobs
- VA Notify
-
Caseflow-Team
- Tier 4
- Bat Team
- Technical Documentation
- Backend Code Patterns
- Backend Working Group
- FACOLS, VACOLS DB Schema
- Asyncable Models
- External Data: where and why
- Data Fetching Scripts
- Caseflow Data Model and Dictionary
- User Access Permissions
- Controller Schemas
- Constants
- Frontend Best Practices
- Accessibility
- How-To
- Debugging Tips
- Adding a Feature Flag with FeatureToggle
- Editing AMA issues
- Editing a decision review
- Fixing task trees
- Investigating and diagnosing issues
- Data and Metric Request Workflow
- Exporting and Importing Appeals
- Explain page for Appeals
- Record associations and Foreign Keys
- Upgrading Ruby
- Stuck Appeals
- Testing Action Mailer Messages Locally
- Re-running Seed Files
- Rake Generator for Legacy Appeals
- Manually running Scheduled Jobs
- System Admin UI
- Caseflow Makefile
- Upgrading Postgresql from v11.7 to v14.8 Locally
- VACOLS VM Trigger Fix M1
- Using SlackService to Send a Job Alert
- Technical Talks