Skip to content
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

Redis omits query offset parameter in key #636

Closed
krystian50 opened this issue May 9, 2020 · 3 comments
Closed

Redis omits query offset parameter in key #636

krystian50 opened this issue May 9, 2020 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@krystian50
Copy link
Contributor

krystian50 commented May 9, 2020

Describe the bug
I'm querying sorted data. Changing offset seems to be ignored by the query.

To Reproduce
Steps to reproduce the behavior:

  1. Use query eg:
    {"dimensions":["Refunds.refundNumber"],"limit":10,"offset":0,"order":{"Refunds.refundNumber":"asc"}}

this query returns example data:

{
    "query": {
        "dimensions": [
            "Refunds.refundNumber"
        ],
        "limit": 10,
        "offset": 0,
        "order": [
            {
                "id": "Refunds.refundNumber",
                "desc": false
            }
        ],
        "rowLimit": 10,
        "timezone": "UTC",
        "filters": [],
        "timeDimensions": []
    },
    "data": [
        {
            "Refunds.refundNumber": "691695"
        },
        {
            "Refunds.refundNumber": "691696"
        },
        {
            "Refunds.refundNumber": "691697"
        },
...
  1. Change offset in query
    {"dimensions":["Refunds.refundNumber"],"limit":10,"offset":10,"order":{"Refunds.refundNumber":"asc"}}
    this query returns:
{
    "query": {
        "dimensions": [
            "Refunds.refundNumber"
        ],
        "limit": 10,
        "offset": 10,
        "order": [
            {
                "id": "Refunds.refundNumber",
                "desc": false
            }
        ],
        "rowLimit": 10,
        "timezone": "UTC",
        "filters": [],
        "timeDimensions": []
    },
    "data": [
        {
            "Refunds.refundNumber": "691695"
        },
        {
            "Refunds.refundNumber": "691696"
        },
        {
            "Refunds.refundNumber": "691697"
        },
...

Expected behavior
The query should return data window moved by 10

Screenshots
If applicable, add screenshots to help explain your problem.

Version:
[0.19.16] - server
[0.19.15] - postgres-driver

@krystian50 krystian50 changed the title Changing limit accours in upredicable data change Changing limit accours in upredictable data change May 9, 2020
@krystian50 krystian50 changed the title Changing limit accours in upredictable data change Changing limit occurs in upredictable data change May 9, 2020
@krystian50 krystian50 changed the title Changing limit occurs in upredictable data change Changing limit & offset occurs in upredictable data change May 10, 2020
@krystian50
Copy link
Contributor Author

krystian50 commented May 10, 2020

I just found out my issue is caused by offset parameter being ignored while setting up cache key in cache. Basically first request with offset: 0 is cached. The query.offset is changed in result, but data keep cached for offset: 0.

@krystian50 krystian50 changed the title Changing limit & offset occurs in upredictable data change Redis omits query offset parameter in key May 10, 2020
@krystian50
Copy link
Contributor Author

I found the only way to make it works is by completely removing cache for compiler:

class CompilerCache extends QueryCache {
  constructor({ maxQueryCacheSize, maxQueryCacheAge }) {
    super();
    console.log(maxQueryCacheSize, maxQueryCacheAge)
    this.queryCache = new LRUCache({
      max: maxQueryCacheSize || 1,
      maxAge: (maxQueryCacheAge * 1000) || 1,
      updateAgeOnGet: true
    });
  }

@paveltiunov paveltiunov added the bug Something isn't working label May 11, 2020
@paveltiunov
Copy link
Member

@krystian50 Hey Krystian! Thanks for posting this one! Yep. Seems like a bug. Should be fixed in 0.19.18. Could you please check?

@paveltiunov paveltiunov added this to the v0.19.18 milestone May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants