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

embedded memcached proxy #716

Closed
wants to merge 45 commits into from
Closed

Commits on Sep 28, 2021

  1. proxy: proof of concept and infrastructure

    All this will do as of this commit are simple metagets, ie:
    mg /foo/a t v
    
    ...and only for small responses.
    
    This turns memcached into what will be a full featured proxy. Full
    writeup of what that entails will live in the PR on github.
    
    Does not include vendored files. requires:
    vendor/lua (lua 5.4.0 from public tarball)
    vendor/mcmc (from https://github.com/dormando/mcmc (or
    https://github.com/memcached/mcmc in the future)
    
    also requires a startfile.lua. An empty configuration looks like:
    
    function mcp_config_selectors(oldss)
    
    end
    
    function mcp_config_routes(main_zones)
    
    end
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    8c26d7e View commit details
    Browse the repository at this point in the history
  2. proxy: furhter updates for flow IO API

    keeping this separate so I can review/re-apply in case I need to do
    this rebase again.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    2246ea4 View commit details
    Browse the repository at this point in the history
  3. proxy: convert to IO flow API

    no more batched completion :(
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    091a3c4 View commit details
    Browse the repository at this point in the history
  4. proxy: mcp.await() parallel-subrequests

    Adds a primitive asynchronous wait call, where request "r" is dispatched
    against N pools in parallel. An optional number specifies how many
    responses to wait for before returning.
    
    Has bugs around edge cases and limited testing as of writing, but does
    pass basic tests.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    3b2926d View commit details
    Browse the repository at this point in the history
  5. proxy: fix memory bugs in await()

    classic C bugs :P doesn't seem to leak now in some limited testing with
    mctester.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    3da30e6 View commit details
    Browse the repository at this point in the history
  6. proxy: simplified bad backend handling

    Taking a simplified first attempt at having fast-failures for backends
    that throw errors or time out; IO's will immediately be returned for
    these backends until they become alive. A background retry is scheduled
    until the backend works again.
    
    There are a lot of ways to improve this, some noted in comments, and I
    will likely need to move the connect() code anyway, so doing that as a
    later change.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    ce4a3c4 View commit details
    Browse the repository at this point in the history
  7. proxy: fix config reload crash for user stats

    if replacing existing user stats, would crash. think broke during a
    refactor; need more integration tests :)
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    bc39742 View commit details
    Browse the repository at this point in the history
  8. proxy: start logger integration

    timing is a little tough; not a lot of places to stick the time start vs
    time end for the log. gives a raw timing of microseconds.
    
    also need to follow up with having a response inherit some details about
    the request (type?) and translate the response type/code to something
    useful... but starting with this.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    6443e0c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    d229854 View commit details
    Browse the repository at this point in the history
  10. proxy: start of io_uring integration

    This commit changes:
     - add --enable-proxy-uring option, which looks for a compiled liburing
       in vendor/liburing
     - change backend drive_machine() to remove syscalls so it can be a
       common code path between libevent and uring
     - add basic liburing support for the backend read path. writes to
       backends still use normal syscalls and will be optimized later
    
    The structure will need to change to meter out *sqe's more carefully,
    but it should be impossible to trip the exhaustion condition so this is
    fine for now.
    
    The mcmc code did not make this easy, drive_machine() has turned into a
    bit of a mess. I need to flatten that out to allow avoiding memmove's
    and make the code clearer. Will come back to it after taking a break
    from it...
    
    Uring path is missing some critical code still:
     - backend disconnects
     - bad backend handling/retry
     - timeouts don't exist at all
    
    So it should work for testing in good conditions and I'll add the error
    handling during the stabilization phase.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    e5e8973 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    70d592f View commit details
    Browse the repository at this point in the history
  12. proxy: update/remove some TODO's + uring patch

    Some uring changes before I forget I wanted to do them, and
    update/remove some TODO notes.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    d127e51 View commit details
    Browse the repository at this point in the history
  13. proxy: start N backend servers for tests

    some cleanups/changes to the test startfile as well.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    561a40f View commit details
    Browse the repository at this point in the history
  14. proxy: line ending test

    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    0d95b6e View commit details
    Browse the repository at this point in the history
  15. proxy: gat/gats support

    plus gets/cas/touch tests.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    eabca94 View commit details
    Browse the repository at this point in the history
  16. proxy: more incr/decr support

    mostly in the parser + adding tests. no userlib parts yet.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    d791186 View commit details
    Browse the repository at this point in the history
  17. proxy: beginning of meta parser code

    avoid second malloc for lua request objects by requesting some extra
    space.
    
    generate a bitfield of flags generically to allow later flags without
    breaking code.
    
    when looking for arguments to flags from the API, we will have to
    re-scan the string, which usually very short anyway.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    5e54783 View commit details
    Browse the repository at this point in the history
  18. proxy: rename hash_selectors to pools.

    hasn't made sense for a long time now. distribution and hash functions
    are abstract from the pool.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    ce98eed View commit details
    Browse the repository at this point in the history
  19. proxy: expand the pool API

    in preparation of adding a few more common options.
    
    hash_selectors are now pools. I've now separated the concepts:
    
    ketama/jump/etc are considered "key distributors", and can now be
    separate from key hashing.
    
    collapse arguments into a single options table. this table gets
    passed-through to the distribution function for extra options.
    
    t/startfile.lua has been updated.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    b7bccc8 View commit details
    Browse the repository at this point in the history
  20. proxy: use tokenizer for request parser.

    rewriting the parser yet again... fixes a bug where parser wasn't
    handling spaces around arguments. Simplifies and removes redundancy for
    a bunch of the parser code.
    
    Finally, sets up for a simplified API wrapper that simply handles tokens
    directly.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    c961252 View commit details
    Browse the repository at this point in the history
  21. proxy: add lua API for request token handling

    *trimkey is a fast routine for clipping part of the key before shipping
    the command.
    r:token(n) can fetch a token in the nth position.
    r:token(n, str) replaces the token at the nth position.
    
    modifications to the tokens are ignored. the next commit should
    re-stringify in case of modification.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    6336563 View commit details
    Browse the repository at this point in the history
  22. proxy: r:token(n, newtoken) will modify a request

    replace specific tokens in a request with r:token(n, str) command. the
    request will be re-serialized when it's being sent to a backend.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    02a36f5 View commit details
    Browse the repository at this point in the history
  23. proxy: re-enable metaflag parsing

    also removes errant fprintf.
    
    need to actually parse the flags so we can handle binary-encoded keys.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    f53419c View commit details
    Browse the repository at this point in the history
  24. proxy: re-privitize ascii's string tokenizer

    not used anymore.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    6315b5f View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    a63dccb View commit details
    Browse the repository at this point in the history
  26. proxy: functions for setting/updating timeouts

    mcp.backend_connect_timeout()
    mcp.backend_retry_timeout()
    mcp.backend_read_timeout()
    
    only takes integers. could take a fractional with more work.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    cda1f08 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    99cb030 View commit details
    Browse the repository at this point in the history
  28. proxy: kill some TODO/FIXME's

    these were done / no longer matter.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    35aa24a View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    f4df6ca View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    d94f31f View commit details
    Browse the repository at this point in the history
  31. proxy: fix bug in default timeouts

    I'd forget how to breathe if it weren't automatic.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    5fe40f9 View commit details
    Browse the repository at this point in the history
  32. proxy: change mcmc's vendoring

    clears up an automake error. need a for-real makefile or to turn mcmc
    into a header. Think I like the idea of it being a header actually?
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    9cd3ece View commit details
    Browse the repository at this point in the history
  33. proxy: make watch rawcmds a bit more useful

    will print the original request command name. we can't toss the
    key/anything useful as requests are not pinned to responses. I can think
    of better approaches but they require more clever code so I'm not doing
    it now.
    dormando committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    ae2c239 View commit details
    Browse the repository at this point in the history

Commits on Sep 29, 2021

  1. proxy: start of a "simple" lua library

    can handle flat routing (pools and such) and multi-zones
    
    flat routing is probably fine, zones needs more work for production.
    dormando committed Sep 29, 2021
    Configuration menu
    Copy the full SHA
    c764f5d View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2021

  1. proxylib: allow specifying a host label

    thinking I'll end up moving this script to the proxylibs repo... but
    vendor it on releases.
    dormando committed Sep 30, 2021
    Configuration menu
    Copy the full SHA
    14e04ba View commit details
    Browse the repository at this point in the history
  2. proxylib: allow specifying a default pool

    instead of just erroring.
    dormando committed Sep 30, 2021
    Configuration menu
    Copy the full SHA
    24f1374 View commit details
    Browse the repository at this point in the history
  3. proxy: fix compilation error

    when not configured, again. also cleans up a bit from a TODO note.
    dormando committed Sep 30, 2021
    Configuration menu
    Copy the full SHA
    11d20c9 View commit details
    Browse the repository at this point in the history

Commits on Oct 1, 2021

  1. proxy: automake fix

    dormando committed Oct 1, 2021
    Configuration menu
    Copy the full SHA
    2e7e8f3 View commit details
    Browse the repository at this point in the history
  2. proxy: make simple an actual library

    --proxy_config=./datafile.lua is now the calling convention. the
    datafile loads the library which defines globals for the proxy to run.
    dormando committed Oct 1, 2021
    Configuration menu
    Copy the full SHA
    2ef0074 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    994ab14 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    de3bce4 View commit details
    Browse the repository at this point in the history
  5. proxy: vendoring.

    lua is external.. mcmc is inlined, at least for now.
    dormando committed Oct 1, 2021
    Configuration menu
    Copy the full SHA
    ea22014 View commit details
    Browse the repository at this point in the history
  6. proxy: vendor fetch script

    extra step for proxy builders.
    dormando committed Oct 1, 2021
    Configuration menu
    Copy the full SHA
    03f3321 View commit details
    Browse the repository at this point in the history

Commits on Oct 2, 2021

  1. proxy: make dist hacks...

    I need to spend some time learning this properly, but I need it to work
    in the meantime... So using a proxy makefile to build things.
    
    "make dist" does actually work now, but not unless you "make clean"
    first. it'll add junk because the make dist recursion happens after the
    EXTRA_DIST copies files in.
    
    I'll fix this another time. since it's mostly me building tarballs I'll
    just try to not screw it up until fixed.
    dormando committed Oct 2, 2021
    Configuration menu
    Copy the full SHA
    cecc52a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b8f7790 View commit details
    Browse the repository at this point in the history