[3.0.1 Backport] _user endpoint pagination causes query error

Description

On Sync Gateway/3.0.0(541;46803d1),

invoking server:4985/bucketname/_user/ gets the following error
 

{ "error": "Internal Server Error", "reason":"Internal error: parsing failure | {\"statement\":\"SELECT META(`bucketname`).id FROM `bucketname` USE INDEX(sg_syncDocs_x1) WHERE META(`bucketname`).id LIKE '\\\\\\\\_sync:%' AND (META(`ipc-20002-prod`).id LIKE '\\\\\\\\_sync:user:%' OR META(`ipc-20002-prod`).id LIKE '\\\\\\\\_sync:role:%') ORDER BY META(`bucketname`).id LIMIT 5000 AND META(`bucketname`).id \>= $startkey\",\"client_context_id\":\"9c00aeff-43eb-40e3-a130-4f53c4a79b3b\",\"errors\":[{\"Code\":3000,\"Message\":\"Ambiguous reference to field ipc-20002-prod.\"}]}" }

The query

SELECT META(`bucketname`).id
FROM `bucketname` USE INDEX(sg_syncDocs_x1)
WHERE META(`bucketname`).id LIKE '
_sync:%'
AND (META(`bucketname`).id LIKE '
_sync:user:%'
OR META(`bucketname`).id LIKE '
_sync:role:%')
ORDER BY META(`bucketname`).id
LIMIT 5000
AND META(`bucketname`).id >= $startkey
is malformed (if last "AND" condition is properly moved within the WHERE clause, it works).

Activity

Show:

CB robot April 29, 2022 at 4:41 PM

Build sync_gateway-3.0.1-12 contains sync_gateway commit 9fa603d with commit message:
https://couchbasecloud.atlassian.net/browse/CBG-2031#icft=CBG-2031 [3.0.1 backport] Fix _limit handling for user endpoint (#5522)

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Sprint

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created April 8, 2022 at 12:06 PM
Updated August 31, 2024 at 10:59 AM
Resolved April 29, 2022 at 4:28 PM
Instabug