Skip to content

Disk quota: skip the startup cache traversal for stores that do not track usage - #1615

Open
aaime wants to merge 1 commit into
GeoWebCache:mainfrom
aaime:quotastore_skip_trackers
Open

aaime wants to merge 1 commit into
GeoWebCache:mainfrom
aaime:quotastore_skip_trackers

Conversation

@aaime

@aaime aaime commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

At startup, DiskQuotaMonitor traverses the cache of every layer whose saved usage is zero, to compute it (assuming they are new/untracked). A quota store that discards usage (like DummyQuotaStore in GeoServer) reports zero for every layer, so the monitor walks the whole tile cache and then throws the result away. GeoServer installs that store while the disk quota is disabled, which is the default. On a large cache on network storage the traversal takes hours of CPU and file system load, and it runs again at every disk quota save and every GWC reload.

In this PR, QuotaStore gets a default method, tracksUsage(), that returns true. When the store returns false, the monitor skips the traversal. The BDB and JDBC stores keep the default, so standalone GWC behaves as before
with the quota disabled it still records usage, as the disk quota documentation describes.

@jodygarnett jodygarnett 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.

Minor suggestion to use isUsageTracked() for consistency with other methods in DiskQuota.

* of the tile cache, since this store would discard the computed usage. A store that wraps another must delegate
* this call.
*/
default boolean tracksUsage() {

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.

Suggested change
default boolean tracksUsage() {
default boolean isUsageTracked() {

The rest of this class uses get / set naming? with plain method names for actions...

* {@link LayerQuota#getUsedQuota() used quota} already loaded, when the store records usage.
*/
private LayerCacheInfoBuilder launchCacheInfoGatheringThreads() throws InterruptedException {
if (!quotaStore.tracksUsage()) {

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.

Suggested change
if (!quotaStore.tracksUsage()) {
if (!quotaStore.isUsageTracked()) {

replay(calculator);

QuotaStore store = createNiceMock(QuotaStore.class);
expect(store.tracksUsage()).andReturn(tracksUsage).anyTimes();

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.

Suggested change
expect(store.tracksUsage()).andReturn(tracksUsage).anyTimes();
expect(store.isUsageTracked()).andReturn(tracksUsage).anyTimes();

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.

2 participants