Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no atomicity guarantees for object operations #28

Closed
gedw99 opened this issue Jun 12, 2022 · 7 comments
Closed

no atomicity guarantees for object operations #28

gedw99 opened this issue Jun 12, 2022 · 7 comments

Comments

@gedw99
Copy link

gedw99 commented Jun 12, 2022

This is a new issue but continues on from our discussion in another issue I closed.

The proposal was to add Redis as a global counter system .

Here is my Use case.

i have clients ( browsers ) that store files and do mutations on those files

I have a server running in google cloud run , that talks to google storage / s3

The server is using s3 as it’s global store. Each web client has its own file store that persists offline ( using indexeddb ).

So we have an interesting situation with a file instance existing outside s3.

The notification system is what I am really interested in so that when a file on s3 changes we can notify all servers and clients. I think gose can do that now ?

when the client or server gets this event it should then request the file so it can get up to date.

when it asks for the file however it would be much more performant if it could get a binary byte array of the file difference . Yeah this is rather hard

So regarding Redis , I think that the file change events and the file change diff could be stored on this global message bus. So essentially the notification system uses this distributed message bus and can store the binary diff of the file .

Now I know that offline clients will not really work in this architecture , in the same way that git merges don’t always work because someone else changes the same part of the file but I think it’s possible to make that crazy aspect by using be tie clocks as well as a Chronos style clock system. But that’s more of a layer thing .

The main thing is to see if you think it’s possible to store the file diff in the message bus.

As i think about it it would mean that the Clients and Servers don’t even talk to s3 for sending file mutations . They would calculate the binary diff and send that into the message bus.

Importantly creation of new files would be send directly to S3.

I know this is probably out of scope for what Gose was created but I figured it’s worth explaining to see if you or others are interested in this use case .

https://flurryhead.medium.com/vector-clock-applications-965677624b94

@gedw99
Copy link
Author

gedw99 commented Jun 12, 2022

I should point out that in the article it specifically talks about counters .

by having a counter mapped against the logical clock , it allow distributed ordering of the changes, so that files can be kept in sync everywhere .

Clock skew over time of course occurs and that’s why Chronos is a separate issue . Basically google have a gps clock in all data centers and the servers and also the web client ( like when you use gmail , etc ) get their “google tine” from these gps clocks.

@stv0g
Copy link
Owner

stv0g commented Jun 12, 2022

Hi @gedw99,

The notification system is what I am really interested in so that when a file on s3 changes we can notify all servers and clients. I think gose can do that now ?

I do not think Gose is the solution for your use case.

Gose aims to provide users the easiest possible solution for sharing files.
Each file is uploaded once and can be downloaded multiple times.
Modification of files or management of multiple files or user accounts, folders, etc.. is not the (current) objective of Gose.

I am trying to focus on simplicity here and usability features which others file uploading tools do not provide (resuming of interrupted uploads, de-duplication, encryption, up/download limits and quotas).

But in its core the usability of Gose as a file uploading/sharing tools should be as simple as possible:

  • no registration login
  • simple drag&drop
  • share the uploaded file with a simple link with your friends, colleagues or family

Gose aims to be the tool to quickly share some files like holiday photos or attachments which are otherwise too large for mail or other messengers.

@stv0g
Copy link
Owner

stv0g commented Jun 12, 2022

Vector clocks are an interesting concept and I am sure distributed caches like Redis might already use them.
I have considered implementing a distributed cache / synchronization layer (and hence use vector clocks) itself into Gose but quickly came to the conclusion that I better leave this task to a tool made for this purpose like Redis.
I also searched for a Redis like solution written in Go which I could directly embed into Gose. However, there seems to be no good Redis-like implementation of a lock/kvstore in Go yet..

@stv0g
Copy link
Owner

stv0g commented Jun 12, 2022

I am sorry that I will need to close this issue here as I see no specific bug or feature request which I we could work on.

Please feel free to contact me via other channels (see https://steffenvogel.de/#contact)

@stv0g stv0g closed this as completed Jun 12, 2022
@gedw99
Copy link
Author

gedw99 commented Jun 13, 2022

Agree - its out of scope. But thank you for the tips and comments.

@gedw99
Copy link
Author

gedw99 commented Jun 13, 2022

NATS can do atomic counters via this hack: nats-io/nats-server#2656

Its also a distributed kv and object store ironically: https://docs.nats.io/nats-concepts/jetstream/obj_store/obj_walkthrough

  • as an object store its doin what s3 does.

NATS can be embedded also. So you can include it in GOSE, or run NATS JetStream anywhere.
Its pure golang, no CGO etc.

@hwinkel
Copy link

hwinkel commented Nov 19, 2023

@gedw99 where you see a hack in the referenced issue?

NATS can do atomic counters via this hack: nats-io/nats-server#2656

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

No branches or pull requests

3 participants