SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

GET DOCUMENT WITH EXPLICIT SECONDARYPREFFERED --> RANDOMLY RETURN ETAG #457

Closed WT2 closed 1 year ago

WT2 commented 1 year ago

Hi

restheart 7.3.3 mongo 6

On document retrieval, i randomly get the ETag header in the response.

Here is an example where i get the header: 'ETag': '6422ccf2d41b622daa285083'

--> GET DOCUMENTS REQUEST METHOD GET REQUEST URL https://XXXXXXXXX/api/test_database/test_collection?cache&page=6&pagesize=1&readPreference=secondaryPreferred REQUEST HEADERS {'X-Is-CloudRun': 'TRUE', 'accept': '/', 'User-Agent': 'python-requests/2.27.1', 'Connection': 'keep-alive', 'X-Was-LoadBalanced': 'TRUE', 'content-type': 'application/json', 'Authorization': 'XXXXXXXXX', 'Accept-Encoding': 'gzip, deflate'} REQUEST BODY None RESPONSE HEADERS {'X-XSS-Protection': '1; mode=block', 'Content-Length': '111', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Auth-Token-Location': '/tokens/opsbatch', 'Auth-Token-Valid-Until': '2023-03-28T11:33:11.265667768Z', 'Content-Encoding': 'gzip', 'Access-Control-Expose-Headers': 'Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By', 'Content-Security-Policy': "default-src 'self' https: wss: data: blob: 'unsafe-inline';", 'X-Powered-By': 'origin', 'Server': 'nginx', 'Auth-Token': 'XXXXXXXXX', 'X-Content-Type-Options': 'nosniff', 'Connection': 'keep-alive', 'ETag': '6422ccf2d41b622daa285083', 'Access-Control-Allow-Credentials': 'true', 'Date': 'Tue, 28 Mar 2023 11:18:11 GMT', 'Access-Control-Allow-Origin': '*', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Content-Type': 'application/json', 'X-Frame-Options': 'DENY', 'Permissions-Policy': 'interest-cohort=()'} RESPONSE COOKIES {} RESPONSE CONTENT [...] RESPONSE STATUS CODE 200 RESPONSE ERROR MESSAGE
CREATED False UPDATED False DELETED False RETRIEVED True SUCCESS True ID None ETAG 6422ccf2d41b622daa285083

Here is an example where i don't get the header:

--> GET DOCUMENTS REQUEST METHOD GET REQUEST URL https://XXXXXXXXX/api/test_database/test_collection?cache&readPreference=secondaryPreferred&pagesize=1000 REQUEST HEADERS {'X-Is-CloudRun': 'TRUE', 'accept': '/', 'User-Agent': 'python-requests/2.27.1', 'Connection': 'keep-alive', 'X-Was-LoadBalanced': 'TRUE', 'content-type': 'application/json', 'Authorization': 'XXXXXXXXX', 'Accept-Encoding': 'gzip, deflate'} REQUEST BODY None RESPONSE HEADERS {'Content-Length': '345', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Auth-Token-Location': '/tokens/opsbatch', 'Auth-Token-Valid-Until': '2023-03-28T11:33:12.914342970Z', 'Content-Encoding': 'gzip', 'Access-Control-Expose-Headers': 'Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By', 'Content-Security-Policy': "default-src 'self' https: wss: data: blob: 'unsafe-inline';", 'X-Powered-By': 'origin', 'Server': 'nginx', 'Auth-Token': 'XXXXXXXXX', 'X-Content-Type-Options': 'nosniff', 'Connection': 'keep-alive', 'X-XSS-Protection': '1; mode=block', 'Access-Control-Allow-Credentials': 'true', 'Date': 'Tue, 28 Mar 2023 11:18:12 GMT', 'Access-Control-Allow-Origin': '*', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Content-Type': 'application/json', 'X-Frame-Options': 'DENY', 'Permissions-Policy': 'interest-cohort=()'} RESPONSE COOKIES {} RESPONSE CONTENT [....] RESPONSE STATUS CODE 200 RESPONSE ERROR MESSAGE
CREATED False UPDATED False DELETED False RETRIEVED True SUCCESS True ID None ETAG None

ujibang commented 1 year ago

I pushed a possible fix for this.

Can you please test it with the following snapshot release:

docker pull softinstigate/restheart-snapshot:85f5a1c
WT2 commented 1 year ago

Hello

I still reproduce this one

ujibang commented 1 year ago

I cannot reproduce it (RH 7.3.4, mongodb 6.0.5)

Please note: the response to GET /coll should include the header ETag.

ujibang commented 1 year ago

closing due to missing reproducer.

@WT2 if you want to reopen this issue, please file a reproducer.