Project

General

Profile

Bug #2137

Bad invalidation of good resource in concurrency situation

Added by Henning Blohm 4 months ago. Updated 8 days ago.

Status:
Feedback
Priority:
Urgent
Assignee:
Category:
z2-core
Target version:
Start date:
02.08.2022
Due date:
% Done:

0%

Estimated time:
origin:

Description

The code in com.zfabrik.impl.resources.NamespaceImpl._getResourceHandleImplNonNull(String) may run into a concurrency situation, where a collected resource handle leads to a repeated tick() and invq adding and then invalidation of a concurrently just newly created resource.

Example

  • Threads T1, T2.
  • Resource name N

Flow:

  1. T1: lookup for N returns value holder with null resource handle.
  2. T1: Goes into looping = true
  3. T1: leaves synchronized block
  4. T2: runs tick() and enters synchronized block
  5. T2: Creates and adds new resource handle
  6. T2: leaves synchronized block
  7. T1: enters synchronized block again
  8. T1: finds that it is looping and the value holder for N is not in the invQ and hence puts it into invQ (although the resource handle is NOT null anymore!!!)
  9. T1: invalidates the resource for N right away

Acceptance Criteria

  • When looping for pending invalidations make sure not to accidentally consider a valid non-null handle as to be invalidated

Test Cases

  • com.zfabrik.test.core.resources.tests.Invalidations.concurrentLookupOfCollectedResource: Concurrent lookup and GCing on weakly held resource.
#1

Updated by Henning Blohm 4 months ago

  • Description updated (diff)
#2

Updated by Henning Blohm 4 months ago

  • Status changed from In Progress to Feedback
#3

Updated by Henning Blohm 8 days ago

  • Target version changed from 2.9.2 to 2.10

Also available in: Atom PDF