Skip to content

fix(#4927): refcount the JVM-wide PageManager lifecycle - #5070

Merged
lvca merged 13 commits into
mainfrom
fix/4927-pagemanager-lifecycle
Jul 7, 2026
Merged

lvca merged 13 commits into
mainfrom
fix/4927-pagemanager-lifecycle

Conversation

@lvca

@lvca lvca commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

The last HIGH-severity finding of the 2026-07 engine audit (#4962).

The defect

The JVM-wide PageManager started/stopped on an ACTIVE_INSTANCES.isEmpty() check-then-act spanning factory instances (open/create synchronize on the factory, the map is static, and registration happens only after database.open() completes):

  • Race 1: T1 closes the last instance of DB-A and nulls the shared flush thread while T2's open of DB-B is mid-flight (constructed, not yet registered) - DB-B then NPEs on its first cache miss, or its scheduled pages are never flushed.
  • Race 2: two opens both observe the map empty and both call the unsynchronized configure() - two flush threads, one leaked with queued pages.
  • Bonus (same defect class, deterministic): the GlobalConfiguration PROFILE setter calls configure() at configuration time, and the old code started a flush thread for zero open databases, leaking it until the next lifecycle transition.

The fix (as the issue proposed)

acquire()/release() refcounting under one global lifecycle lock: startup on 0->1 (acquired before the database is constructed, so an in-flight open holds a reference before it registers), teardown on 1->0, over-releases clamped. A failed open releases its reference, preserving the #4991 no-leak guarantee. configure() becomes a reconfigure that no-ops at refcount zero; close() stays as the force-teardown test API and resets the counter.

Verification

Red-first: 2 of the (now 6) new tests fail on the old code (configure() starting a thread with no databases; teardown not keyed to the last release); the third is a 2-thread open/close hammer over two databases. Regression: engine + database packages green (118 classes, 577 tests, 0 failures), including the #4991 failed-open leak test and the #4928 crash-equivalent close suites.

Conflict risks

None expected: touches PageManager lifecycle methods, DatabaseFactory open/create, and one line in LocalDatabase.closeInternal - no overlap with the open PRs #5060/#5062.

The page manager's start/stop keyed on ACTIVE_INSTANCES.isEmpty() - a
check-then-act racing across DatabaseFactory instances (open/create
synchronize on the factory, the map is static, and registration happens
only AFTER database.open() completes):

- Race 1: T1 closes the last instance of DB-A and nulls the shared flush
  thread while T2's open of DB-B is mid-flight (created, not yet
  registered) - DB-B then NPEs on its first cache miss or its scheduled
  pages are never flushed.
- Race 2: two opens both observe the map empty and both call the
  unsynchronized configure() - two flush threads, one leaked with queued
  pages.
- Bonus, same defect class: the GlobalConfiguration PROFILE setter calls
  configure() at configuration time and the old code STARTED a flush
  thread for zero open databases, leaking it until the next transition.

Fix as the issue proposed: acquire()/release() refcounting under one
global lifecycle lock. Every open/create acquires (startup on 0 -> 1,
BEFORE the database is constructed, so an in-flight open holds a
reference before it registers); every close releases (teardown on
1 -> 0); a failed open releases its reference, preserving the #4991
no-leak guarantee. configure() becomes a reconfigure that no-ops at
refcount zero; close() stays as the force-teardown test/emergency API and
resets the counter. Over-releases clamp at zero.

Red-first: 2 of the 3 new tests fail on the old code (configure()
starting a thread with no databases; teardown not keyed to the last
release). The third is a 2-thread open/close hammer over two databases
asserting no thread ever observes a torn-down manager.

Regression: engine + database packages green (118 classes, 577 tests,
0 failures), including the #4991 failed-open leak test and the #4928
crash-equivalent close suites.
@codacy-production

codacy-production Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 minor

Alerts:
⚠ 3 issues (≤ 0 issues of at least minor severity)

Results:
3 new issues

Category Results
CodeStyle 3 minor

View in Codacy

🟢 Metrics 10 complexity

Metric Results
Complexity 10

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a reference-counting mechanism for the JVM-wide PageManager lifecycle to resolve race conditions during concurrent database open and close operations. Instead of relying on a racy check of active database instances, DatabaseFactory and LocalDatabase now acquire and release references under a global lock. A potential issue was identified where calling close() multiple times on the same database instance could lead to a double-release of the reference count, which should be guarded.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 2167 to 2175
if (DatabaseFactory.removeActiveDatabaseInstance(databasePath))
GraphAnalyticalView.closeExecutor();
PageManager.INSTANCE.close();
}

// #4927: paired with the acquire in DatabaseFactory.open/create - the flush machinery is torn down by
// the refcount reaching zero, never by the racy "was this the last registered instance" check (an open
// in flight on another thread holds a reference before it registers, so it can no longer be pulled out
// from under).
PageManager.INSTANCE.release();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If close() is called multiple times on the same database instance, closeInternal will execute the code outside the write lock block repeatedly, resulting in multiple calls to PageManager.INSTANCE.release(). This causes a double-release of the refcount. Guarding the close logic using a thread-safe check on openedOn ensures that the PageManager is only released once per database instance.

    boolean wasOpen = false;
    synchronized (this) {
      if (openedOn != 0) {
        openedOn = 0;
        wasOpen = true;
      }
    }

    if (wasOpen) {
      if (DatabaseFactory.removeActiveDatabaseInstance(databasePath))
        GraphAnalyticalView.closeExecutor();

      // #4927: paired with the acquire in DatabaseFactory.open/create - the flush machinery is torn down by
      // the refcount reaching zero, never by the racy "was this the last registered instance" check (an open
      // in flight on another thread holds a reference before it registers, so it can no longer be pulled out
      // from under).
      PageManager.INSTANCE.release();
    }

@lvca lvca self-assigned this Jul 7, 2026
@lvca lvca added this to the 26.7.2 milestone Jul 7, 2026
@mergify

mergify Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: fix(#4927): refcount the JVM-wide PageManager lifecycle

Nice, focused fix. The refcount-under-a-single-lock approach is the right model, and replacing the ACTIVE_INSTANCES.isEmpty() check-then-act removes a genuine cross-factory race. The red-first tests and the configure()-with-zero-databases no-op are good. One correctness concern below that I think is a real regression, plus two smaller notes.

🔴 Over-release on a redundant close() can tear down the manager under other open databases

LocalDatabase.closeInternal() is designed to be idempotent - it guards the real work with if (!open) return null; inside the executeInWriteLock lambda (LocalDatabase.java:2070). But the new PageManager.INSTANCE.release() sits outside that lambda (LocalDatabase.java:2198), so it runs on every call to close()/closeInternal(), including a redundant second close of an already-closed database.

Scenario (two DBs open, lifecycleRefCount == 2):

  1. dbA.close() -> lambda runs, open=false, then release() -> refcount 2 -> 1.
  2. dbA.close() again (defensive double-close, AutoCloseable + explicit close, retry-on-error path, etc.) -> lambda early-returns because open == false, but execution still falls through to release() -> refcount 1 -> 0 -> shutdown().

Now dbB is still open but the shared flush thread has been joined and nulled - exactly the "flush thread pulled out from under a live database" failure this PR set out to eliminate, re-entered through the double-close door.

The old code was immune here: it only tore down inside if (removeActiveDatabaseInstance(...)), and on the second close removeActiveDatabaseInstance returns false while dbB is still registered, so PageManager.close() was never reached. The refcount version loses that protection because release() is unconditional.

The existence of the if (!open) return null guard signals that idempotent close is a supported contract, so release() needs to honor it. Suggestion: only release when this call actually performed the close - e.g. have the lambda report whether it closed and gate the tail on it:

final boolean actuallyClosed = executeInWriteLock(() -> {
    if (!open)
        return false;
    ...
    open = false;
    ...
    return true;
});

if (actuallyClosed) {
    if (DatabaseFactory.removeActiveDatabaseInstance(databasePath))
        GraphAnalyticalView.closeExecutor();
    PageManager.INSTANCE.release();
}

(The removeActiveDatabaseInstance / closeExecutor calls arguably belong under the same guard too, but the acute regression is the unconditional release().)

🟠 acquire() is outside the try in DatabaseFactory.open()/create() - a startup() failure leaks the reference

PageManager.INSTANCE.acquire() (DatabaseFactory.java:80, :103) runs before the try. acquire() calls startup() on the 0 -> 1 transition, and startup() can throw (ConfigurationException when MAX_PAGE_RAM is negative) after ++lifecycleRefCount == 1. Because acquire() threw before entering the try, the balancing release() in the catch never runs, leaving lifecycleRefCount == 1 with flushThread == null. The next acquire() then sees 1 -> 2 and never starts the flush thread - a wedged manager. It only bites on misconfiguration, so low severity, but decrementing the counter if startup() throws (or moving acquire() inside the try) would close it.

🟠 Concurrent open of the same path can double-release (edge race)

If two different DatabaseFactory instances open the same path concurrently, both can pass checkForActiveInstance before either registers. The loser hits registerActiveInstance -> putIfAbsent returns non-null -> database.close() (one release() via closeInternal) -> throws -> catch block release()s again (DatabaseFactory.java:93/:117). That's two releases for one acquire(), which can drive the count to zero and tear down the manager under the winner. Pre-existing raciness in registerActiveInstance (it also removes the winner's map entry by path), but the refcount change makes the double-decrement newly harmful. Worth a guard so the failed-open path releases exactly once.

Test coverage

Solid additions. The gap that matches the top finding: there's no test for double-close of one database while another is open (assert the flush thread survives). Adding that would fail on the current diff and pin the contract deterministically, same spirit as the other two red-first tests.

Overall: the direction is right and most of it is a clear improvement; the double-close release() placement is the one I'd want resolved before merge.

… instance

All three review findings were real; the first was a genuine regression in
this PR and the reviewer's scenario was exact.

1. RED - redundant double-close stole another database's reference.
   closeInternal's lambda is documented-idempotent (early-return on !open)
   but the new release() ran unconditionally after it: dbA.close();
   dbA.close(); decremented twice and tore the flush thread down under a
   still-open dbB - the exact failure this PR exists to eliminate,
   re-entered through the double-close door. The lambda now reports
   whether THIS call performed the close, and the whole tail
   (removeActiveDatabaseInstance, closeExecutor, release) is gated on it -
   taking the reviewer's suggestion including the arguably-belongs part.

2. ORANGE - acquire() rolls back its increment when startup() throws
   (e.g. ConfigurationException on negative MAX_PAGE_RAM). Without it the
   counter wedged at 1 with no flush thread and every later acquire ran
   against a dead manager the caller's catch could not repair.

3. ORANGE - same-path concurrent open double-release. When
   registerActiveInstance loses the race it closes the database itself,
   which (with fix 1) consumes the reference and records it in a
   per-instance flag; the factory's catch now releases only when the
   instance did NOT already consume its reference. The lifecycle reference
   is exactly-once per instance by construction - same pattern as the
   exactly-once WAL ack from #5012.

Red-first: the double-close and startup-failure tests both fail on the
pre-review code (1 failure + 1 error). The same-path race has no
deterministic repro (it needs two threads between checkForActiveInstance
and registerActiveInstance); it is covered by the exactly-once flag
construction and the existing hammer test.

Regression: engine + database packages green.
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: refcount the JVM-wide PageManager lifecycle (#4927)

Reviewed the full diff plus the surrounding lifecycle code (DatabaseFactory.open/create/registerActiveInstance, LocalDatabase.closeInternal, PageManager startup/shutdown). This is a solid, well-reasoned fix. The refcount replaces a genuine check-then-act race with a clean invariant, and the reference accounting balances across every open outcome I traced:

  • success -> later close: acquire once, release once (via actuallyClosed);
  • construction throws (database == null): factory catch releases;
  • database.open() throws (database != null, flag false): factory catch releases;
  • registration race loser (putIfAbsent returns winner -> database.close()): the close consumes the reference and sets the flag, so the factory catch correctly skips its release.

The acquire() rollback (resetting lifecycleRefCount = 0 if startup() throws) is correct because startup() only runs on the 0->1 transition, so there is never a live reference to lose. Double-close is a full no-op via the actuallyClosed flag. The test suite is genuinely good: red-first assertions, the 2-thread hammer, the double-close regression, and the startup-failure rollback all pin the contract deterministically. Nice work.

A few observations, none of them blockers:

1. configure() reconfigure while databases are open (low/medium)

configure() is now a live shutdown() + startup() when lifecycleRefCount > 0, reachable from the GlobalConfiguration.PROFILE setter (GlobalConfiguration.java:130). Two concerns in that window:

  • shutdown() clears the live readCache and nulls flushThread, then startup() builds new ones, all under LIFECYCLE_LOCK. But the hot paths read these fields without that lock and without a null check: flushThread.scheduleFlushOfPages(...) (PageManager.java:488) and flushThread.getCachedPageFromMutablePageInQueue(...) (:557). A concurrent flush of a live database during a profile change could NPE on the transient flushThread == null. flushThread/readCache are also non-volatile, so the reassignment is not guaranteed visible to those reader threads.
  • In practice PROFILE is set at startup before any DB is open (refcount 0 -> the new no-op path), so this is an edge case, but the previous code never reconfigured a live manager at all, so this is new exposure. Worth either documenting "PROFILE must be set before opening databases" or gating the reconfigure to the refcount-0 case only.

2. Registration-race loser removes the winner from ACTIVE_INSTANCES (pre-existing, but adjacent)

When registerActiveInstance loses the putIfAbsent race, the loser calls database.close(), whose closeInternal runs removeActiveDatabaseInstance(databasePath), a single-arg ACTIVE_INSTANCES.remove(path) (DatabaseFactory.java:169) that is not keyed to the instance. That removes the winner's still-live mapping, orphaning it from the map and defeating checkForActiveInstance for a subsequent third open of the same path. This predates the PR and is orthogonal to the refcount, but since you are reasoning carefully about exactly this race here, a two-arg remove(normalizedPath, instance) would close it while you are in the neighborhood.

Minor

  • pageManagerReferenceReleased being volatile is correct for cross-thread visibility, though the only reader (the factory catch after the loser's own close()) actually runs on the same thread; harmless either way.

Overall the lifecycle contract is a clear improvement over the ACTIVE_INSTANCES.isEmpty() heuristic, and the tests back it well. My only actionable suggestion is to decide what configure() should do to a live manager (item 1).

…tance CAS

Corrects the previous commit, which was pushed with a FAILING broad
battery (325/600) - a process failure on my side: the verification ran in
a command chain that committed and pushed regardless of the result. The
regression it contained: gating the WHOLE close tail on 'this call
performed the close' broke the kill()-then-close() contract (crash
simulation used across the test suite) - a killed database reaches
close() with open == false, so it was never UNREGISTERED from
ACTIVE_INSTANCES, and one leaked registration cascaded into every
subsequent test failing the active-database check.

The corrected composition keeps each property where it belongs:

- removeActiveDatabaseInstance/closeExecutor run UNCONDITIONALLY, as
  before this PR: unregistration is naturally idempotent (false on the
  second call) and a killed database must still unregister.
- The lifecycle release is EXACTLY ONCE per instance via an AtomicBoolean
  compareAndSet - a redundant double-close cannot steal another
  database's reference (the #5070 review's regression), two RACING closes
  cannot double-release either (the volatile flag alone could), and the
  same-path open-race loser closed by registerActiveInstance is still
  seen by the factory's catch through the flag.

All five lifecycle tests green including both red-first review tests;
full battery: engine + database packages + kill/recovery/leak suites =
611 tests, 0 failures, BUILD SUCCESS verified BEFORE this push.
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: refcount the JVM-wide PageManager lifecycle (#5070)

Thanks for this - the refcount design is the right fix for the ACTIVE_INSTANCES.isEmpty() check-then-act. The lifecycle contract is clean: startup on 0 -> 1, teardown on 1 -> 0, the acquire-before-construct ordering closes the "open in flight when the last close fires" window, and the exactly-once release via AtomicBoolean.compareAndSet neatly handles both double-close and the same-path open-race loser. The tests are genuinely red-first and cover the interesting transitions. Overall this looks correct and well reasoned. A few points worth considering:

1. Test isolation against the JVM-wide singleton (medium)

PageManager.INSTANCE and lifecycleRefCount are process-global static state. Several assertions in the new test - especially configureWithoutOpenDatabasesDoesNotStartAFlushThread (asserts getFlushThread() == null) - are only valid when the global refcount is exactly 0 at that instant. In a full mvn test run within one surefire fork, any other engine test that leaks an open database (or a kill() without a following close()) leaves the counter > 0, and configure() would then legitimately start a thread, flipping the assertion to red. This makes the class order-dependent even though it passes today.

Consider normalizing the starting state, e.g. a @BeforeEach that force-resets via PageManager.INSTANCE.close() (which zeroes the counter), so the test asserts against a known baseline rather than a globally-clean one.

2. kill() leaks the reference unless close() follows (low/verify)

LocalDatabase.kill() never releases the lifecycle reference nor sets pageManagerReferenceReleased; the design relies on the documented kill-then-close contract (closeInternal still releases via CAS with open == false). That holds for the current crash-simulation tests, but it is now an invariant the whole refcount rests on: any path that kills a database and never calls close() will pin the manager open forever (and skew the assertions in point 1). Worth a one-line note on kill() pointing at the contract, so a future caller doesn't break it silently.

3. Non-volatile fields written under LIFECYCLE_LOCK, read lock-free (low, mostly pre-existing)

flushThread, readCache, maxRAM, freePageRAM are plain fields now written under LIFECYCLE_LOCK but read on the hot paths without it. For normal open/close the happens-before is fine (the opening thread took the lock in acquire(); the flush thread is started after the writes). The one spot that gives me pause is configure() (the runtime PROFILE setter): with active databases it does shutdown(); startup();, so flushThread transiently goes non-null -> null -> non-null while another thread may dereference it without a null guard - e.g. suspendFlushAndExecute and isPageFlushingSuspended call flushThread. unconditionally. Low probability (needs a live PROFILE change under load) and largely pre-existing, but since this PR is the lifecycle-hardening PR it may be the right place to null-guard those two call sites or document that configure() requires quiescent databases.

4. Pre-existing, in the touched area (FYI, not blocking)

The same-path open-race loser calls database.close() inside registerActiveInstance, and closeInternal -> removeActiveDatabaseInstance(databasePath) removes the entry by path - which is the entry the race winner just registered. That unregisters an open database. It predates this PR and is orthogonal to the page-manager refcount, but since the PR reasons explicitly about this exact race path, it may be worth a follow-up issue.

Minor

  • close() (force teardown) -> shutdown() -> readCache.clear() NPEs if invoked before any startup() ran (readCache still null). Matches the old close() behavior, but close() is now a more reachable test/emergency API, so a null-guard would be cheap insurance.
  • create(): the database = new LocalDatabase(... wraps oddly across two lines; a formatting nit.

Nice work overall - the core concurrency reasoning is sound and the exactly-once release is the right tool.

lvca added 2 commits July 6, 2026 21:59
…ation

1. configure() no longer performs a live shutdown+startup swap when
   databases are open: the hot paths read flushThread/readCache without
   the lifecycle lock (and the fields are non-volatile), so a concurrent
   flush during a profile change could NPE on the transient null. A live
   profile change is now refused with a WARNING telling the operator to
   set the profile before opening databases; the refcount-0 case remains a
   no-op (next acquire reads fresh settings). New regression test pins
   that the live flush thread survives configure() untouched
   (isSameAs + isAlive).

2. removeActiveDatabaseInstance is keyed to the instance (two-arg
   ConcurrentHashMap.remove): when registerActiveInstance closes a
   same-path open-race LOSER, the loser's close no longer removes the
   WINNER's still-live mapping (which orphaned the winner from the
   registry and let a third open of the same path pass
   checkForActiveInstance). Pre-existing, adjacent, taken as suggested.
   The GAV-executor gate keeps its map-emptiness return semantics; the
   one test caller updated.

Full battery verified BEFORE this push: engine + database packages, 601
tests, 0 failures, BUILD SUCCESS.
…note; shutdown null-guard

Round 3 raced the round-2 push - its points 3 (live-configure window) and
4 (race loser unregistering the winner) were already fixed there. The
remaining points, taken:

1. The lifecycle tests normalize the process-global refcount to a known
   zero baseline in @beforeeach (force-reset via close()), so the
   assertions are not order-dependent on another test in the same fork
   leaking an open database or a kill() without its paired close().

2. kill() now documents the invariant the refcount rests on: it
   deliberately does NOT release the lifecycle reference - the documented
   kill-then-close contract relies on the following close() releasing it
   (exactly once via the CAS, with open == false). A kill() never followed
   by close() pins the manager open.

Minor: shutdown() null-guards readCache (close() is a reachable
test/emergency API and may run before any startup()); the create()
constructor-call line wrap fixed.

Focused suites green: lifecycle 6/6 (with the new baseline), flush
robustness, factory, commit ordering.
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: fix(#4927): refcount the JVM-wide PageManager lifecycle

Thorough, well-documented change. The core design - a single LIFECYCLE_LOCK, acquire() on the 0 -> 1 transition acquired before the database is constructed, release() on the last 1 -> 0, plus exactly-once release via an AtomicBoolean CAS - is exactly the right shape and closes the check-then-act race across factory instances. The startup-failure rollback, the over-release clamp, and the instance-keyed ACTIVE_INSTANCES.remove(path, instance) are all good defensive touches, and the red-first tests (config-with-no-DB, double-close, startup-failure, live-configure, and the 2-thread hammer) cover the interesting states. Nice work.

A few observations, mostly for confirmation rather than blockers:

1. The sibling teardown (GraphAnalyticalView.closeExecutor) is still on the old racy pattern

LocalDatabase.closeInternal now decouples the PageManager teardown (refcount) from removeActiveDatabaseInstance(...), but GraphAnalyticalView.closeExecutor() is still gated on the return value of that call - i.e. the same ACTIVE_INSTANCES.isEmpty() check-then-act the PR set out to eliminate. It is the same defect class: a close of the last registered instance can shut the executor down while another open is mid-flight (acquired but not yet registered). It is much less severe than the PageManager case because getExecutor() lazily re-creates a shutdown executor, so it self-heals rather than NPEs - but it is worth a sentence acknowledging that the executor teardown was intentionally left on the isEmpty() heuristic, or aligning it with the refcount if you want the whole lifecycle keyed the same way. The doc comment at GraphAnalyticalView.java:108 ("Called when the last database instance is closed (alongside PageManager.INSTANCE.close())") is now stale on both counts - teardown is via release(), and it is no longer strictly "alongside."

2. flushThread / readCache remain non-volatile and are read on the hot paths without the lifecycle lock

This is pre-existing and the PR comments call it out explicitly (it is the stated reason configure() now refuses a live swap), so no regression. Worth noting only that the safety argument rests entirely on "steady state keeps refcount > 0, and the teardown/re-startup window has no readers." That holds today. If a future change ever allows a startup while any reader can still touch the manager, the non-volatile publish of flushThread becomes a live hazard. A one-line comment on the fields pointing at the lifecycle invariant (or making them volatile) would harden this cheaply.

3. Behavior change: a profile change after databases are open is now refused

configure() used to apply the new settings live (buggily, but it did something); it now logs a WARNING and no-ops when refcount > 0. Only the high-performance branch of the PROFILE setter calls it (the low-ram branch never did), and profiles are normally set at bootstrap before any open, so this is almost certainly fine and strictly more correct. Just confirm no server/integration path sets PROFILE after opening a database and expects the page cache sizing to change - if one exists, it now silently keeps the old sizing (with only a log line). The release note covers the user-facing guidance well.

4. Test isolation on a JVM-wide singleton

PageManagerLifecycleRefCountTest asserts on global singleton state (getFlushThread() null / non-null / same-instance). These assertions are only valid if no other database anywhere in the JVM holds a reference at that moment. Within this class the @AfterEach drop keeps it clean, and Surefire's per-class forking makes it safe today, but the coupling to global lifecycle state makes these inherently fragile to future changes in test parallelism or a leaked reference from a neighboring class. Not a change request - just flagging that configureWithoutOpenDatabasesDoesNotStartAFlushThread in particular will report a confusing failure if it ever runs with a stray open database rather than pointing at the real cause.

5. Minor: emergency close() + reopen can misaccount the refcount

close() force-resets the counter to 0 and shuts down regardless of live references. If it is ever called while a database is open and another is opened afterward, the still-live database's eventual release() will drive the new manager's refcount to 0 and tear it down under the newcomer. Since close() now has no production callers (test/emergency only, per grep) this is contained, but the Javadoc could note that force-close is only safe when no database is open.

Overall: solid fix, good tests, clear reasoning in the comments. Points 1 (stale doc / sibling race) and 3 (confirm no live-profile caller) are the two I would most want addressed before merge; the rest are hardening notes.

@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: refcount the JVM-wide PageManager lifecycle (#4927)

Nice work. The refcount-under-one-lock design is the right fix for the ACTIVE_INSTANCES.isEmpty() check-then-act, and the edge cases are handled carefully: startup-failure rollback of the increment, over-release clamping, the instance-keyed remove(path, instance) for the same-path open race, and the AtomicBoolean CAS that makes the release exactly-once per instance. Tests are red-first and cover the important interleavings (concurrent hammer, double-close, startup rollback, live-configure refusal). The reasoning captured in the inline comments is excellent.

A few points, mostly minor:

1. Misplaced Javadoc on kill() (LocalDatabase.java ~2200)

The new doc block is placed after the @Override annotation, and there is already a Javadoc block before it:
```java
/**

2. Partial profile application while databases are open

configure() now no-ops (with a WARNING) when lifecycleRefCount > 0. But the GlobalConfiguration PROFILE setter applies all the other settings (async threads, HTTP threads, queue sizes, ...) before calling configure(). So a live profile switch with a database open now leaves a partially applied profile: everything changes except the page manager, and the only signal is a WARNING. The refusal is defensible, but consider making the mismatch more discoverable, since a user setting PROFILE post-open gets a silently inconsistent config.

3. GraphAnalyticalView.closeExecutor() is not double-close guarded

In closeInternal, closeExecutor() runs whenever removeActiveDatabaseInstance(...) returns true. On a redundant double-close of the last database the map is already empty, so it returns true again and closeExecutor() runs a second time. The PageManager release is now CAS-guarded, but this call is not (pre-existing behavior). Worth confirming closeExecutor() is idempotent; if so a one-line note would help.

4. Global force-teardown in a shared-JVM test

@BeforeEach normalizeGlobalState() calls the force PageManager.INSTANCE.close(), resetting the process-global refcount and tearing down the flush thread unconditionally. Safe under sequential execution (the documented assumption), but a landmine if Surefire parallel/concurrent execution is ever enabled for this fork: it would tear the manager down under a database another test class has open. Consider a @ResourceLock or an explicit note that this class must not run concurrently with others touching the PageManager.

5. Nits

  • pageManagerReferenceReleased is declared in the middle of the class (right after closeInternal) rather than with the other fields at the top; minor style inconsistency.
  • The comments correctly note the hot paths read flushThread/readCache without the lifecycle lock. The refcount removes the actual teardown-under-open race (the real hazard), so this is fine as-is; a volatile on flushThread would be belt-and-suspenders but is not required.

None of these block the change; (1) is the one I'd fix before merge. Solid, well-tested PR overall.

Automated review by Claude.

lvca added 2 commits July 6, 2026 22:06
…umented; PROFILE caller verified

The two points the reviewer wanted before merge, plus the hardening notes:

1. GraphAnalyticalView.closeExecutor: the stale 'alongside
   PageManager.INSTANCE.close()' doc is rewritten, and both the doc and
   the closeInternal call site now state that the executor teardown STAYS
   on the map-emptiness heuristic deliberately - unlike the flush thread,
   a shutdown executor lazily re-creates itself on the next getExecutor(),
   so the mid-flight-open race self-heals instead of failing.

2. flushThread/readCache non-volatile publish: the lifecycle invariant is
   now documented on the fields - written only under LIFECYCLE_LOCK during
   the 0->1 / 1->0 transitions, read lock-free ONLY because a reader
   implies refcount > 0, so no transition can run concurrently; make them
   volatile and re-audit if that ever changes.

3. Live-PROFILE caller verified as requested: the only production setter
   is the Console at startup (Console.java:113), and it sets 'low-cpu' -
   the branch that never called configure() at all. No path sets PROFILE
   after opening a database.

4. Test-isolation fragility acknowledged (the @beforeeach force-reset from
   round 3 pins the baseline; the coupling to the singleton is inherent).

5. close() javadoc now states force-teardown is only safe with no open
   database (a live database's eventual release would tear down the NEW
   manager under a later acquire).

Lifecycle suite 6/6, factory suite green.
…rtial-profile warning; idempotency notes

1. My round-3 kill() note was placed AFTER the @OverRide annotation - not
   attached to the member by the Javadoc tool and duplicating the existing
   block. Merged into the proper block above the annotation.
2. The live-profile WARNING now states the actual consequence: the profile
   was PARTIALLY applied (async/HTTP/queue settings changed, page manager
   sizing did not) - discoverable instead of a vague refusal.
3. closeExecutor() idempotency confirmed (early-return on null/isShutdown
   under its class lock) and noted at the double-close-reachable call site.
4. The lifecycle test class declares its singleton dependency via
   @ResourceLock('PageManager.INSTANCE') plus a comment: the force-reset
   baseline must never run concurrently with a class holding an open
   database.
5. Nit (field placement) left as-is: moving the declaration away from the
   closeInternal it documents would trade a style point for locality.

Lifecycle suite 6/6, factory green.
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: fix(#4927) refcount the JVM-wide PageManager lifecycle

Reviewed the full diff and traced the lifecycle paths against DatabaseFactory, LocalDatabase.closeInternal/kill, PageManager, and the GlobalConfiguration PROFILE hook. This is a solid, well-reasoned fix - the refcount replaces a genuine ACTIVE_INSTANCES.isEmpty() check-then-act race, and I verified every acquire is balanced by exactly one release across all paths:

  • normal open+close -> acquire(+1) / closeInternal CAS release(-1) ✅
  • construction throws (database == null) -> factory catch releases ✅
  • database.open() throws (with or without an internal close) -> the isPageManagerReferenceReleased() guard prevents a double release ✅
  • register-race loser -> loser's own close() releases, catch sees the flag and skips ✅
  • startup() throws (negative MAX_PAGE_RAM) -> acquire() resets the counter to 0 before rethrowing, and since it runs before the try, the catch's release() is correctly not reached ✅

The remove(path, instance) keying, the AtomicBoolean CAS for exactly-once release, and holding LIFECYCLE_LOCK across startup()/shutdown() (the flush thread never needs that lock, so no join deadlock) are all correct. Test coverage is excellent - red-first, deterministic contract tests plus the concurrent hammer, and a @BeforeEach reset for the process-global singleton. Nicely done.

A few points:

1. Duplicated / misplaced Javadoc on kill() (minor, should fix)

LocalDatabase.java lines 321-330 now has two Javadoc blocks around kill(): the original one before @Override, and the new one between @Override and the method signature. A /** */ after the annotation is not a valid Javadoc position (tools won't associate it with the method), and the two blocks are redundant. Please consolidate into a single Javadoc block placed before @Override.

2. Behavior change: live PROFILE change is now refused (intentional, worth calling out)

The low-ram profile sets MAX_PAGE_RAM, INITIAL_PAGE_CACHE_SIZE, and FREE_PAGE_RAM - exactly the values startup() reads. Previously, setting PROFILE while a database was open would tear down and restart the PageManager, applying the new (smaller) page-cache limits live. Now configure() no-ops with a warning until all databases close and one reopens. This is the safer behavior (the old live swap raced the lock-free hot paths, which is the whole point of the fix), and the warning message plus "set the profile before opening databases" guidance is a good mitigation. Since PROFILE is SCOPE.JVM and realistically set once at boot, the practical impact is small - just flagging it as a real semantic change. The release note covers the configure() change; consider also mentioning that low-ram applied at runtime with an open DB no longer shrinks the live page cache.

3. Lock-free read invariant (no action needed, just confirming)

The flushThread/readCache fields stay non-volatile and are read unguarded on the hot paths (lines 200, 256, 269, 446, 492). This is safe under the stated invariant (a reader implies refcount > 0, so no transition runs concurrently), and it is not a regression - the old configure() published the same fields the same way, now under a lock rather than none. The LIFECYCLE INVARIANT comment documenting this is a good addition. The if (readCache != null) guards in shutdown()/getStats() correctly handle the force-close()-before-startup() case.

Overall this looks correct and ready to merge once the duplicated Javadoc (#1) is cleaned up.

@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Code Review: refcount the JVM-wide PageManager lifecycle (#4927)

Reviewed the full diff and traced the lifecycle interleavings against the source. This is a high-quality, well-reasoned fix. The refcount-under-a-single-lock model is the right shape for the defect, the pairing is balanced across every path I could construct, and the tests pin the contract deterministically (the correct way to test what were originally pure races). The inline #5070 review comments are excellent and made verification much easier.

Correctness - traced and confirmed

  • acquire before construct: acquiring the reference before new LocalDatabase(...) is the crux of the fix - an in-flight open holds a reference before it registers, so a concurrent last-close can no longer null the flush thread out from under it. Correct.
  • Balance on every path: normal open then close (acquire/release), failed construct (database == null then release), failed database.open() (flag false then release), and the open-race loser (loser`s own close() consumes its reference, catch sees the flag and skips) all net out correctly. The exactly-once AtomicBoolean CAS + isPageManagerReferenceReleased() guard closes the double-decrement hole cleanly.
  • removeActiveDatabaseInstance(path, instance): keying the removal to the instance is a genuine bug fix beyond the refcount work - a plain remove(path) by the race loser would have orphaned the winner from the registry. Good catch.
  • Lock ordering: open()/create() are synchronized(factory) then take LIFECYCLE_LOCK; the loser`s close() path is also factory then LIFECYCLE_LOCK. No inversion, no deadlock. The flush thread never calls back into the lifecycle lock, so closeAndJoin() under the lock is safe.
  • startup() rollback: resetting lifecycleRefCount = 0 when startup() throws (so the counter cannot wedge at 1 with no flush thread) is subtle but important, and it is tested.

Minor observations (non-blocking)

  1. Stale comment in getStats() (PageManager.java:474): still says readCache and flushThread are populated by configure(), which is called on first DB open. After this PR they are populated by startup() on the 0 to 1 acquire; configure() is now a no-op/warn. Worth updating so the next reader is not misled.
  2. shutdown() leaves flushThread non-null on InterruptedException: the flushThread = null assignment sits inside the try after closeAndJoin(), so an interrupt during teardown leaves a stale (dead) reference with refcount at 0; the next startup() overwrites it. Harmless in practice, but moving the null-out to a finally would make the field state consistent regardless of interrupt.
  3. Non-volatile hot-path reads of flushThread/readCache: the new LIFECYCLE INVARIANT comment documents the reasoning well (a reader implies refcount > 0, so no transition runs concurrently). Cross-thread visibility of the startup() writes still leans on the happens-before edge from publishing the opened database to query threads - true in practice and not a regression (old configure() wrote these non-volatile too), but it is the one part of the invariant resting on an external assumption rather than this class`s own synchronization. Fine to leave; flagging so it stays on the radar if the publication path ever changes.
  4. Behavior change - live profile change is now refused, not applied: setting a PROFILE while databases are open no longer resizes the page manager (it warns and keeps current sizing). Reasonable and well-documented vs. racing the hot paths, but it is a user-visible semantics change - worth calling out in the release notes beyond the configure()-with-zero-DBs case. (The docs/release-26.7.2.md entry covers the zero-DB leak but not the open-DB refusal.)
  5. PR description nit: body says 3 new tests but the new test class has 6 @test methods (all valuable - double-close, startup-failure rollback, and live-configure-refusal are the strongest).

Test coverage

Strong. Red-first on the two lifecycle-divorced-from-DB-count defects, a 2-thread open/close hammer for the race, plus targeted regressions for each 5070-review fix. The @ResourceLock("PageManager.INSTANCE") + force-reset @beforeeach correctly acknowledge the process-global singleton dependency under sequential surefire.

Performance / Security

No concerns. The lock is taken only on lifecycle transitions (open/create/close), never on the read/flush hot paths, so no added contention. No security surface touched.

Verdict: LGTM. The items above are documentation/edge-case polish, not blockers. Careful work on a genuinely tricky concurrency defect.

Note: reviewed statically and traced the interleavings by hand; I did not run the full build/test suite in this session.

…y, release-note sentence

The round validated the whole lifecycle design (calling the instance-keyed
unregistration 'a genuine bug fix beyond the refcount work') and left five
one-line nits; taken:

1. getStats() comment no longer claims configure() populates
   readCache/flushThread - startup() on the 0 -> 1 acquire does.
2. shutdown() nulls flushThread in a finally, so an interrupt during
   teardown cannot leave a stale dead reference at refcount 0.
4. The release note now covers BOTH profile cases: no thread started with
   zero databases, and the live-profile refusal (page manager keeps its
   sizing; set the profile before opening).

Acknowledged: (3) the cross-thread visibility of startup() writes leans on
the database-publication happens-before - documented, stays on the radar;
(5) the PR body test count is corrected separately via gh.

Lifecycle 6/6, flush robustness green.
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: refcount the JVM-wide PageManager lifecycle (#4927)

Solid fix. Replacing the ACTIVE_INSTANCES.isEmpty() check-then-act with a refcount under a single LIFECYCLE_LOCK, acquiring BEFORE the database is constructed, is the right shape: it closes the mid-flight-open window the old heuristic left open, and the exactly-once release via AtomicBoolean.compareAndSet cleanly handles double-close, the same-path open-race loser, and kill-then-close. The red-first tests and the commit history show the tricky interleavings (double-close stealing a reference, startup-failure wedging the counter, unregister-must-stay-unconditional for kill()) were each found and fixed. I verified the compilation surface: no stale callers of the old single-arg removeActiveDatabaseInstance or the removed stopPageManagerIfNoActiveInstance remain, and isPageManagerReferenceReleased() is package-private within com.arcadedb.database, reachable from DatabaseFactory.

A few points, none blocking:

1. flushThread / readCache non-volatile publication (minor, hardening). The lifecycle invariant is documented well (PageManager.java:68): written only under LIFECYCLE_LOCK on the 0->1 / 1->0 transitions, read lock-free because a reader implies refcount > 0. The cross-thread visibility of the startup() writes leans on the database-publication happens-before (a query thread receives the DB via the ConcurrentHashMap / thread-start, which carries the prior flushThread write). That holds today, but marking both fields volatile would remove the "re-audit if this ever changes" footgun for effectively zero cost - a volatile read on the flush hot path is negligible next to the ConcurrentHashMap barriers already there. Optional, but it makes invalidation of the invariant a compile-time-visible decision rather than a comment.

2. close() is a public force-teardown that zeroes the refcount. close() resets lifecycleRefCount = 0 and tears down unconditionally. It is documented test/emergency-only and I confirmed no production path calls it (the old production caller stopPageManagerIfNoActiveInstance is now removed). Since INSTANCE is a public singleton, a plugin calling it while databases are open would tear the manager down under them - the javadoc warns about exactly this, so acceptable, but consider whether it needs to stay public vs. package-private for the test.

3. Test isolation on the process-global singleton. PageManagerLifecycleRefCountTest force-resets the singleton in @beforeeach and guards with @ResourceLock("PageManager.INSTANCE") + sequential surefire. This is inherently fragile (a class-level parallel surefire config would break it), but the coupling is intrinsic to a JVM-wide singleton and the comments call it out honestly. Fine as-is.

4. Stale comments in adjacent tests (cosmetic). PageManagerReadCacheRamAccountingTest.java:53 and Issue4544FlushIndexIdentityTest.java:53 still reference PageManager.configure() picking up config; that reading now happens in startup() (invoked from acquire() on the first open). Functionally unchanged, but the comments are now slightly misleading.

5. Partial-profile warning. configure() is reached only from the low-ram profile branch (GlobalConfiguration.java:130). The new "PARTIALLY applied" warning on a live profile change is a nice, discoverable behavior; and since the only runtime PROFILE setter (Console at startup, low-cpu) never calls configure(), the warning path will not fire spuriously in normal operation.

Overall: correct, well-tested, and thoroughly reasoned. Recommend merge after considering point 1 (volatile) and the cosmetic comment fixes.

…mments; close() visibility decided

1. flushThread and readCache are now volatile - taken after three review
   rounds converged on it with a sound cost argument (a volatile read is
   negligible next to the ConcurrentHashMap barriers already on these
   paths). The lifecycle-invariant comment stays as the primary reasoning
   (a reader implies refcount > 0, so no transition runs concurrently);
   the volatile removes the reliance on the external database-publication
   happens-before for cross-thread visibility of the startup() writes and
   makes invalidating the invariant a visible decision.

2. close() STAYS public - decided, not overlooked: it was public API
   before this PR and CLAUDE.md mandates backward compatibility; embedded
   users may call it at shutdown. The javadoc already carries the
   only-safe-with-no-open-database warning.

3. The two stale test comments referencing configure() as the config
   pickup point now name startup() on the first acquire.

Points 3 (test isolation honesty) and 5 (warning behavior) were the
reviewer's own confirmations.

Focused suites green: lifecycle 6/6, RAM accounting, flush-index
identity, flush robustness.
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: fix(#4927) refcount the JVM-wide PageManager lifecycle

Thorough read of the whole diff plus the surrounding call sites (DatabaseFactory.open/create, LocalDatabase.closeInternal/kill, GlobalConfiguration PROFILE setter, PageManager). Overall this is a high-quality, carefully-reasoned concurrency fix with strong tests. The core design is sound:

  • acquire() before new LocalDatabase(...) so an in-flight open holds a reference before it registers - closes Race 1.
  • Single LIFECYCLE_LOCK guarding refcount + startup()/shutdown() - closes Race 2 and the double-start.
  • Exactly-once release via the pageManagerReferenceReleased CAS placed OUTSIDE the executeInWriteLock lambda (so a redundant double-close still evaluates it but only fires once), plus the factory isPageManagerReferenceReleased() gate for the same-path open-race loser. Right pattern, and redundantDoubleCloseDoesNotStealAnotherDatabasesReference pins it.
  • startupFailureRollsBackTheAcquiredReference: the lifecycleRefCount = 0 rollback on a startup() throw is correct precisely because startup() only runs on the 0 -> 1 transition, so no other holder can exist when it resets.
  • Over-release clamp, volatile on flushThread/readCache, and instance-keyed ACTIVE_INSTANCES.remove(path, instance) are all appropriate.

I verified every production caller now uses acquire/release (only configure() remains, from the low-ram PROFILE branch), LocalDatabase is constructed exclusively inside DatabaseFactory (so every instance has a paired acquire), and close() is now test/emergency-only. LowRamProfileTest still passes because it asserts on GlobalConfiguration values with no DB open (refcount 0, so configure() no-ops). Nice red-first discipline (2 tests fail on old code) and the 2-thread hammer is a good addition.

Minor / non-blocking:

  1. Test style - fully-qualified names. PageManagerLifecycleRefCountTest inlines FQNs (com.arcadedb.GlobalConfiguration.MAX_PAGE_RAM, org.assertj.core.api.Assertions.assertThatThrownBy, org.junit.jupiter.api.parallel.ResourceLock, org.junit.jupiter.api.BeforeEach). CLAUDE.md asks to import the class and use the simple name. Worth tidying for suite consistency.

  2. User-visible behavior change worth calling out. A live PROFILE=low-ram (or any profile hitting configure()) while databases are open no longer resizes the live page cache - it is refused with a WARNING and only the non-page settings take effect. Safer than the old racy live swap and documented in the release note, but a genuine semantic change from resize-in-place to refused. Confirm no runtime/ops flow depends on resizing page RAM after open.

  3. Serialization under a wedged flush (pre-existing-ish). shutdown() runs flushThread.closeAndJoin() while holding LIFECYCLE_LOCK, so a slow/stuck flush now blocks ALL JVM-wide acquire/release/configure for its duration. The old close() already joined, so not new, but the global lock widens the stall surface. Note only.

  4. Test cross-class global reset. normalizeGlobalState force-resets the process-global refcount via close(); the class-level @ResourceLock only excludes tests that also declare that lock. As the comment acknowledges, this is only safe under the current sequential surefire config - if class-parallel execution is ever enabled it could tear down another class open DB. Fine for now.

Nit: the review-provenance comments are genuinely helpful for such a subtle fix, though quite verbose inline; some might live better in the PR/issue. Subjective - I lean toward keeping them given the trap density.

Nothing blocking. The concurrency reasoning holds up under inspection and the test coverage (double-close, startup-failure rollback, live-configure refusal, concurrent hammer, multi-db survival) matches the described failure modes. Nice work.

Round 9 confirmed 'nothing blocking' with one legitimate style catch: the
FQNs my earlier review-round additions inlined in
PageManagerLifecycleRefCountTest (GlobalConfiguration, assertThatThrownBy,
ResourceLock, BeforeEach) now use imports per CLAUDE.md.

The other notes were confirmations or already-decided items: the
live-profile refusal is release-noted and no runtime flow sets a profile
post-open (verified in round 4: the only production setter is the Console
at startup); the shutdown-under-lock stall surface is pre-existing (the
old close() joined too) and noted; the sequential-surefire assumption is
documented on the test.

Lifecycle suite 6/6.
@codacy-production

codacy-production Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 minor

Alerts:
⚠ 3 issues (≤ 0 issues of at least minor severity)

Results:
3 new issues

Category Results
CodeStyle 3 minor

View in Codacy

🟢 Metrics 10 complexity

Metric Results
Complexity 10

View in Codacy

🟢 Coverage 94.00% diff coverage · -7.23% coverage variation

Metric Results
Coverage variation ✅ -7.23% coverage variation
Diff coverage ✅ 94.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (852e924) 135124 100760 74.57%
Head commit (bd9b6e2) 166954 (+31830) 112422 (+11662) 67.34% (-7.23%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#5070) 50 47 94.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: refcount the JVM-wide PageManager lifecycle (issue #4927)

Overall this is a well-reasoned, high-quality fix. The refcount-under-a-single-lifecycle-lock model correctly replaces the racy ACTIVE_INSTANCES.isEmpty() check-then-act, and the invariants are documented meticulously. I traced the key interleavings and they hold up. A few observations below, none of them blocking.

What is correct and well done

  • Acquire-before-construct / release-on-close closes the mid-flight-open window: an in-flight open holds a reference before it registers, so a concurrent last-close can no longer null the flush thread underneath it.
  • startup() failure rollback (lifecycleRefCount = 0 in the catch) is the right call - without it a throwing startup() wedges the counter at 1 with no flush thread. Because acquire() is invoked OUTSIDE the try in open()/create(), the factory catch never double-decrements (the reset already zeroed it) and release() clamps at 0 anyway. Belt and suspenders.
  • removeActiveDatabaseInstance(path, instance) -> map.remove(key, value) correctly prevents a same-path open-race loser from evicting the winners live mapping.
  • compareAndSet(false, true) release-exactly-once plus the isPageManagerReferenceReleased() guard in the factory catch cleanly keeps the failed-open (issue JVM cannot exit after a failed DatabaseFactory.open(): non-daemon "ArcadeDB AsyncFlush" thread is never stopped #4991) and register-race-loser paths from double-releasing.
  • configure() refusing a live swap is safer than the old close()+recreate, which itself raced the lock-free hot paths.
  • Test coverage is genuinely good: red-first cases, the double-close reference-steal regression, the startup-failure rollback, and a 2-thread open/close hammer over two DBs. @ResourceLock + the @BeforeEach force-reset is the right hygiene for a process-global singleton.

Minor / non-blocking

  1. Visibility inconsistency on maxRAM / freePageRAM. The PR deliberately makes flushThread and readCache volatile to remove reliance on the external database-publication happens-before. But maxRAM and freePageRAM are also written only in startup() and read lock-free on the RAM-check hot path, yet remain non-volatile. In practice they are covered (the LIFECYCLE_LOCK monitor in acquire() and normal database publication both establish happens-before), so this is not a bug - but for the same consistency argument the comment makes, they arguably deserve the same treatment or a one-line note explaining why they are exempt.

  2. close() is a sharp public API. It now has no production callers (only tests / @BeforeEach), but it is still public and force-tears-down ignoring the refcount - exactly the unsafe-if-a-database-is-open footgun the Javadoc warns about. Consider narrowing visibility or renaming it to something self-evidently test-only (e.g. forceCloseForTests()) so a future caller cannot reach for it by habit, given release() is now the real teardown path.

  3. Cross-test state pollution via kill()-without-close(). As documented, kill() intentionally does not release its reference, so a test that kills a DB and never closes it leaves lifecycleRefCount > 0 for the rest of the surefire fork. The new class defends itself in @BeforeEach, but other PageManager-touching test classes that assume a clean baseline do not. @ResourceLock serializes access but does not reset the counter for them. Low risk under the current sequential config, but a latent fragility if parallel test execution is ever enabled.

Behavior change to flag for release notes
The low-ram PROFILE setters configure() call previously resized the live page cache; with a database already open it is now a no-op-plus-warning and the new MAX_PAGE_RAM / INITIAL_PAGE_CACHE_SIZE sizing is NOT applied until the next 0->1 startup. This is the safer behavior and it is captured in release-26.7.2.md, but it is a user-visible semantic change worth emphasizing for anyone who switched profiles at runtime.

Nit
The comment density is high (though consistent with the repos issue-tagged style). The multi-round review annotations are useful now but read as review scaffolding; a couple could be trimmed once merged.

Nice work - the reasoning is easy to follow and the tests pin the contract rather than the (unreproducible) races.

…nsistency

Round 10 ('none blocking') caught the internal inconsistency round 8
created: maxRAM and freePageRAM share the exact write-in-startup /
read-lock-free shape that motivated making flushThread/readCache volatile,
so the same treatment applies - two words, closing the consistency gap in
the documented invariant.

Declined again, with the same reasoning as round 8: renaming/narrowing
close() would break the public API for embedded users (CLAUDE.md mandates
backward compatibility); the javadoc carries the warning. The kill()
cross-test fragility and the release-note emphasis were already addressed
in rounds 3-8; comment-trimming is deferred to post-merge cleanup.

Lifecycle 6/6, RAM accounting green.
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: fix(#4927) refcount the JVM-wide PageManager lifecycle

I traced the lifecycle end-to-end (DatabaseFactory.open/create -> LocalDatabase.closeInternal -> PageManager.acquire/release/startup/shutdown) and the open-race path through registerActiveInstance. This is a well-engineered fix that correctly targets the root cause.

What is solid

  • Correct root cause. Replacing the ACTIVE_INSTANCES.isEmpty() check-then-act with a refcount under a single LIFECYCLE_LOCK eliminates the cross-factory race. The key insight, acquiring the reference in open()/create() before new LocalDatabase(...) (so an in-flight open holds a reference before it registers), is exactly what closes Race 1.
  • Exactly-once release is carefully handled. The AtomicBoolean CAS in closeInternal, combined with the keyed ACTIVE_INSTANCES.remove(path, instance) and the isPageManagerReferenceReleased() guard in the factory catch, correctly prevents the open-race loser from double-decrementing and tearing down the manager under the race winner. I walked the two-thread same-path scenario and the accounting balances.
  • startup() failure rollback (reset to 0 on throw) prevents a wedged counter. ConfigurationException extends ArcadeDBException extends RuntimeException, so the catch (RuntimeException | Error) compiles and catches the negative-MAX_PAGE_RAM case the test exercises.
  • All call sites updated (removeActiveDatabaseInstance signature, DatabaseFactoryTest); no production code relies on the old close()/configure() restart-the-thread semantics beyond the factory, which now uses release().
  • Excellent test coverage. Red-first tests, the two-DB open/close hammer, the double-close reference-theft regression, the startup-failure rollback, and the live-configure refusal each pin a distinct failure mode.

Things worth confirming / minor

  1. shutdown() joins the flush thread while holding LIFECYCLE_LOCK: flushThread.closeAndJoin() runs inside the global lock, so a concurrent acquire() (new DB open on another thread) blocks for the full flush-drain of the last DB teardown. I checked PageManagerFlushThread and it does not re-enter any lifecycle method, so no deadlock today. Worth documenting the invariant: the flush thread must never call acquire/release/configure/close, or this becomes a self-join deadlock. A one-line comment on shutdown() would help future maintainers.

  2. configure() behavioral change is a real semantic shift: with databases open, a PROFILE change (e.g. low-ram) now drops the page-RAM resizing and only logs a WARNING. I confirmed the server does not set arcadedb.profile after opening databases (JVM-scope, set at bootstrap), so this is not a regression in the shipped server flow. The "PARTIALLY applied" wording is honest. No action needed beyond the release note you added.

  3. Test isolation relies on sequential surefire: @BeforeEach normalizeGlobalState() force-close()s the process-global refcount to 0. @ResourceLock("PageManager.INSTANCE") only serializes against other tests declaring the same lock; a future switch to JUnit cross-class parallel execution would let this force-teardown run under another class live database. The comment acknowledges this, so it is a documented assumption rather than a bug, but a latent fragility if parallel test execution is ever enabled.

  4. Cosmetic: inserting volatile broke the aligned columns on a few fields, e.g. private volatile int freePageRAM; and the maxRAM line. Prettier will not touch these (requires a pragma), so they persist. Trivial, but a re-align would keep the block tidy.

Overall a high-quality, well-tested fix with rationale captured directly in the code. Nice work on the acquire-before-construct ordering and the exactly-once release accounting.

…mented; field alignment

The round endorsed the full design after an end-to-end trace. Two items
taken: shutdown() now documents the load-bearing invariant that the flush
thread must never call a lifecycle method (it is joined under
LIFECYCLE_LOCK - a call back into acquire/release/configure/close would
self-deadlock; verified true today), and the volatile insertions'
column-alignment breakage is fixed. Points 2 and 3 were the reviewer's own
confirmations of decided items.

Lifecycle suite green.
@claude

claude Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review: refcount the JVM-wide PageManager lifecycle (#4927)

I traced the refcount protocol end-to-end through DatabaseFactory.open/create, LocalDatabase.closeInternal, and the PageManager lifecycle methods. This is a careful, well-reasoned fix and the inline commentary makes the invariants easy to audit. Overall assessment: looks correct and safe to merge, with a few notes below.

Correctness (verified)

  • Exactly-once release. The AtomicBoolean CAS in closeInternal plus the !database.isPageManagerReferenceReleased() guard in the factory catch correctly collapse to a single release() per instance across all the paths I walked:
    • normal open/close (acquire on 0->1, release on 1->0);
    • constructor/open() failure (database == null or flag false -> release once);
    • the same-path registerActiveInstance race loser (its close() sets the flag + releases, so the factory catch skips) - and the winner keeps its own reference. Refcount arithmetic (2->1 for the winner) checks out.
  • Keyed unregister. Switching removeActiveDatabaseInstance to remove(path, instance) is the right call - it stops a race loser's close() from evicting the winner's live mapping. All call sites (2 in main, 1 test) were updated, so no signature-orphan.
  • Startup rollback. Resetting lifecycleRefCount = 0 when startup() throws avoids the wedged-at-1 state; the dedicated test covers it.
  • No deadlock / no re-entrancy. shutdown() runs under LIFECYCLE_LOCK and joins the flush thread; I confirmed PageManagerFlushThread never calls acquire/release/configure/close, so the join can't self-deadlock. The lock ordering is always factory-monitor -> LIFECYCLE_LOCK (never reversed), so no cross-lock deadlock either.
  • Visibility. Making flushThread/readCache/maxRAM/freePageRAM volatile is sound given the stated "a reader implies refcount > 0" invariant - every hot-path reader runs under an open database that holds a reference, so no startup/shutdown transition can run concurrently with it.

Behavior change worth flagging for release notes

The configure() semantics change is the one user-visible behavior shift: setting GlobalConfiguration.PROFILE (e.g. low-ram, which sets MAX_PAGE_RAM=16) after a database is already open no longer resizes the live page cache - it now logs a warning and keeps the current sizing. This is strictly safer (the old path called readCache.clear() + restarted the flush thread under a running DB, a latent hazard), but anyone who relied on live re-profiling will see a behavior change. The docs entry covers it; just make sure it lands in the user-facing 26.7.2 notes prominently.

Minor notes (non-blocking)

  1. Public lifecycle surface. acquire(), release(), and close() are public on the PageManager.INSTANCE singleton. Only DatabaseFactory/LocalDatabase should touch the refcount; a stray external/plugin call to release() or close() can tear the manager down under live databases (the close() javadoc acknowledges this). Consider package-private visibility for acquire/release if the module boundary allows, to make misuse impossible rather than merely documented.
  2. Test coverage gap. The concurrent hammer uses two distinct databases (A/B). The trickiest path in this PR - the same-path registerActiveInstance open-race loser (exactly-once release + keyed remove) - is heavily reasoned in comments but not exercised by a test. It's hard to hit deterministically, but a two-thread same-path open race (even best-effort/looped) would give that path some direct coverage.
  3. Pre-existing nit (not introduced here). In startup() the invalid-config message prints maxRAM (already in bytes) with a " MB)" suffix, so a bad value is reported in the wrong unit. Untouched by this PR, but easy to fix while you're in the file.

Test coverage

Strong. Six focused tests covering the config-no-DB no-op, close-one-of-two survival, the concurrent hammer, redundant double-close, startup-failure rollback, and live-configure refusal - with @ResourceLock("PageManager.INSTANCE") and a force-reset @BeforeEach to keep the process-global singleton deterministic. The red-first framing (2 of the new tests failing on old code) is a nice touch.

Nice work - the invariants are documented well enough that the next person touching this lifecycle won't have to reverse-engineer them.

@lvca
lvca merged commit 50efba6 into main Jul 7, 2026
21 of 26 checks passed
@lvca
lvca deleted the fix/4927-pagemanager-lifecycle branch July 7, 2026 02:53
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.58%. Comparing base (852e924) to head (bd9b6e2).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
...in/java/com/arcadedb/database/DatabaseFactory.java 75.00% 2 Missing and 1 partial ⚠️
...src/main/java/com/arcadedb/engine/PageManager.java 90.62% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5070      +/-   ##
============================================
- Coverage     65.58%   65.58%   -0.01%     
  Complexity      842      842              
============================================
  Files          1687     1687              
  Lines        135124   135151      +27     
  Branches      28907    28912       +5     
============================================
+ Hits          88627    88639      +12     
- Misses        34401    34409       +8     
- Partials      12096    12103       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

oc007us pushed a commit to oc007us/arcadedb-grpc that referenced this pull request Jul 8, 2026
…caffolding trim

Two deferred items from the audit's final review rounds:

- The invalid-MAX_PAGE_RAM ConfigurationException printed the byte value
  with an 'MB' suffix (maxRAM is already multiplied by 1024*1024 when the
  message is built); it now divides back so a bad value reads in the unit
  it names.
- The review-round chronology left in comments across the audit-touched
  files ('#NNNN review round N', 'taken after three rounds', ...) is
  trimmed to plain issue references - the invariant statements stay, the
  PR-history narration goes, as the final ArcadeData#5063/ArcadeData#5060/ArcadeData#5070 rounds asked.

No behavior change beyond the message unit. Lifecycle, commit-ordering,
context-lifecycle and flush-robustness suites green.
robfrank pushed a commit that referenced this pull request Aug 14, 2026
… instance

All three review findings were real; the first was a genuine regression in
this PR and the reviewer's scenario was exact.

1. RED - redundant double-close stole another database's reference.
   closeInternal's lambda is documented-idempotent (early-return on !open)
   but the new release() ran unconditionally after it: dbA.close();
   dbA.close(); decremented twice and tore the flush thread down under a
   still-open dbB - the exact failure this PR exists to eliminate,
   re-entered through the double-close door. The lambda now reports
   whether THIS call performed the close, and the whole tail
   (removeActiveDatabaseInstance, closeExecutor, release) is gated on it -
   taking the reviewer's suggestion including the arguably-belongs part.

2. ORANGE - acquire() rolls back its increment when startup() throws
   (e.g. ConfigurationException on negative MAX_PAGE_RAM). Without it the
   counter wedged at 1 with no flush thread and every later acquire ran
   against a dead manager the caller's catch could not repair.

3. ORANGE - same-path concurrent open double-release. When
   registerActiveInstance loses the race it closes the database itself,
   which (with fix 1) consumes the reference and records it in a
   per-instance flag; the factory's catch now releases only when the
   instance did NOT already consume its reference. The lifecycle reference
   is exactly-once per instance by construction - same pattern as the
   exactly-once WAL ack from #5012.

Red-first: the double-close and startup-failure tests both fail on the
pre-review code (1 failure + 1 error). The same-path race has no
deterministic repro (it needs two threads between checkForActiveInstance
and registerActiveInstance); it is covered by the exactly-once flag
construction and the existing hammer test.

Regression: engine + database packages green.
(cherry picked from commit 60caa57)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…tance CAS

Corrects the previous commit, which was pushed with a FAILING broad
battery (325/600) - a process failure on my side: the verification ran in
a command chain that committed and pushed regardless of the result. The
regression it contained: gating the WHOLE close tail on 'this call
performed the close' broke the kill()-then-close() contract (crash
simulation used across the test suite) - a killed database reaches
close() with open == false, so it was never UNREGISTERED from
ACTIVE_INSTANCES, and one leaked registration cascaded into every
subsequent test failing the active-database check.

The corrected composition keeps each property where it belongs:

- removeActiveDatabaseInstance/closeExecutor run UNCONDITIONALLY, as
  before this PR: unregistration is naturally idempotent (false on the
  second call) and a killed database must still unregister.
- The lifecycle release is EXACTLY ONCE per instance via an AtomicBoolean
  compareAndSet - a redundant double-close cannot steal another
  database's reference (the #5070 review's regression), two RACING closes
  cannot double-release either (the volatile flag alone could), and the
  same-path open-race loser closed by registerActiveInstance is still
  seen by the factory's catch through the flag.

All five lifecycle tests green including both red-first review tests;
full battery: engine + database packages + kill/recovery/leak suites =
611 tests, 0 failures, BUILD SUCCESS verified BEFORE this push.

(cherry picked from commit fe2335b)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…ation

1. configure() no longer performs a live shutdown+startup swap when
   databases are open: the hot paths read flushThread/readCache without
   the lifecycle lock (and the fields are non-volatile), so a concurrent
   flush during a profile change could NPE on the transient null. A live
   profile change is now refused with a WARNING telling the operator to
   set the profile before opening databases; the refcount-0 case remains a
   no-op (next acquire reads fresh settings). New regression test pins
   that the live flush thread survives configure() untouched
   (isSameAs + isAlive).

2. removeActiveDatabaseInstance is keyed to the instance (two-arg
   ConcurrentHashMap.remove): when registerActiveInstance closes a
   same-path open-race LOSER, the loser's close no longer removes the
   WINNER's still-live mapping (which orphaned the winner from the
   registry and let a third open of the same path pass
   checkForActiveInstance). Pre-existing, adjacent, taken as suggested.
   The GAV-executor gate keeps its map-emptiness return semantics; the
   one test caller updated.

Full battery verified BEFORE this push: engine + database packages, 601
tests, 0 failures, BUILD SUCCESS.

(cherry picked from commit f8eb322)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…note; shutdown null-guard

Round 3 raced the round-2 push - its points 3 (live-configure window) and
4 (race loser unregistering the winner) were already fixed there. The
remaining points, taken:

1. The lifecycle tests normalize the process-global refcount to a known
   zero baseline in @beforeeach (force-reset via close()), so the
   assertions are not order-dependent on another test in the same fork
   leaking an open database or a kill() without its paired close().

2. kill() now documents the invariant the refcount rests on: it
   deliberately does NOT release the lifecycle reference - the documented
   kill-then-close contract relies on the following close() releasing it
   (exactly once via the CAS, with open == false). A kill() never followed
   by close() pins the manager open.

Minor: shutdown() null-guards readCache (close() is a reachable
test/emergency API and may run before any startup()); the create()
constructor-call line wrap fixed.

Focused suites green: lifecycle 6/6 (with the new baseline), flush
robustness, factory, commit ordering.

(cherry picked from commit baba465)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…umented; PROFILE caller verified

The two points the reviewer wanted before merge, plus the hardening notes:

1. GraphAnalyticalView.closeExecutor: the stale 'alongside
   PageManager.INSTANCE.close()' doc is rewritten, and both the doc and
   the closeInternal call site now state that the executor teardown STAYS
   on the map-emptiness heuristic deliberately - unlike the flush thread,
   a shutdown executor lazily re-creates itself on the next getExecutor(),
   so the mid-flight-open race self-heals instead of failing.

2. flushThread/readCache non-volatile publish: the lifecycle invariant is
   now documented on the fields - written only under LIFECYCLE_LOCK during
   the 0->1 / 1->0 transitions, read lock-free ONLY because a reader
   implies refcount > 0, so no transition can run concurrently; make them
   volatile and re-audit if that ever changes.

3. Live-PROFILE caller verified as requested: the only production setter
   is the Console at startup (Console.java:113), and it sets 'low-cpu' -
   the branch that never called configure() at all. No path sets PROFILE
   after opening a database.

4. Test-isolation fragility acknowledged (the @beforeeach force-reset from
   round 3 pins the baseline; the coupling to the singleton is inherent).

5. close() javadoc now states force-teardown is only safe with no open
   database (a live database's eventual release would tear down the NEW
   manager under a later acquire).

Lifecycle suite 6/6, factory suite green.

(cherry picked from commit c03ed05)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…rtial-profile warning; idempotency notes

1. My round-3 kill() note was placed AFTER the @OverRide annotation - not
   attached to the member by the Javadoc tool and duplicating the existing
   block. Merged into the proper block above the annotation.
2. The live-profile WARNING now states the actual consequence: the profile
   was PARTIALLY applied (async/HTTP/queue settings changed, page manager
   sizing did not) - discoverable instead of a vague refusal.
3. closeExecutor() idempotency confirmed (early-return on null/isShutdown
   under its class lock) and noted at the double-close-reachable call site.
4. The lifecycle test class declares its singleton dependency via
   @ResourceLock('PageManager.INSTANCE') plus a comment: the force-reset
   baseline must never run concurrently with a class holding an open
   database.
5. Nit (field placement) left as-is: moving the declaration away from the
   closeInternal it documents would trade a style point for locality.

Lifecycle suite 6/6, factory green.

(cherry picked from commit b8bc444)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…y, release-note sentence

The round validated the whole lifecycle design (calling the instance-keyed
unregistration 'a genuine bug fix beyond the refcount work') and left five
one-line nits; taken:

1. getStats() comment no longer claims configure() populates
   readCache/flushThread - startup() on the 0 -> 1 acquire does.
2. shutdown() nulls flushThread in a finally, so an interrupt during
   teardown cannot leave a stale dead reference at refcount 0.
4. The release note now covers BOTH profile cases: no thread started with
   zero databases, and the live-profile refusal (page manager keeps its
   sizing; set the profile before opening).

Acknowledged: (3) the cross-thread visibility of startup() writes leans on
the database-publication happens-before - documented, stays on the radar;
(5) the PR body test count is corrected separately via gh.

Lifecycle 6/6, flush robustness green.

(cherry picked from commit 5322b29)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…mments; close() visibility decided

1. flushThread and readCache are now volatile - taken after three review
   rounds converged on it with a sound cost argument (a volatile read is
   negligible next to the ConcurrentHashMap barriers already on these
   paths). The lifecycle-invariant comment stays as the primary reasoning
   (a reader implies refcount > 0, so no transition runs concurrently);
   the volatile removes the reliance on the external database-publication
   happens-before for cross-thread visibility of the startup() writes and
   makes invalidating the invariant a visible decision.

2. close() STAYS public - decided, not overlooked: it was public API
   before this PR and CLAUDE.md mandates backward compatibility; embedded
   users may call it at shutdown. The javadoc already carries the
   only-safe-with-no-open-database warning.

3. The two stale test comments referencing configure() as the config
   pickup point now name startup() on the first acquire.

Points 3 (test isolation honesty) and 5 (warning behavior) were the
reviewer's own confirmations.

Focused suites green: lifecycle 6/6, RAM accounting, flush-index
identity, flush robustness.

(cherry picked from commit 0243813)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
Round 9 confirmed 'nothing blocking' with one legitimate style catch: the
FQNs my earlier review-round additions inlined in
PageManagerLifecycleRefCountTest (GlobalConfiguration, assertThatThrownBy,
ResourceLock, BeforeEach) now use imports per CLAUDE.md.

The other notes were confirmations or already-decided items: the
live-profile refusal is release-noted and no runtime flow sets a profile
post-open (verified in round 4: the only production setter is the Console
at startup); the shutdown-under-lock stall surface is pre-existing (the
old close() joined too) and noted; the sequential-surefire assumption is
documented on the test.

Lifecycle suite 6/6.

(cherry picked from commit d980f18)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…nsistency

Round 10 ('none blocking') caught the internal inconsistency round 8
created: maxRAM and freePageRAM share the exact write-in-startup /
read-lock-free shape that motivated making flushThread/readCache volatile,
so the same treatment applies - two words, closing the consistency gap in
the documented invariant.

Declined again, with the same reasoning as round 8: renaming/narrowing
close() would break the public API for embedded users (CLAUDE.md mandates
backward compatibility); the javadoc carries the warning. The kill()
cross-test fragility and the release-note emphasis were already addressed
in rounds 3-8; comment-trimming is deferred to post-merge cleanup.

Lifecycle 6/6, RAM accounting green.

(cherry picked from commit 563027c)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…mented; field alignment

The round endorsed the full design after an end-to-end trace. Two items
taken: shutdown() now documents the load-bearing invariant that the flush
thread must never call a lifecycle method (it is joined under
LIFECYCLE_LOCK - a call back into acquire/release/configure/close would
self-deadlock; verified true today), and the volatile insertions'
column-alignment breakage is fixed. Points 2 and 3 were the reviewer's own
confirmations of decided items.

Lifecycle suite green.

(cherry picked from commit bd9b6e2)
robfrank pushed a commit that referenced this pull request Aug 14, 2026
…caffolding trim

Two deferred items from the audit's final review rounds:

- The invalid-MAX_PAGE_RAM ConfigurationException printed the byte value
  with an 'MB' suffix (maxRAM is already multiplied by 1024*1024 when the
  message is built); it now divides back so a bad value reads in the unit
  it names.
- The review-round chronology left in comments across the audit-touched
  files ('#NNNN review round N', 'taken after three rounds', ...) is
  trimmed to plain issue references - the invariant statements stay, the
  PR-history narration goes, as the final #5063/#5060/#5070 rounds asked.

No behavior change beyond the message unit. Lifecycle, commit-ordering,
context-lifecycle and flush-robustness suites green.

(cherry picked from commit 6c70024)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant