News for hackers. Stuff that matters.
Re:Gcsfuse: A user-space file system for interacting with Go... by paulgb on Wednesday September 06, 2023 @06:28AM (#37403298)
> Cloud Storage FUSE can only write whole objects at a time to Cloud Storage and does not provide a mechanism for patching. If you try to patch a file, Cloud Storage FUSE will reupload the entire file. The only exception to this behavior is that you can append content to the end of a file that's 2 MB and larger, where Cloud Storage FUSE will only reupload the appended content.

I didn’t know GCS supported appends efficiently. Correct me if I’m wrong, but I don’t think S3 has an equivalent way to append to a value, which makes it clunky to work with as a log sink.

Re:Gcsfuse: A user-space file system for interacting with Go... by KptMarchewa on Wednesday September 06, 2023 @06:40AM (#37403368)
I wonder how it handles potential conflicts.
Re:Gcsfuse: A user-space file system for interacting with Go... by londons_explore on Wednesday September 06, 2023 @06:59AM (#37403461)
For appends, the normal way is to apply the append operations in an arbitrary order if there are multiple concurrent writers. That way you can have 10 jobs all appending data to the same 'file', and you know every record will end up in that file when you later scan through it.

Obviously, you need to make sure no write operation breaks a record midway while doing that. (unlike the posix write() API which can be interrupted midway).

Re:Gcsfuse: A user-space file system for interacting with Go... by KptMarchewa on Wednesday September 06, 2023 @07:35AM (#37403656)
That makes sense - if you keep data in something like ndjson and don't require any order.

If you need order then probably writing to separate files and having compaction jobs is still better.

Re:Gcsfuse: A user-space file system for interacting with Go... by boulos on Wednesday September 06, 2023 @08:00AM (#37403828)
Objects have three fields for this: Version, Generation, and Metageneration. There's also a checksum. You can be sure that you were the writer / winner by checking these.
Re:Gcsfuse: A user-space file system for interacting with Go... by dpkirchner on Wednesday September 06, 2023 @10:33AM (#37405744)
You can also send a x-goog-if-generation-match[0] header that instructs GCS to reject writes that would replace the wrong generation (sort of like a version) of a file. Some utilities use this for locking.

0: https://cloud.google.com/storage/docs/xml-api/reference-head...

Re:Gcsfuse: A user-space file system for interacting with Go... by dekhn on Wednesday September 06, 2023 @04:28PM (#37410839)
It's also sensible to have high quality record markers that make identifying and skipping broken records easy. For example, recordio, a record-based container format used at Google in the early mapreduce days (and probably still used today) was explicitly designed to skip corruption efficiently (you don't wnt a huge index build to fail halfway through because a single document got corrupted).

Even so, I avoid parallel appenders to a single file, it can be hard to reason about and debug in ways that having each process appending to its own file doesn't.

Re:Gcsfuse: A user-space file system for interacting with Go... by londons_explore on Wednesday September 06, 2023 @06:55AM (#37403440)
Append workloads are common in distributed systems. Turns out nearly every time you think you need random read/write to a datastructure (eg. a hard drive/block device for a Windows/Linux VM), you can instead emulate that with an append-only log of changes and a set of append-only indexes.

Doing so has huge benefits: Write performance is way higher, you can do rollbacks easily (just ignore the tail of the files), you can do snapshotting easily (just make a new file and include by reference a byte range of the parent), etc.

The downside is from time to time you need to make a new file and chuck out the dead data - but such an operation can be done 'online', and can be done during times of lower system load.

Re:Gcsfuse: A user-space file system for interacting with Go... by capableweb on Wednesday September 06, 2023 @07:31AM (#37403626)
> Append workloads are common in distributed systems.

Bringing back the topic to what the parent was saying; since S3 is a pretty common system, and a distributed system at that, are you saying that S3 does support appending data? AFAIK, S3 never supported any append operations.

Re:Gcsfuse: A user-space file system for interacting with Go... by ozfive on Wednesday September 06, 2023 @07:44AM (#37403716)
It does not. Consider using services like Amazon Kinesis Firehose, which can buffer and batch logs, then periodically write them to S3.
Re:Gcsfuse: A user-space file system for interacting with Go... by vlovich123 on Wednesday September 06, 2023 @12:55PM (#37407773)
I’ll add some nuance here. You can implement append yourself in a clunk way. Create a new multipart upload for the file, copy its existing contents, create a new part appending what you need, and then complete the upload.

Not as elegant / fast as GCS’s and there may be other subtleties, but it’s possible to simulate.

Re:Gcsfuse: A user-space file system for interacting with Go... by merb on Wednesday September 06, 2023 @07:04AM (#37403484)
you just described wal files of a database.
Re:Gcsfuse: A user-space file system for interacting with Go... by tough on Wednesday September 06, 2023 @11:29AM (#37406576)
ha I was just thinking how similar this was to postgres pg-audit way of reusing the logs to sum up the correct state
Re:Gcsfuse: A user-space file system for interacting with Go... by KRAKRISMOTT on Wednesday September 06, 2023 @11:57AM (#37406995)
The generalized architecture is called event sourcing
Re:Gcsfuse: A user-space file system for interacting with Go... by capableweb on Wednesday September 06, 2023 @12:15PM (#37407260)
Well, I'd argue that it's just two different names for similar concepts, but applied at different levels. WAL is a low-level implementation detail, usually for durability, while Event Source is a architecture applied to solve business problems.

A WAL would usually disappear or truncate it's length after a while, and you'd only rerun things from it if you absolutely have two. Changes in business requirements shouldn't require you to do anything with a WAL.

In contrast, Event sourcing log would be kept indefinitely, so when business requirements change, you could (if you want to, not required) re-run N previous events so you can apply new changes to old data in your data storage.

But, if you really want to, it's basically the same, but in the end, applied differently :)

Re:Gcsfuse: A user-space file system for interacting with Go... by slt2021 on Wednesday September 06, 2023 @05:15PM (#37411423)
WAL is just one moving piece of database, that could be using SSTable or LSM tree or some other append-only immutable data structure, and the Event Sourcing is enterprise architecture pattern applied to business applications that heavily relies on immutable append-only data structures as the backbone
Re:Gcsfuse: A user-space file system for interacting with Go... by nicornk on Wednesday September 06, 2023 @07:37AM (#37403666)
With S3 you can do something similar my misusing the multiparty upload functionality, e.g.: https://github.com/fsspec/s3fs/blob/fa1c76a3b75c6d0330ed03c4...
Re:Gcsfuse: A user-space file system for interacting with Go... by Severian on Wednesday September 06, 2023 @07:46AM (#37403734)
You can use S3 versioning, assuming you have enabled this on the bucket. It would be a little clunky. It would also be done in batches and not continuous append.

Basically if your data is append only (such as a log), buffer whatever reasonable amount is needed, and then put a new version of the file with said data (recording the generated version ID AWS gives you). This gets added to the "stack" of versions of said S3 object. To read them all, you basically get each version from oldest to newest and concatenate them together on the application side.

Tracking versions would need to be done application side overall.

You could also do "random" byte ranges if you track the versioning and your object has the range embedded somewhere in it. You'd still need to read everything to find what is the most up to date as some byte ranges would overwrite others.

Definitely not the most efficient but it is doable.

Re:Gcsfuse: A user-space file system for interacting with Go... by dataangel on Wednesday September 06, 2023 @07:58AM (#37403816)
what is the advantage of versioning versus just naming your objects log001, log002, etc and opening them in order?
Re:Gcsfuse: A user-space file system for interacting with Go... by vlovich123 on Wednesday September 06, 2023 @12:57PM (#37407800)
You can set up lifecycle policies. For example, auto delete or auto archive versions > X date. That’s one lifecycle rule. With custom naming schemes, it wouldn’t scale as well.
Re:Gcsfuse: A user-space file system for interacting with Go... by jeffbarr on Wednesday September 06, 2023 @12:45PM (#37407647)
OMG...
Re:Gcsfuse: A user-space file system for interacting with Go... by rickette on Wednesday September 06, 2023 @09:39AM (#37404956)
Azure Blob Storage actually has explicit append support using "Append"-blobs (next to block and page blobs)
Re:Gcsfuse: A user-space file system for interacting with Go... by capableweb on Wednesday September 06, 2023 @10:53AM (#37406068)
Building a storage service like these today and not having "append" would be very silly indeed. I guess S3 is kind of excused since it's so old by now. Although I haven't read anything about them adding it, so maybe less excused...
Re:Gcsfuse: A user-space file system for interacting with Go... by advisedwang on Wednesday September 06, 2023 @11:54AM (#37406936)
gcsfuse uses compose [1] to append. Basically it uploads the new data to a temp object, then performs a compose operation to make a new object in the place if the original with the combined content.

[1] https://cloud.google.com/storage/docs/composing-objects

Re:Gcsfuse: A user-space file system for interacting with Go... by paulddraper on Wednesday September 06, 2023 @02:09PM (#37408797)
> Correct me if I’m wrong, but I don’t think S3 has an equivalent way to append to a value, which makes it clunky to work with as a log sink.

You are correct. (There are multipart uploads, but that's kinda different.)

ELB logs are delivered as separate object every few minutes, FWIW.