Repository navigation
Description
storage-users defaults the filemetadata cache to memory:
FilemetadataCache: config.FilemetadataCache{
Store: "memory",
Nodes: []string{"127.0.0.1:9233"},
Database: "storage-users",
TTL: 24 * time.Hour,
},
IDCache: config.IDCache{
Store: "nats-js-kv",memory is only correct for a single process. As soon as a second process touches the same storage it serves stale metadata:
- multiple pods: the charts only set
OC_CACHE_STORE=nats-js-kvif .Values.nats.endpoint. That guard is pointless, the events config is behind the sameif, so the pods can't work without NATS anyway. Fixed in https://github.com/opencloud-eu/opencloud-charts/pull/423. - CLI commands: we want maintenance commands to consume cpu and memory in the pod that runs them, not in the api pod. The revisions cleanup command (feat: clean up old revisions according to a cleanup strategy reva#895, 🧹 Clean-Up File Versions #1419) is the first one that writes node metadata itself (
uploads sessionsonly reads and sends events). Withmemorythe server keeps listing the revisions it deleted, and the PR has to addos.Statchecks to restore and download to not point a node to a deleted blob. Every other reader still sees the stale entries.
So I'd make nats-js-kv the default. storage-users already depends on NATS for the id cache and the Nodes default points to the embedded NATS, so no new dependency. It's a cache, so no migration. cache_disable_persistence defaults to false, so the cache even survives restarts. Within one process nothing changes: cache.GetFileMetadataCache keeps a process wide registry, so the storageprovider and dataprovider instances share the cache either way.
It also helps operations:
- after restoring a tree or a space from a backup, admins can flush the cache, or just the keys of that space, with the nats CLI. With
memorythe only way is restarting storage-users, unless the posix watcher is enabled and picks up the changes. Since the cache survives restarts now, flushing becomes a required step of a restore, not an option. - when debugging, a nats-box shows what the cache actually holds. The store base32 encodes the keys, so that needs a decode step.
Open points:
- a storage-users CLI helper to list and flush the cache entries of a space or node
- latency on single node installs: every stat, child of a listing and propagation step reads the filemetadata cache, with
nats-js-kvthat's a round trip to NATS instead of a map lookup. The go-micro store has no local tier,Readdoes abucket.Getper key. k8s already runs it, so measure only single node, e.g. with cdperf: PROPFIND depth 1 on a large folder and upload throughput,memoryvsnats-js-kv - a CLI walking a whole space should not fill the shared cache with every node it reads (24h TTL in the KV). It should read past the cache, the cleanup already does that with
Reloadfor the parts that matter - opencloud-compose: run a dedicated NATS, see run a dedicated nats by default opencloud-compose#437
If the single node latency hurts too much ... a local in-memory tier in front of nats-js-kv that drops its entries on KV updates would keep reads in process. The plugin only exposes WatchAll, the service registry already uses it that way.
cc @pbleser-oc
Activity