Permalink
Commits on Aug 3, 2017
  1. Add support for turning on tcp keep alive.

    youngm committed with ingenthr Jul 28, 2017
    Change-Id: Ic561f87fe262782a607e86ac8b2e0efb69d2c46e
    Reviewed-on: http://review.couchbase.org/81810
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
    Tested-by: Matt Ingenthron <matt@couchbase.com>
Commits on Apr 10, 2017
  1. SPY-195: Defer String Concat in handleEmptySelects()

    amcrn committed with daschl Feb 25, 2017
    MemcachedConnection.handleEmptySelects() has a debug level log
    statement that doesn't correctly defer the concatentation of
    the argument until it has determined that the level is enabled.
    
    Change-Id: I3c8bb70cfaa9f47eb790f2eb150bacca2ce839b6
    Reviewed-on: http://review.couchbase.org/76567
    Reviewed-by: Michael Nitschinger <michael@nitschinger.at>
    Tested-by: Michael Nitschinger <michael@nitschinger.at>
Commits on Apr 7, 2017
  1. SPY-194: Allow to optionally bound retry queue.

    daschl committed Nov 16, 2016
    Motivation
    ----------
    If the retry queue might grow very large this can lead to
    uncontrollable side effects (like heap growth), since this
    queue is not accessible from the outside of spymemcached.
    
    Modifications
    -------------
    This change adds the system property "net.spy.retryQueueSize" which
    allows to optionally bound the retry queue to the given size.
    
    Note that to maximize backwards compatibility and to not introduce
    any regressions the actual queue has not been changed but rather
    the code which inserts into this queue is now checking for the
    limit.
    
    If the queue is full the operation is cancelled instead of sending
    it into the retry queue.
    
    Result
    ------
    It is now possible to bound the retry queue.
    
    Change-Id: I86452ef8dcddcf2c4acfc065fd9db94510665ac3
    Reviewed-on: http://review.couchbase.org/69938
    Tested-by: Michael Nitschinger <michael@nitschinger.at>
    Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Commits on Mar 14, 2017
  1. SPY-193: Allow to override wakeupDelay

    daschl committed Mar 14, 2017
    Motivation
    ----------
    As part of SPY-172, a new wakeupDelay setting has been introduced,
    but as part of a mistake it has never been used to actually set
    the wakeup time, which is still hardcoded to 1000.
    
    Modifications
    -------------
    This simple change modifies the code so it accepts the wakeupDelay
    setting, still having the default at 1000 but making it possible
    to override it through the system property.
    
    Result
    ------
    The wakeupDelay can now be configured via a system property.
    
    Change-Id: If1273cb560d49ea2c9c42b7c7b70c84fd9aeebdc
    Reviewed-on: http://review.couchbase.org/75116
    Tested-by: Michael Nitschinger <michael@nitschinger.at>
    Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Commits on Feb 1, 2017
  1. SPY-192: Ensure connection key is valid before checking if writable.

    ggrochow committed with daschl Jan 20, 2017
    Motivation
    ----------
    It has been discovered in the wild that sometimes CancelledKeyException are
    received even if the key has been checked for validity before. It turns out
    that the validity can change between the check and the next function call.
    
    Modifications
    -------------
    The changeset makes sure to check if it is valid on both reading and
    subsequent writing, reducing the chance of race conditions and interleaved
    state changes.
    
    Result
    ------
    More stable behavior at runtime and less chance of CancelledKeyException.
    
    Change-Id: Ic0db65f9c7ccc3a7b9738aaff0e3c7e60d7f25c2
    Reviewed-on: http://review.couchbase.org/72270
    Reviewed-by: Michael Nitschinger <michael@nitschinger.at>
    Tested-by: Michael Nitschinger <michael@nitschinger.at>
Commits on Apr 4, 2016
  1. SPY-191: Don't force reconnect on E2BIG with binary protocol.

    daschl committed Mar 24, 2016
    Motivation
    ----------
    In the current codebase, a socket is forcefully reset when the server
    returns an E2BIG response, that is when the document is larger than the
    possible value size.
    
    Modifications
    -------------
    While this needs to be done on the ASCII protocol, doing so is not needed
    with binary protocol and can be considered a bug/leftover.
    
    The code is modified so that E2BIG just translates into a non-success response
    like any other error and the proper error code identifies the cause.
    
    The test cases have been modified for binary to reflect the change.
    
    Result
    ------
    Do not force reconnect / treat the issue as a server error on the binary
    protocol - the ASCII protocol is unaffected.
    
    Change-Id: Idf392d146d30b2e96dc198a93a3cc6598dae3fc6
    Reviewed-on: http://review.couchbase.org/61927
    Reviewed-by: Simon Baslé <simon@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Commits on Jan 13, 2016
  1. SPY-190: Remove the no-operation isInterrupted() call. Document inter…

    christian-esken committed with daschl Jan 5, 2016
    …ruption policy.
    
    Motivation
    ----------
    Avoid confusion. Make the interruption policy more clear.
    
    Modifications
    -------------
    Remove the no-operation isInterrupted() call.
    Document interruption policy.
    
    Result
    ------
    Better understandable concurrency code.
    
    Change-Id: Iaf63f8a246c45e9ed9ebfe9c4239043cbe9e2039
    Reviewed-on: http://review.couchbase.org/58266
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on Jun 11, 2015
  1. SPY-187: Expose a few more attributes of MemcachedClient

    fabienrenaud committed with daschl May 29, 2015
    Motivation
    ----------
    Extending MemcachedClient to access some of its protected attributes is
    not always desirable as it makes harder writing mocks for unit testing.
    
    Modifications
    -------------
    MemcachedClient now exposes operationTimeout,
    mconn, tcService and executorService.
    
    Result
    ------
    One does not have to extend MemcachedClient any more to write custom
    commands.
    
    Change-Id: I81932da64d4492512dcf1a11fe1161203fa70c5e
    Reviewed-on: http://review.couchbase.org/51546
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on May 19, 2015
  1. Support Libmemcached ketama weighted

    sideshowcoder committed with daschl Mar 3, 2015
    - Add support for alternative Ketama Node key format
    
      Libmemcached uses the format for `[hostname or ip][port unless
      default]-[repetition]` while spymemcached has been using
      `[hostname]/[ip]:[port]-[repetition]` the added `KetamaNodeKeyFormat`
      allows to choose either format while retaining the caching
      optimization.
    
    - Add support for weighted ketama
      Straight port of the weighting based on Libmemcached, configured via
      passing a map of node socketaddress to weight to the configuration.
      This code is only active if the weight is actually configured
      otherwise the old ketama code is used.
    
    - Split testLibKetamaCompatTwo into 2 pieces as the length breaks
      compiling on Eclipse and Java 8 "In java a methods can't have more than
      65535 bytes." http://stackoverflow.com/questions/12257398/how-to-fix-the-code-of-method-is-exceeding-the-65535-bytes-limit
    
    Change-Id: I0263b9afc513f9a135d5d17318b3fe6bd4593437
    Reviewed-on: http://review.couchbase.org/47624
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on Mar 11, 2015
  1. SPY-183: Allow touch operations to be cloned.

    daschl committed Mar 11, 2015
    Motivation
    ----------
    In case a touch  operation needs to be rescheduled, it needs to
    be cloneable (like any other keyed operation).
    
    Modifications
    -------------
    Apply the same clone logic as with any other keyed operation. Also
    added getter methods to the operations so that the expiration time
    can be extracted on cloning.
    
    Result
    ------
    Correct behavior when a touch op needs to be cloned.
    
    Change-Id: Iad343b4dbdcd5dfd4d9ec53bf5335dcf4775f9c9
    Reviewed-on: http://review.couchbase.org/48076
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Simon Baslé <simon@couchbase.com>
Commits on Jan 19, 2015
  1. Fix spring unit tests.

    daschl committed Jan 19, 2015
    Motivation
    ----------
    afterPropertiesSet() needs to be called on the factory to actually
    create the client so that it does not result in a NPE.
    
    Change-Id: I483c045451f90ff3ed01d00db7e912e7d2484b64
    Reviewed-on: http://review.couchbase.org/45554
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Simon Baslé <simon@couchbase.com>
Commits on Jan 9, 2015
  1. SPY-181: GetAndLock needs to be cloneable like any other keyed op.

    daschl committed Jan 9, 2015
    Motivation
    ----------
    In case a getAndLock operation needs to be rescheduled, it needs to
    be cloneable (like any other keyed operation).
    
    Modifications
    -------------
    Apply the same clone logic as with any other keyed operation. Also
    added getter methods to the operations so that the expiration time
    can be extracted on cloning.
    
    Result
    ------
    Correct behavior when a getAndLock op needs to be cloned.
    
    Change-Id: I7f4fdad62af71a42cc203b2a4b7e72f2002a286d
    Reviewed-on: http://review.couchbase.org/45129
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Simon Baslé <simon@couchbase.com>
  2. SPY-182: Avoid WARN logging when handling node not set.

    daschl committed Jan 9, 2015
    Motivation
    ----------
    The main purpose of setting a continous timeout on a node is to
    properly reconnect when the threshold is reached. Now if auth
    has not happened yet, it could be that ops do not have a handling
    node set yet.
    
    In those cases, it doesn't make any sense to increase the counter,
    so it should be ignored. This also has the side effect of not logging
    warnings to the user which have no impact for him.
    
    Modifications
    -------------
    Ignore the operation when its handling node is not set.
    
    Result
    ------
    No unnecessary warnings printed to the user.
    
    Change-Id: I3643d5e0bfc7474889279d0f8362f287624b89a3
    Reviewed-on: http://review.couchbase.org/45131
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Simon Baslé <simon@couchbase.com>
  3. Change MemcachedNodeROImpl and BaseGetOpImpl classes to public.

    fabienrenaud committed with daschl Dec 21, 2014
    Motivation
    ----------
    Implementing a custom NodeLocator requires to override the getReadonlyCopy
    method which in turn requires to use some MemcachedNode implementation.
    MemcachedNodeROImpl should be reusable outside of its package for that
    purpose. In addition, memcached being an open source project, its
    implementation can be changed or extended and commands such as GET may
    be used differently in these custom versions. The abstract BaseGetOpImpl
    should be flexible enough to be adapted to different but similar GET
    commands.
    
    Modifications
    -------------
    The MemcachedNodeROImpl class accessor changes from package-private to public.
    The BaseGetOpImpl class accessor changes from package-private to public.
    The initialization method and constructors of BaseGetOpImpl changed to
    abstract the string appended to the <GET key> command.
    
    Result
    ------
    Writing a custom NodeLocator outside of the net.spy.memcached package
    and supporting variants of GET commands is now easy.
    
    Change-Id: I49b3efc741ab4fe5780bf74ad5f99b839c9ceb7d
    Reviewed-on: http://review.couchbase.org/44565
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on Dec 10, 2014
  1. Update Spring FactoryBean to properly support isSingleton property

    mattbertolini committed with daschl Dec 9, 2014
    Motivation
    ----------
    The current MemcachedClientFactoryBean is marked as a singleton to Spring but
    does not respect the flag. It is creating a new instance with every call to
    getObject(). According to the Spring Javadoc a FactoryBean marked with
    isSingleton true should always return the same reference. By doing this it
    will also expose an ability to safely shutdown a client instance.
    
    Modifications
    -------------
    The class was updated to implement the Spring InitializingBean and
    DesposableBean interfaces. These interfaces provide the two key lifecycle
    methods to create and shutdown the client object. The afterPropertiesSet is
    called after the FactoryBean is constructed and all of the properties have
    been set. This will create the client object and store it in a field so the
    same reference can be returned. The destroy method is called when closing the
    Spring context. It will call the client's shutdown method. I have also added a
    new property that allows a caller to specify the number of seconds to wait
    before shutting down the client. This is a well established Spring pattern
    that is used in many of their own FactoryBean implementations.
    
    Result
    ------
    A more accurate Factory bean that respects the Spring lifecycle and provides
    a safe shutdown mechanism.
    
    Change-Id: I9ae2d71ae7d3fe899bce8ec8200e215aa987400d
    Reviewed-on: http://review.couchbase.org/44144
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on Nov 21, 2014
  1. SPY-179: Reconnect has wrong ceiling, leading to very long reconnect …

    daschl committed Nov 7, 2014
    …delays.
    
    Motivation
    ----------
    This is a regression which was introduced through the change in SPY-158
    (couchbase@bfaec2b).
    
    Because the time is now converted to millis right away, but the comparison checks with the 2^n
    still converted to seconds. That way, even with a very high N it is smaller than the default of
    30k.
    
    Modifications
    -------------
    The code now correctly converts the 2^n to milliseconds before comparing it, making it a comparison
    on the same unit of time again.
    
    Result
    ------
    The ceiling is now properly respected and as a result, reconnect delays are properly capped at
    their defined maximum.
    
    Change-Id: I0c976344d0f8e09bc041d94f3544620ef4fb3117
    Reviewed-on: http://review.couchbase.org/42925
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Commits on Nov 10, 2014
  1. SPY-178: KetamaNodeLocator#getReadonlyCopy uses unsafe operations.

    daschl committed Nov 10, 2014
    Motivation
    ----------
    Users reported java.lang.UnsupportedOperationException when using the
    KetamaNodeLocator#getReadonlyCopy() method. It turns out the error
    only shows up when the JVM is run with the -XX:+AggressiveOpts flag.
    
    Modifications
    -------------
    Changing the iterator to properly update the TreeMap while iterating
    fixes the problem.
    
    Result
    ------
    Correct behavior for KetamaNodeLocator#getReadonlyCopy(), even when
    the -XX:+AggressiveOpts flag is enabled.
    
    Change-Id: I6e7f09892687b8896c9b295a94fb473857ec212f
    Reviewed-on: http://review.couchbase.org/43040
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Commits on Jun 24, 2014
  1. SPY-176: Enhance redistribution logic and avoid possible deadlocks.

    daschl committed Jun 23, 2014
    Motivation
    ----------
    There have been issues reported that redistribution of operations does
    not work as expected, especially with authentication scenarios. This
    has been tracked down and the following changes have been made:
    
    Modifications
    -------------
    
    	- With the old redistribute logic, it could happen that subsequent
    	  ops in the retry queue got accidentally deleted. With the copy
    	  first, this cannot happen anymore.
    	- On redistribute, if the handling node is still not set, just
    	  clone the operation to avoid NPEs. A op without a node set
    	  can happen if it is enqueued to retry because the target node
    	  is not yet authenticated.
    	- Do not try to add operations to a node which is not yet authen
    	  ticated. This can lead to costly locks with redistributions since
    	  they are run from the IO thread. Without the change, it can happen
    	  that the IO thread waits for an auth latch, but is also responsible
    	  for telling listeners when auth has completed, therefore
    	  locking everything up until the auth latch wait runs out of time.
    
    Result
    ------
    Much better resilience and performance with redistributions, especially
    if authentication takes longer than expected and from scenarios where the
    operations get redistributed/moved around from within the IO thread.
    
    Change-Id: Icbc5f9e4f568ea885500e8d2baedfa989c8ef801
    Reviewed-on: http://review.couchbase.org/38669
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on Jun 17, 2014
  1. SPY-175: Reduce memory use in binary GET

    tootedom committed with daschl May 25, 2014
    Change-Id: I9b90aab0b54a2ae7d2c262d499ff47482b9d6c6c
    Reviewed-on: http://review.couchbase.org/38359
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  2. SPY-174: Make sure MultiOperationCallback is threadsafe

    daschl committed Jun 17, 2014
    First, special thanks goes to @exortech for reporting and fixing the issue
    here: #9
    
    Motivation
    ----------
    Certain operations like the multi get callback rely on the multi operation
    callback which has a non-thread safe component to it.
    
    Modification
    ------------
    Make the callback atomic and thread safe.
    
    Result
    ------
    No race conditions with bulk get operation callbacks.
    
    Change-Id: I511a8e5ec6e8fe50168337a4b9bbddf2360bd365
    Reviewed-on: http://review.couchbase.org/38358
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on Jun 4, 2014
  1. SPY-172: Addition - test case fix.

    daschl committed Jun 4, 2014
    Just fixed the port.
    
    Change-Id: I82f55e8cef10c30bac785389b8d3c23d57553206
    Reviewed-on: http://review.couchbase.org/37839
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  2. SPY-172: Wakeup the selector if idle.

    daschl committed Jun 2, 2014
    Motivation
    ----------
    Waking the selector up from time to time and providing implementations a
    chance to run certain checks helps to improve robustness in certain
    situations.
    
    Modifications
    -------------
    The wakeup time is configurable through a system property, but is low
    impact even if set to a smaller value. If the added queue is empty (which
    means the selector has been woken up but no op has been added) a custom
    method is called where implementations can run custom code like idle polls.
    
    Result
    ------
    Better handling in idle situations.
    
    Change-Id: I43ea722b8a4fc28be4f997674ea85f73f2c66a50
    Reviewed-on: http://review.couchbase.org/37725
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  3. SPY-171: More robust shutdown handling characteristics.

    daschl committed Jun 2, 2014
    Motivation
    ----------
    It has been reported several times that the IO thread kept lingering
    around even after a shutdown() call.
    
    Modifications
    -------------
    Since its run() method is kept alive by the "running" variable, the
    code now makes sure to always set it to false, even if an exception
    occurs during the connection shutdown process.
    
    Also, a slightly misleading IOException has been removed in favor of
    just silently moving on if shutdown is in progress.
    
    Result
    ------
    More stable and predictable shutdown behavior.
    
    Change-Id: I99f3effbbb20a78a2705ee7f3f839e9753fb2a4a
    Reviewed-on: http://review.couchbase.org/37724
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on Jun 2, 2014
  1. Move superfluous log message from info to debug.

    daschl committed May 28, 2014
    Motivation
    ----------
    In every log when connecting, a message like this shows up:
    
    INFO [Memcached IO over {MemcachedConnection to ...}] (?:?) - 
    Connection state changed for sun.nio.ch.SelectionKeyImpl@...
    
    This message is superfluous since it does not provide any addition 
    information to the user, especially not at INFO level.
    
    Modifications
    -------------
    The message has been moved to DEBUG level so that users are not 
    wondering what it means and also to streamline the log a bit.
    
    Result
    ------
    Easier log output to read and analyze for the user.
    
    Change-Id: I13ef691dd435f397dc9d5f08ff40a28202d3ddb7
    Reviewed-on: http://review.couchbase.org/37647
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
  2. SPY-170: Fix concurrency issue in StringUtils.isJSONObject()

    daschl committed May 27, 2014
    Motivation
    ----------
    A concurrency issue was reported in the StringUtils class, pointing towards
    the pattern matching of the JSON string.
    
    Modifications
    -------------
    It turned out that the matcher is not thread safe and there is a race condition
    between clearing it and then matching on it. By falling back to the thread-safe
    builder directly the race condition goes away.
    
    Result
    ------
    No concurrency issue anymore in the helper method.
    
    Change-Id: I09729af78bd241ff8dcb0869992d3ff474fb6ec1
    Reviewed-on: http://review.couchbase.org/37603
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  3. SPY-134: Make sure lastReadTimestamp is concurrency safe.

    daschl committed May 28, 2014
    Motivation
    ----------
    When the last read timestamp is read from each node, there has been some
    suspicion that the (sometimes very long) reported times are flawed.
    
    Tracking it down further, it was discovered that the timestamp was potentially
    accessed by two or more threads, but not volatile.
    
    Modifications
    -------------
    This changeset makes the timstamp volatile and also uses nanoTime instead
    of currentTimeMillis for better accuracy.
    
    Result
    ------
    Since the timestamp is now thread safe, the actual value will now be shown
    to the user.
    
    Change-Id: I39e47408319f8adf3b2875a4a730232ecadeafe2
    Reviewed-on: http://review.couchbase.org/37646
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Commits on May 7, 2014
  1. SPY-169: Also clone observe calls on redistribute.

    daschl committed May 5, 2014
    Motivation
    ----------
    Observe calls also need to be cloned when redistributed, for example if a socket
    gets closed or the op stil waits for an auth latch.
    
    Modifications
    -------------
    The observe operation now gets cloned similar to get, gets and so on.
    
    Result
    ------
    No assert error is raised if an observe needs to be cloned.
    
    Change-Id: I6269a1d7fb756855f94caa2fe0495133fe1a83b0
    Reviewed-on: http://review.couchbase.org/36698
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on May 5, 2014
  1. SPY-165: Do not cache the selectedKeys.

    daschl committed Apr 23, 2014
    Motivation
    ----------
    Caching the selected keys may cause issues if the selector is accessed by different
    threads, also the loop for the keys is not using the iterator correct.
    
    Modifications
    -------------
    Make it not cache the keys and also correctly make use of an iterator to loop through
    the keys.
    
    Result
    ------
    No stale/cached selected keys and correctly using the iterator should lead to better
    stability during failure cases.
    
    Thanks to Brad Svee (@sveesible) for suggesting the fix
    
    Change-Id: If82cdfc810c758a4196415cb709a03ebd72c3d15
    Reviewed-on: http://review.couchbase.org/36222
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  2. SPY-166: Only readd a WRITE_QUEUED operation, not clone it in addition.

    daschl committed Apr 24, 2014
    Motivation
    ----------
    When a WRITE_QUEUED operation is redistributed, it needs to be readded
    but not cloned (since its still in a sendable state).
    
    Modification
    ------------
    Return after adding the operation again.
    
    Result
    ------
    The operation is readded and not cloned afterwards too.
    
    Change-Id: I79fec436aa538a8a4074e82f69b3ed186c5126b7
    Reviewed-on: http://review.couchbase.org/36258
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  3. SPY-167: Avoid deadlock on notify listeners.

    daschl committed Apr 23, 2014
    Motivation
    ----------
    Because of how the addListener and notifyListener works, it could be that
    one deadlocks each other because they are waiting on the same locks from
    different threads.
    
    Modifications
    -------------
    The listeners are copied before notified, moving it out of the synch block.
    
    Result
    ------
    Since notify is not synched anymore, the lock should be not happening anymore.
    
    Note that also the listeners array is set to empty which avoid notifying listeners
    more than once potentially.
    
    Thanks to @adamhonen for pointing out the fix.
    
    Change-Id: I7ebda58c2eadd62d8885e3eeac79d5a971e07979
    Reviewed-on: http://review.couchbase.org/36219
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  4. SPY-168: isJSONObject should handle null or empty input values.

    daschl committed May 5, 2014
    Motivation
    ----------
    Before this change, the isJSONObject was suspect to NPEs and possibly also
    regex match failings on empty strings, although that does not seem to be the
    case on Java 1.7+.
    
    Modifications
    -------------
    Specific null and empty checks have been added to make the method more robust.
    
    Result
    ------
    NPEs are not raised anymore and also empty strings are checked much quicker. Test
    cases have been added to verify functionality.
    
    Side note: An exception like this was reported on empty strings, but could not be
    verified with Java 1.7 onward. It is suspected that this changeset also fixes
    the issue given the input type and code process:
    
    Original Exception: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    Stack trace:
    java.lang.String.charAt(String.java:658)
    java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715)
    java.util.regex.Pattern$Ques.match(Pattern.java:4079)
    java.util.regex.Pattern$Begin.match(Pattern.java:3472)
    java.util.regex.Matcher.match(Matcher.java:1221)
    java.util.regex.Matcher.matches(Matcher.java:559)
    net.spy.memcached.util.StringUtils.isJsonObject(StringUtils.java:109)
    net.spy.memcached.transcoders.SerializingTranscoder.encode(Seriali
    ...
    
    Change-Id: Icaca2f3fef658cdb2c376b6b4dba12ae0327f240
    Reviewed-on: http://review.couchbase.org/36695
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
    Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  5. SPY-164: Clone gets correctly.

    daschl committed Apr 23, 2014
    Motivation
    ----------
    When a gets operation is cloned, it currently gets incorrectly cloned into
    a regular get operation. This can cause issues later on.
    
    Modifications
    -------------
    Make sure that a gets() gets correctly cloned into a new gets().
    
    Result
    ------
    The cloning is now properly done, based on the operation type.
    
    Thanks to Brad Svee (@sveesible) for the fix suggestion.
    
    Change-Id: I7b8820bea20d0a0d9555f1bb9b2a46e5327a5f78
    Reviewed-on: http://review.couchbase.org/36221
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Commits on Apr 23, 2014
  1. SPY-163: Count down bulk get latch even when empty key list is provided.

    daschl committed Apr 23, 2014
    Motivation
    ----------
    When a empty iterator (or empty key list) is passed in to a get bulk operation,
    a result is never returned and the thread is blocked because it waits on a
    latch that will never be counted down (because no response will ever arrive).
    
    Modifications
    -------------
    If no chunks with keys are sent out to the servers, the latch is initialized
    to 0 right away so that the code doesn't need to wait at all.
    
    Result
    ------
    The code now returns properly with an empty map instead of blocking the thread
    forever.
    
    Change-Id: I0711c399d9f15010bc808e0f651ce6ad605c06f0
    Reviewed-on: http://review.couchbase.org/36208
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Commits on Apr 14, 2014
  1. SPY-162: Also respect nagle setting on reconnect.

    daschl committed Apr 10, 2014
    Motivation
    ----------
    If a server connection is reset (because it is lost or a reconnection
    is triggered), the nagle setting is not re-set properly.
    
    Modifications
    -------------
    During the reconnect phase, properly re-set the nagle setting so it is
    respected on the new connection.
    
    Result
    ------
    The custom nagle setting is respected and used even across new connections.
    
    Change-Id: Ic0b513b8538a39710aaf8fd0f0f699a5c561bc09
    Reviewed-on: http://review.couchbase.org/35553
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>
  2. Enhanced auth logging on sasl failure.

    daschl committed Apr 14, 2014
    Motivation:
    -----------
    In case of long-taking auth roundtrips, it could be the case - for one 
    reason or another - that a empty sasl list gets returned or the auth 
    thread gets interrupted, leading to the same effect. This needs to 
    be better debugable from the logs.
    
    Modifications:
    --------------
    Better logging has been added for auth failure scenarios, and also the 
    sasl mechs response has been refactored a bit so that the timing is 
    also reported in case of an error.
    
    Result:
    -------
    Auth errors are now easier to debug from the logs.
    
    Change-Id: I9f0fff8b2c3a6b1492fb0fd82746ff78f7b006c5
    Reviewed-on: http://review.couchbase.org/35672
    Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
    Reviewed-by: Matt Ingenthron <matt@couchbase.com>