Problem analysis of Linux version membase unable to write to default bucket

Source: Internet
Author: User
Tags couchbase memcached

Recent projects used in the membase found a problem, the production environment read and write all kinds of data are normal, but the new development environment, only the default bucket is not written data, call store always return false, the configuration file is identical, Really do not know where the problem, the other buckets are normal read and write, and, in the development environment of the membase on a new bucket is also normal read and write. Finally found the production on the Windows version of the Membase, and the development environment is the Linux (CentOS) version, suspected may be related to the server version, so installed a version of Windows, sure enough, everything is OK. As for the Linux version (couchbase) Why this problem, still have to spend time to find out why.

Project use of Dll:membase.dll 2.14.0.0,enyim.caching.dll 2.11.0.0, anti-compilation can see the code, but not good debugging, you can find the appropriate source code on the Internet:

    • Https://github.com/enyim/EnyimMemcached
    • Https://github.com/xianrendzw/LightFramework.Net

The second is to put Membase source package in the Lightframework.caching project, I am that code to check the reason.

Since the store failed, let's step through and see where the default bucket and other buckets are different in the store method.

public bool Store (Storemode mode, string key, Object value) {    ulong tmp = 0;    return this. Performstore (mode, key, value, 0, ref TMP);}

you can see that the actual call is the Performstore method, followed by the discovery of var node = this.pool.Locate (Hashedkey), will return null, that is, no corresponding bucket is found, then what data ah.


Check why the return is NULL, we found that when initializing the membaseclient instance, we need to get the bucket information to the registered ServerURL (whether it is legitimate, the state is normal, etc.), call the Resolvebucket method, the result is abnormal. 401 error, not authorized!





When we initialize with other buckets, we find that the credential in the client parameter of the method is a value (username, password), And the default bucket is null. This should be the cause. Manually set the credential username to default, request the bucket verification information again, and sure enough, it returns correctly.



wonder, is not the default defaults can not set the password, how do we need to verify it? Google-related issues, found that many people do not know how to break, and even said that the Membase bug:

    • Http://grokbase.com/t/gg/enyim-memcached/11anh26mtr/membase-client-401-getting-config-from-pool-url
    • https://issues.couchbase.com/browse/MB-2166
    • Http://qnalist.com/questions/5796245/membase-client-401-getting-config-from-pool-url
    • Http://grokbase.com/t/gg/enyim-memcached/11anh26mtr/membase-client-401-getting-config-from-pool-url

In the process of finding the problem, I found that if the bucket is default, Membase.dll will empty its bucketname and password, meaning that it does not require authentication, go to the special port 11210 (the other bucket walk is 11211 authentication), since the comments are so, that is the request for wool in the bucket authentication information also need authentication?



The problem that default cannot write is caused by the above reasons, for the Windows version of Membase Server does not exist, I have tested, there is no authentication limit for the default bucket. And for the Linux version, through the source tracking process, the authentication information is manually modified, but also can read and write, but unfortunately, can not initialize the external membaseclient when the credential configuration is correct. There is another solution that uses memcachedclient because Membase is compatible with the Memcached SDK, so you can initialize the operation instance as follows:

var config = new memcachedclientconfiguration (); config. Addserver ("192.168.1.12", 11211), var client = new Memcachedclient (config), client. Store (Storemode.set, DateTime.Now.ToString ("Hhmmss"), "TestValue");

It is also normal to read and write the default bucket in this way.

Problem analysis of Linux version membase unable to write to default bucket

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.