-
Notifications
You must be signed in to change notification settings - Fork 136
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
[Work in Progress] 3rd-party API: ETag for faster synchronization #51
Conversation
3cc9b01
to
d585c82
Compare
I'm running my approach now for several weeks and it is working very well. However, there is one issue I want to discuss: It scales only up to approximately 400 notes. Background: The Solutions: There are several possible solutions for this:
Conclusion: Is this (>400 notes) an edge case? Should we merge this pull request now and care about the open issue later? I would argue for this. But what do you think? Do you even understand what I'm talking about? Maybe my English is not good enough? 😎 @nextcloud/notes @Henni @stefan-niedermann and everybody else 😀 |
The solution should be to use one etag per note if you request a specific note and one etag for all notes (e.g. etag of the latest note or hash all notes' etags in a specific order) So basically: make it so an etag will always be 32 chars long |
Thanks for you comment! 😃 I wanted to improve this, and therefore, in my approach the client sends all known ETags in a single request when updating all notes. |
Well if you send only the etag of the latest one you could actually send a diff |
BTW this is probably a scenario where the last modified header would make more sense than an etag |
Another idea: you send back all notes but notes with a smaller last modified time than the one that was requested will only contain an Id. That way you can in fact keep track of deleted notes as well. |
Unfortunately, we can't use the
Nevertheless, please continue thinking with about this, maybe we find a better solution 😃 We would need another type of modified time, i.e. we need to distinguish between the real Nevertheless, the approach of using the modified time of the file does not take into account that meta-data (i.e. the |
AFAIK filemtime is not synchronised. If a client created a note he won't have an id for it yet so you can pretty easily check which files are in the server and which aren't |
Oh yes, the To your second part: Yes, note creating detection is easy. But updates have to be handled correctly, as well. ;-) |
Seems like a bad idea then. ;) I don't see the value, client and server time don't have to match at all and I'm unsure if this could even cause sync client issues. If the client update date is important for you, why not store it as an additional fields in the dB? |
What I'm trying to say is: there is this really simple, fast restful approach which is blocked by a minor feature that can be solved in a different fashion :) |
I understand what do you mean. However, I like that feature (there are at least 3 different use-cases for this*) and -- which is more important -- the server core has the same feature (in WebDAV using propset or the HTTP header *) use-cases:
|
I see, that's a bummer then. I guess this is where simple APIs like webdav fall apart and you need custom handling :) In that case I'd order all files by filemtime, concatenate their etags and hash them again and use that as etag. If the E-Tag doesn't match, then send all files again. |
Now we are at a point, we were already before: #51 (comment) (see above) 😉 Sending all notes although only one of them may have changed is not reasonable (especially in mobile environments). Maybe, do you have another idea, how we can improve this situation? The only other way I could imagine, is to have two steps:
For the second step, the API has to introduce a new routing. But I think, backward-compatibility can be achieved, because the client can distinguish the server version on behalf of the response from 1. Pro: If nothing has changed, the synchronization will be faster than all my other suggestions from #51 (comment). |
The less requests (especially on mobile) the faster it will be because latency is the killer and you can compress text pretty well using gzip. Another approach would be to hook into file creation and update process and maintain a modified date on the server so you can make the "give me all notes modified since x" approach would work. |
That's a promising idea! I wasn't aware of the existence of hooks. But according to the documentation, this should work for us. I thought about this for some time, and finally, I came to the insight that it would be better to do it without hooks. Variant using hooks We would have to introduce a database table with two columns But what happens if the notes app is deactivated temporarily and files are modified or deleted in this time period? We will get orphaned rows in the database table and we will lost updates of the files! When thinking about a solution for this, I came to this variant: Variant without hook Introduce a database table with three columns
Then, |
@korelstar what’s the current state here? Can you rebase? :) @Henni @irgendwie @BernhardPosselt @Gomez do you have feedback? :) |
@jancborchardt My plan is to completely rework this PR with respect to the feedback given by @BernhardPosselt. I would use the above presented approach "Variant without hook". However, it would be nice if I get a OK by somebody before doing the implementation.
|
@korelstar we can close this, right? |
yes |
This is my prototype which introduces ETags for notes. See #49 for further details. For now, it's work in progress but I'm looking forward for any kind of feedback and a lively discussion in #49. 😃