Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

.Net Client (DP3) causing storage problems

5 replies [Last post]
  • Login or register to post comments
Mon, 09/17/2012 - 16:03
Tim Barlow
Offline
Joined: 09/12/2012
Groups: None

I'm running couchbase-server-community_x86_64_2.0.0-1554-rel as a single server on OS X and reading & writing to it from .NET application using Couchbase-Net-Client-1.2-DP-3.

I initially wrote a series of JSON objects to the database. Using the browser console the objects displayed correctly, that is, all the objects were there and they displayed as structured JSON objects.

However, after deleting and rewriting a number of the objects from/to the database NONE of the database objects no longer appeared as JSON objects. Instead, each resembled a single stream of Base64 encoded characters.

Despite this, when the objects where read back into the .Net application the objects appeared as JSON objects and were successfully deserialized.

Since my colleague has been using Couchbase extensively via a Groovy interface without any problems at all I suspect the culprit is the .Net client.

So, is this a known problem and if so when may a fix available ?

Many thanks

Top
  • Login or register to post comments
Tue, 09/18/2012 - 16:02
ingenthr
Offline
Joined: 03/16/2010
Groups:

This doesn't sound like a known problem, but given that we've fixed a number of issues recently and released both a beta of Couchbase Server 2.0 and a beta of the Couchbase .NET client 1.2, can you check that out?

Let me know if it's reproducible with those versions, and then we can dig in further if needed.

Top
  • Login or register to post comments
Fri, 09/28/2012 - 12:41
john
Offline
Joined: 01/05/2012
Groups: None

Could you post the .NET code that was used?

Top
  • Login or register to post comments
Fri, 09/28/2012 - 23:59
Tim Barlow
Offline
Joined: 09/12/2012
Groups: None

I've dug a little deeper and found out exactly what the problem is ...

I'm attempting to write a complex object to Couchbase as a JSON string.
My object has several levels of embedded objects including collections of objects.

If I serialize the object (using Newtonsoft.Json) without any serialization settings then ...
... when the resulting JSON string is written it displays in the console correctly as a structured JSON object
... BUT when I read the string back it does not deserialize the string correctly
(in particular the embedded objects are not deserialized at all, they remain as JSON strings)

If I serialize / deserialize the object with the serialization settings ...
TypeNameHandling = TypeNameHandling.All
TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full

... when the resulting JSON string is written it displays in the console as an attachment (it appears as
a binary string and thus can not be used for indexing)
... HOWEVER when I read the string back it does deserialize correctly

In short, the use of the serialize / deserialize settings seems to affect the manner in which Couchbase stores the data.

Code sample ...

POI poi = (POI)mnppObjectCreator.CreatePOIObject(nltKey);

// Generate a JSON object from the POI object
JsonSerializerSettings settings = new JsonSerializerSettings {
TypeNameHandling = TypeNameHandling.All, TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full
};
string jsonInputObject = JsonConvert.SerializeObject(poi, settings);

// Write the JSON object to couchbase database
WriteToCouchbase(couchbaseClient, "POI:" + nltKey, jsonInputObject);

private void WriteToCouchbase(CouchbaseClient couchbaseClient, String key, Object jsonObject)
{
IStoreOperationResult result = couchbaseClient.ExecuteStore(StoreMode.Set, key, jsonObject);
if (!result.Success)
{
throw new TPException("EMPS150-1", "Could not write JSON object to CouchBase instance for key '" + key + "' ");
}
}

I shall be away from my desk for a couple of weeks but will be monitoring my email.

Top
  • Login or register to post comments
Thu, 12/20/2012 - 06:05
liza87
Offline
Joined: 12/20/2012
Groups: None

This bug is still present in the beta of the Couchbase .NET client 1.2.
Any chance of fixing this?

Top
  • Login or register to post comments
Fri, 12/21/2012 - 10:28
john
Offline
Joined: 01/05/2012
Groups: None

If Newtonsoft.Json is somehow producing a JSON string that Couchbase Server doesn't recognize as valid JSON, then the server creates the document as an attachment.

If someone has an example of an object graph that they could either attach to a new Jira issues (http://www.couchbase.com/issues) or to this post, I'll investigate. The client itself doesn't deal with JSON other than to send the string to the server.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker