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

rpc: make blocking queries for non-existent items more efficient #12110

Merged
merged 3 commits into from
Feb 17, 2022

Commits on Feb 15, 2022

  1. Add a test for blocking query on non-existent entry

    This test shows how blocking queries are not efficient when the query
    returns no results.  The test fails with 100+ calls instead of the
    expected 2.
    
    This test is still a bit flaky because it depends on the timing of the
    writes. It can sometimes return 3 calls.
    
    A future commit should fix this and make blocking queries even more
    optimal for not-found results.
    dnephin committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    897b953 View commit details
    Browse the repository at this point in the history
  2. Make blockingQuery efficient with 'not found' results.

    By using the query results as state.
    
    Blocking queries are efficient when the query matches some results,
    because the ModifyIndex of those results, returned as queryMeta.Mindex,
    will never change unless the items themselves change.
    
    Blocking queries for non-existent items are not efficient because the
    queryMeta.Index can (and often does) change when other entities are
    written.
    
    This commit reduces the churn of these queries by using a different
    comparison for "has changed". Instead of using the modified index, we
    use the existence of the results. If the previous result was "not found"
    and the new result is still "not found", we know we can ignore the
    modified index and continue to block.
    
    This is done by setting the minQueryIndex to the returned
    queryMeta.Index, which prevents the query from returning before a state
    change is observed.
    dnephin committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    4b33bdf View commit details
    Browse the repository at this point in the history
  3. rpc: add errNotFound to all Get queries

    Any query that returns a list of items is not part of this commit.
    dnephin committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    8a6e75a View commit details
    Browse the repository at this point in the history