Repository navigation
v0.30.0
Highlights
This release lowers what osfs roots cost on listing, prefix deletes and ranged reads, and changes what a recursive listing or delete does under a symlinked directory. No on-disk format change.
- On
osfs, a recursive listing,CountorDeleteRecursivewhose prefix reaches into a symlinked directory now follows the link, and a delete there removes the target's objects, even when the target lies outside the root (#490). A symlinked directory inside a root is not supported (https://github.com/mojatter/s2/blob/main/docs/backends.md#symlinks-on-osfs), but one set up to serve existing files, sayln -s /srv/media "$S2_SERVER_ROOT/media", has worked for a listing with a delimiter, the console's folder view,Get,Putand a delete by key, on v0.29.0 as on v0.30.0. v0.29.0's recursive walk found nothing under it, so a recursive delete under it removed no object, whether or not it removed the link. v0.30.0 lists, counts and deletes the target's objects; the target directory itself stays. A bucket that is itself a symlink in$S2_SERVER_ROOTis emptied the same way by the console's bucket delete, where v0.29.0 answered204and left the link and its target untouched. The follow is a consequence of the fix below, not a feature: the walk now starts at the prefix's directory, andfs.FSoffers no way to tell a link from a directory there short of reading its parent, which is the read the fix removes; it also matches what the non-recursive listing and the by-key operations already did. Before upgrading, find links to directories under the root withfind -H "${S2_SERVER_ROOT:?}" -type l -exec test -d {} \; -print(-Hmakesfinddescend when the root itself is a link) and remove each withrm, then move its target to the link's path to keep its objects. Links to files are unaffected: both versions list one as an object and read it through the link. Details in https://github.com/mojatter/s2/blob/main/docs/upgrading.md#v0300.- A recursive delete (
DeleteRecursive) into the link, which the console's folder delete sends when no user policy applies, removes the objects under its prefix and then the link, whatever else the target holds. - A client that lists and then deletes by key, such as
aws s3 rm --recursiveor the console's folder delete under a user policy, removes them until a delete empties the target or a directory at its top level and takes the link with it, so the target's other objects can stay on disk while the client reports success.
- A recursive delete (
- A recursive
List,CountorDeleteRecursiveonosfsandmemfsno longer reads the whole root for a prefix inside a directory (#490, fixes #469). v0.29.0 walked from the storage root, so every page underd/read and sorted every ancestor directory of the prefix: on an Apple M4, a 100-key page underd/took 83 ms with 100,000 objects at the root and 0.24 ms after the fix, andDeleteRecursive("d/a")with 100,000 objects in a sibling directory went from 88 ms to 1.10 ms. The walk now starts at the prefix's directory. Results are unchanged on a root without symlinks. ListObjectsV2andListPartsread metadata files in parallel through the news2.PrefetchMetadata(#491, part of #260). Onosfs, aListObjectsV2page opened each object's metadata file one after another to fill in its ETag.s2.PrefetchMetadata(objs)reads theMetadataof a slice of objects on up to 8 goroutines, andListObjectsV2andListPartscall it on the objects they are about to render. On an Apple M4, listing 1000 one-byte objects and reading every ETag went from 47.0 ms to 14.7 ms (BenchmarkListETag→BenchmarkListETagPrefetch, README). A page still reads one metadata file per object, as before; only 8 are open at once.GetandPutare unchanged, and #260 stays open.- Ranged GETs on
osfsare served with sendfile, as full GETs already were (#494, fixes #431).fs'sOpenRangewrapped the seeked file in its own reader, so net could not reach the file and the body went through user space. On an Apple M4 over loopback, a ranged GET of almost all of a 2 GiB object cost the server 0.95 s of CPU before and 0.15 s after, about the same as a full GET. Responses are unchanged. - The README no longer calls the
osfsfsync a durability guarantee (#492). Anosfswrite fsyncs the object and its metadata file before renaming each into place, but not the directories after the rename, so an acknowledged write can still come back as it was before a power loss or kernel crash. That has been so since the write path first fsynced and is tracked in #493; this release changes the wording, not the write path.
Changes
Fixed
- fs: recursive
List,CountandDeleteRecursivewalk from the prefix's directory (path.Dir(prefix)) instead of the root, andDeleteRecursiveskips a directory the prefix rules out, asCountalready did; a prefix under an object (a.txt/x/) still returns an empty result with no error (#490, fixes #469) - fs: on
osfs, a recursiveList,CountandDeleteRecursivewhose prefix reaches into a symlinked directory follow the link, as the non-recursiveListalready did; before, the recursive walk listed, counted and deleted nothing under it (#490)
Performance
- s2: new
PrefetchMetadata(objs []Object)callsMetadata()on every object, on up to 8 goroutines at once, and returns once all are done; it reports no errors (#491, part of #260) - server:
ListObjectsV2prefetches the objects it renders, after the delimiter grouping and themax-keyscut;ListPartsprefetches each page of parts (#491) - fs, server: a ranged GET on
osfsis served with sendfile;fs's range reader exposes its*io.LimitedReaderthrough aLimitedReader()method andserver.CopyBodyhands it to net; no exported type is added (#494, fixes #431)
Documentation
- README: the Go-native benchmark table is re-run (storage-layer PUT on
osfs9.4 ms, GET 83 µs), the fsync paragraph now says the PUT path fsyncs the object and its metadata file (7 to 8 ms of the 9.4 ms) and no longer calls that a durability guarantee (see #493), thememfsratios areGetObjectabout 60x andPutObjectover 1000x, a "Listing" table lists the five List benchmarks, and the warp table is re-run (#492, fixes #261, refs #260) - docs/backends.md: a "Symlinks on osfs" section describes what
osfsdoes with a symlink, replacing the one-line note (#490, #496) - docs/upgrading.md: a v0.30.0 section (#495)
CI / Build
make benchalso runsBenchmarkList,BenchmarkListETag,BenchmarkListETagPrefetch,BenchmarkListMemFSandBenchmarkListETagMemFS; the List benchmarks seed their objects without fsync, somake benchtakes 35 s instead of 61 s (#492)- Bump intra-repo deps to v0.30.0 (#495); v0.29.0 bookkeeping for cmd/s2-server (#489)
Upgrading
- Submodule consumers:
go get github.com/mojatter/s2/<module>@v0.30.0 - s2-server operators running the image:
docker pull mojatter/s2-server:0.30.0(:latestpoints at it too) cmd/s2-server/v0.30.0is published separately, shortly after:go install github.com/mojatter/s2/cmd/s2-server@v0.30.0- No module's
godirective moved andgo.workis unchanged since v0.29.0. - No configuration changes and no on-disk format change; downgrading to v0.29.0 is safe. Operators on an
osfsroot with a symlinked directory under it have something to check before upgrading, in https://github.com/mojatter/s2/blob/main/docs/upgrading.md#v0300. osfswrites are not crash-durable, on this version as on every earlier one: the object and its metadata file are fsynced, the directories after the rename are not (#493). The README said "durability guarantee" until #492; nothing in the write path changed.
Library users
s2:PrefetchMetadata(objs []Object)is new. Call it on aListpage before readingETag,ContentTypeorMetadataof each object. It callsMetadata()once per object on up to 8 goroutines, a fixed count that does not followGOMAXPROCS, takes no context, and returns once every call is done. It reports no errors: a read fails as the accessor would, and onfsan object whose metadata file is missing or corrupt reports an emptyMetadataandContentTypeand falls back to the mtime-size ETag form, as it did before. Ons3,gcsandazblob, whoseListobjects already hold their attributes,Metadata()is a field read, so the call costs only the goroutines.fs: a recursiveList,CountorDeleteRecursiveunder a prefix inside a directory, such asd/ord/2024, no longer reads the root; a prefix at the root's level, such asd, still reads the root, where its keys begin. Results are unchanged on a root without symlinks.fsonosfs: a recursiveListorCountwhose prefix reaches into a symlinked directory now returns the objects of the link's target, andDeleteRecursiveremoves the objects under its prefix, even when the target lies outside the root, and then removes the link, whatever else the target holds; the target directory stays. v0.29.0 returned nothing under such a prefix andDeleteRecursiveremoved no object, whether or not it removed the link. On both versions a prefix that stops at the link lists it as an object, a non-recursiveListunder it returns the target's entries,Get,Put,ExistsandDeleteby key go through the link, and aDeletethat empties the target or a directory at its top level removes the link as well, andDeleteof the link's own key removes nothing and succeeds. A symlink to a file is listed as an object and read through the link on both versions, and a prefix under it returns nothing.memfshas no symlinks. A symlinked directory inside a root stays unsupported.- The
s2.Storageands2.Uploaderinterfaces are unchanged.
Storage implementers
- s2-server now calls
Metadata()on the objects of oneListpage from up to 8 goroutines at once, inListObjectsV2(the objects it is about to render) andListParts(each page of parts). Each object'sMetadata()is called once by the prefetch; the concurrency is across objects of one page, andETag()andContentType()are read afterwards on one goroutine. The Concurrency section of thes2package doc already requiresName,Length,LastModified,Metadata,ContentTypeandETagto be safe for concurrent use and a backend that resolves an attribute lazily to synchronize that itself, so an implementation that follows it needs no change. s2testis unchanged between v0.29.0 and v0.30.0, and none of its checks calls an object's accessors from more than one goroutine, so a backend that resolves an attribute lazily without synchronizing it passess2testand races under s2-server. Run your own test of that under-raceuntil the suite covers it.
s2-server operators
- Read https://github.com/mojatter/s2/blob/main/docs/upgrading.md#v0300.
s3,gcsandazblobroots are unchanged by this release except thatListObjectsV2andListPartsspend a few goroutines on the prefetch. - On
osfsandmemfs, aListObjectsV2without a delimiter, the console's search and the console's folder delete under a prefix inside a directory, such asd/ord/2024, no longer read the bucket's root; a prefix at the bucket's level, such asd, still does.ListObjectsV2andListPartsonosfsread up to 8 metadata files at once. - On
osfs, a symlinked directory inside the root, which is not supported, is now followed by a recursive listing or delete whose prefix reaches into it, even when the target lies outside the root:ListObjectsV2without a delimiter and the console's search list the objects of the link's target, and the two deletes below reach them; the target directory itself stays. v0.29.0 listed nothing under such a prefix, so such a delete removed no object, whether or not it removed the link. A listing from above the link shows it as an object, and a listing with a delimiter, the console's folder view and a delete by key followed the link, on both versions, so a delete by key under the link removed the target's object on v0.29.0 too. A symlink to a file is unaffected: both versions list it as an object and serve it through the link.- A recursive delete under the link, which the console's folder delete sends when no user policy applies, removes the objects under its prefix and then the link, whatever else the target holds.
- A client that lists and then deletes by key, such as
aws s3 rm --recursive s3://<bucket>/<link>/or the console's folder delete under a user policy, removes them one by one until a delete empties the target or a directory at its top level and takes the link with it, after which the remaining deletes and listings find nothing and succeed, so the target's other objects stay on disk while the client reports success.
- This includes a bucket that is itself a symlink in
$S2_SERVER_ROOT: the console's bucket delete now empties the link's target and removes the link, andDeleteBucketdoes the same when the target holds nothing but.keep(otherwise both versions answer409 BucketNotEmpty), where v0.29.0 answered204and left the link and its target untouched, so the bucket stayed. Neither version lists such a bucket inListBucketsor the console. A bucket bind-mounted into the root, as the README's Docker example does, is a directory, not a link, and is unaffected. - To find links to directories before upgrading, run
find -H "${S2_SERVER_ROOT:?}" -type l -exec test -d {} \; -print;-Hmakesfinddescend when the root itself is a link, and the command lists links to directories only. Remove each withrm, then move its target to the link's path to keep its objects: aDeleteObjectof the link's key answers204and leaves it, on both versions. - Ranged GETs on
osfsare served with sendfile, as full GETs already were; responses are unchanged. A write error on a ranged GET other than the client going away is now logged at Error, as for a full GET; the client going away stays at Debug.