[MXS-2539] REST API doesn't update Last-Modified or ETag on state change Created: 2019-05-31  Updated: 2019-07-03  Resolved: 2019-07-03

Status: Closed
Project: MariaDB MaxScale
Component/s: REST-API
Affects Version/s: None
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: markus makela Assignee: markus makela
Resolution: Won't Do Votes: 0
Labels: None

Sprint: MXS-SPRINT-85

 Description   

If a resource in MaxScale is modified due to internal events (e.g. statistics being updated) the ETag and Last-Modified values aren't updated. The update only happens if a user modifies the resource. This causes various web frameworks to return stale data even though the data has changed.

Calculating a checksum or a hash and using that as the ETag would make it possible to detect updates that happen internally. By comparing this ETag the Last-Modified could also be updated. The downside is that the request would always be executed and the result discarded if the resource hasn't changed.



 Comments   
Comment by markus makela [ 2019-06-24 ]

A first-pass fix to this is to calculate a checksum of the object contents and use that as the ETag. This does cause some extra overhead for requests that are not sent back to the client but a larger change would be needed to correctly represent the internal changes in object states.

Comment by markus makela [ 2019-06-28 ]

There is a problem by using only GET requests to calculate the hash: the ETag returned from a PATCH will not be the one that would be returned from a GET on the same resource.

Comment by markus makela [ 2019-06-28 ]

Decided to not do a partial fix and properly track object versions in a later release.

Comment by markus makela [ 2019-07-03 ]

A solution to the PATCH/POST problem would of course be to perform a fake GET request and use that as the hash. This would slow down modifying requests but in theory it would also allow the API to return the created and/or updated element in question.

The problem with all of these is the fact that the statistics can be updated constantly making PATCH request effectively impossible to do on live systems that are in use. This would mean that the current implementation is in fact the most reasonable solution at this point and the problem is only on the client side using cached results and expecting statistics to be updated. Whether this is the behavior that all clients exhibit is something that is not known at this point in time.

Comment by markus makela [ 2019-07-03 ]

After thinking about the problem for quite a bit, I've come to the conclusion that this should not be implemented at all and that the ETag documentation must be updated to describe that it only changes if a request done via the REST API modifies a resource.

Generated at Thu Feb 08 04:14:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.