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

KV: changing discard policy would fail on srv upgrade #917

Merged
merged 2 commits into from Mar 15, 2022

Commits on Feb 19, 2022

  1. KV: changing discard policy would fail on srv upgrade

    This is related to #900 that introduced the change of discard
    policy if connecting to a server v2.7.2+.
    
    The CreateKeyValue() API calls AddStream(). If the stream already
    exists and the configuration is identical, the call succeeds
    (idempotent). However, since we now try to set the discard policy
    to "new" when connecting to a server v2.7.2+, the call will fail
    if the KV store already existed (CreateKeyValue() was called with
    a v2.7.1 server and stream was created with DiscardOld).
    
    The approach here is that if AddStream() fails with an "already in use"
    error, then we will lookup the stream info, and if we detect that
    the configuration is same (except for the discard policy), then
    we call UpdateStream() with the new discard policy.
    
    The problematic part is that the client side configuration does
    not set some of the fields (or their value is 0), but then the
    server sets either some defaults (like Duplicates set to 2min)
    or replaces 0 to -1. So the info we get back and the config
    we have need to be tweaked before being compared. This is really
    hacky and prone to break if server were to change some defaults.
    
    Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
    kozlovic committed Feb 19, 2022
    Copy the full SHA
    79d6644 View commit details
    Browse the repository at this point in the history
  2. Updates based on code review

    Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
    kozlovic committed Feb 19, 2022
    Copy the full SHA
    5bdaa1f View commit details
    Browse the repository at this point in the history