question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Broken continuation results with ordered results with recent v3.31.2 change

See original GitHub issue

I have confirmed the issue is comming from with the change in v3.31.2. It does not happen in v3.31.1.

When fetching ordered results that cause a continuation token to be returned, the first set of results are returned as normal, but with subsequent fetches, an “odd” filter query is returned with the continuation token, which then when passed into the next query execution causes only 1 record to be returned per call (and very poor performance). So for example, when you have a dataset of 1 million records, and you query with a max page size of 1000, you’d get 1000 records, and then after that 1 record per call. Again, its definitely related to the filter being a part of the continuation token because without it (as it works with the version of the sdk previous to this) the sdk behaves as expected (1000 or max page size results returned per call to cosmos)

SDK Version: v3.31.2

The situation seems to be possibly circumstantial under unknown specific conditions, and I’m not sure which are relevant. Once it happens it consistently happens. The query I’m performing is something like

SELECT VALUE c FROM c WHERE c.DocumentType = @documentType ORDER BY c.DocumentType ASC, c.AuditDate DESC

where AuditDate is a number and DocumentType is a string. The query is cross-partition. The first query returns a continuation result like this:

[{"compositeToken":{"token":"+RID:~MjYdAJoN+QFnBgAAAAAAAA==#RT:1#TRC:1#RTD:NuyR9A/x6vbOO5/KeBRJrwVkdnN9cHNoAPs+J4e/4+f/////4A==#ISV:2#IEO:65567#QCF:8","range":{"min":"","max":"FF"}},"orderByItems":[{"item":"cur|org"},{"item":1673790342}],"rid":"MjYdAJoN+QFnBgAAAAAAAA==","skipCount":0,"filter":"true"}]

but the subseuent ones return one with the following filter property

[{"compositeToken":{"token":"+RID:~MjYdAJoN+QFwBgAAAAAAAA==#RT:2#TRC:2#RTD:NuyR9A/x6vbOO5/KeBRJrwVkdnN9cHNoAPs+J4f/gSv/////4A==#ISV:2#IEO:65567#QCF:8#FPC:AWwGAAAAAAAAcQYAAAAAAAA=","range":{"min":"","max":"FF"}},"orderByItems":[{"item":"cur|org"},{"item":1673531381}],"rid":"MjYdAJoN+QFwBgAAAAAAAA==","skipCount":0,"filter":"((c.DocumentType > \"cur|org\"  OR IS_ARRAY(c.DocumentType)  OR IS_OBJECT(c.DocumentType) )) OR ((c.DocumentType = \"cur|org\" ) AND (c.AuditDate <= 1673617781  OR NOT IS_DEFINED(c.AuditDate)  OR IS_NULL(c.AuditDate)  OR IS_BOOLEAN(c.AuditDate) ))"}]

which only returns one result.

I do have a composite index setup that the query is utilizing, confirmed through IndexMetrics

With the continuation token without a filter:

Index Utilization Information
  Utilized Single Indexes
  Potential Single Indexes
  Utilized Composite Indexes
    Index Spec: /DocumentType ASC, /AuditDate DESC
    Index Impact Score: High
    ---
  Potential Composite Indexes

With the continuation token with one"


Index Utilization Information
  Utilized Single Indexes
    Index Spec: /DocumentType/?
    Index Impact Score: High
    ---
    Index Spec: /AuditDate/?
    Index Impact Score: High
    ---
    Index Spec: /DocumentType/?
    Index Impact Score: High
    ---
    Index Spec: /AuditDate/?
    Index Impact Score: Low
    ---
    Index Spec: /DocumentType/?
    Index Impact Score: High
    ---
    Index Spec: /AuditDate/?
    Index Impact Score: High
    ---
    Index Spec: /DocumentType/?
    Index Impact Score: High
    ---
    Index Spec: /AuditDate/?
    Index Impact Score: High
    ---
    Index Spec: /DocumentType/?
    Index Impact Score: High
    ---
    Index Spec: /AuditDate/?
    Index Impact Score: High
    ---
  Potential Single Indexes
  Utilized Composite Indexes
    Index Spec: /DocumentType ASC, /AuditDate ASC
    Index Impact Score: High
    ---
    Index Spec: /DocumentType ASC, /AuditDate DESC
    Index Impact Score: High
    ---
  Potential Composite Indexes

Issue Analytics

  • State:open
  • Created 8 months ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
neildshcommented, Jan 30, 2023

Hello @IsaacBoy , thanks for reporting this issue and for sharing the diagnostics. We will change the backend and the continuation token format to accept values so that we can remove these filters from the query. This work is currently scheduled for next month.

1reaction
balaperucommented, Jun 20, 2023

Hi @IsaacBoy, I apologize for the delay. We found an issue with our backend implementation and had to make a change in our backend. The backend changes are currently rolling out and there are few more regions to go. I’m hoping to check-in the SDK changes in a week or two if everything goes as planned. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inline Replace focuses wrong input - Developer Community
A breaking change in Preview 4 of 17.0 is that when you Hit Control+H / Edit -> Replace the Focused input is put...
Read more >
Subpart 31.2 - Contracts with Commercial Organizations
(1) Payments to employees under agreements in which they receive special compensation, in excess of the contractor's normal severance pay practice, if their ......
Read more >
MNA User Guide.pdf - MyNavyHR - Navy.mil
MNA User's Guide V3.0i (14FEB2022). 92. - Reduction of a PRD not in the LPW and the new PRD is inside LPW. -...
Read more >
MySQL order by before group by
The example query produces unusable results as its not always the latest post that is returned. SELECT wp_posts.* FROM wp_posts WHERE wp_posts.
Read more >
Johnson & Johnson Reports Q3 2022 Results
NEW BRUNSWICK, N.J. --(BUSINESS WIRE)--Oct. 18, 2022-- Johnson & Johnson (NYSE: JNJ) today announced results for third-quarter 2022.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found