Skip to content

Page cache map access is not synchronized #59

@hugithordarson

Description

@hugithordarson

NGPageCache._cacheMap and _allEntries are accessed without synchronization in savePage(), restorePageFromCache(), retainPageWithContextIDInCache(), and retainRootEntry(). Per-entry ReentrantLocks exist but the map structure itself is not thread-safe.

Impact

Concurrent access can cause:

  • ConcurrentModificationException
  • Lost cache entries
  • Inconsistent reads
  • Memory visibility issues across threads

Symptoms would appear under concurrent load — exactly when a framework most needs to be reliable.

Fix

Either:

  • Replace HashMaps with ConcurrentHashMap, or
  • Guard map operations with a lock around the entire critical section (less ergonomic but possibly necessary if multi-map invariants exist)

The comment at line 19 acknowledges the cache is experimental — promote to non-experimental by making it thread-safe.

Severity

Important — concurrency bug that surfaces under load. M2 blocker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions