Skip to content

default the storage-users filemetadata cache to nats-js-kv #4064

Open

Description

@butonic

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",

https://github.com/opencloud-eu/opencloud/blob/main/services/storage-users/pkg/config/defaults/defaultconfig.go#L165-L175

memory is only correct for a single process. As soon as a second process touches the same storage it serves stale metadata:

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 memory the 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-kv that's a round trip to NATS instead of a map lookup. The go-micro store has no local tier, Read does a bucket.Get per key. k8s already runs it, so measure only single node, e.g. with cdperf: PROPFIND depth 1 on a large folder and upload throughput, memory vs nats-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 Reload for 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions