From cassandra-user-return-2475-apmail-incubator-cassandra-user-archive=incubator.apache.org@incubator.apache.org Mon Feb 08 22:07:02 2010 Return-Path: Delivered-To: apmail-incubator-cassandra-user-archive@minotaur.apache.org Received: (qmail 64865 invoked from network); 8 Feb 2010 22:07:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Feb 2010 22:07:02 -0000 Received: (qmail 85864 invoked by uid 500); 8 Feb 2010 22:07:01 -0000 Delivered-To: apmail-incubator-cassandra-user-archive@incubator.apache.org Received: (qmail 85855 invoked by uid 500); 8 Feb 2010 22:07:01 -0000 Mailing-List: contact cassandra-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cassandra-user@incubator.apache.org Delivered-To: mailing list cassandra-user@incubator.apache.org Received: (qmail 85846 invoked by uid 99); 8 Feb 2010 22:07:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Feb 2010 22:07:01 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jbellis@gmail.com designates 209.85.219.212 as permitted sender) Received: from [209.85.219.212] (HELO mail-ew0-f212.google.com) (209.85.219.212) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Feb 2010 22:06:53 +0000 Received: by ewy4 with SMTP id 4so55129ewy.27 for ; Mon, 08 Feb 2010 14:06:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=6Es9ZD6J93rtJ2ogo4sSBklDovTLkOS8cV0aDaXPgWk=; b=vTCVyZHbBs8fMuMsS7u0+7gXjDdsK3PhoUOZkanejIfSVYHGpvQqPznLInwgdFCLnt j60z10oBG71RRa80ow1ebC5y2ETpeYAyxjNLzMggb0aV48zCwKs/7HIUKSRgJMChniOR O7mvIo2NqOPsM+woLO5HPig8T0hSkgLCWAkmE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=j18l0kTPzPQeZmG0fAIYWT/gnRU+ueEyLuz9X1s2S3WDoDfxrJCyF+0lEorBB3UxWz 2z0t5X8dh+CfncqYqVfdSP8y3Z/klMYZoH1Xl+syPlFDW2OK+ccXjGj5ymIu7H6pTv6e J4ArHClDm3JGcntH/5h1faU6DZ6ij9A1R6hCk= MIME-Version: 1.0 Received: by 10.216.85.130 with SMTP id u2mr2139357wee.135.1265666792907; Mon, 08 Feb 2010 14:06:32 -0800 (PST) In-Reply-To: <261c158e1002061705h2f3e3429md81864bc1edb628@mail.gmail.com> References: <261c158e1002060004q7e0220a4q47ff8c3c502e376c@mail.gmail.com> <261c158e1002061401j60bb4378uce1f61b6bb6fd65a@mail.gmail.com> <261c158e1002061705h2f3e3429md81864bc1edb628@mail.gmail.com> From: Jonathan Ellis Date: Mon, 8 Feb 2010 16:06:12 -0600 Message-ID: Subject: Re: get_key_range() vs. get_range_slice() -- scan/counting errors To: cassandra-user@incubator.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Can you create a ticket for this, please? Thanks! On Sat, Feb 6, 2010 at 7:05 PM, Jack Culpepper wr= ote: > I did a bit more testing, and it does seem to be related to having two > nodes. When I turn one node off and repeat the range scan, I get the > same result, but if I start with only one node and do all the inserts > and then a range scan, I get the correct count using > get_range_slice(). > > However, with two nodes there is a very easy way to replicate the > problem. Just clear out your Test Keyspace and insert 1000 keys. For > example, here I use pycassa to do that. > > if 1: > =A0 =A0import pycassa > =A0 =A0import uuid > > =A0 =A0client =3D pycassa.connect(["10.212.87.165:9160"]) > =A0 =A0cf_test =3D pycassa.ColumnFamily(client, "Test Keyspace", "Test > Super", super=3DTrue) > > =A0 =A0for i in xrange(1000): > =A0 =A0 =A0 =A0key =3D uuid.uuid4().hex > =A0 =A0 =A0 =A0cf_test.insert(key, { 'params' : { 'is' : 'cool' }}) > =A0 =A0 =A0 =A0print key > > Hear me out before you argue that pycassa is the problem. I haven't > actually done this using the raw thrift interface, but only the > retrieval is problemic. You can run this code and pipe the output to a > file to record all the keys that were inserted. Now use the regular > thrift interface to try and get them back: > > if 1: > =A0 =A0from thrift import Thrift > =A0 =A0from thrift.transport import TTransport > =A0 =A0from thrift.transport import TSocket > =A0 =A0from thrift.protocol.TBinaryProtocol import TBinaryProtocolAcceler= ated > =A0 =A0from cassandra import Cassandra > =A0 =A0from cassandra.ttypes import * > > =A0 =A0socket =3D TSocket.TSocket("10.212.87.165", 9160) > =A0 =A0transport =3D TTransport.TBufferedTransport(socket) > =A0 =A0protocol =3D TBinaryProtocol.TBinaryProtocolAccelerated(transport) > =A0 =A0client =3D Cassandra.Client(protocol) > > =A0 =A0transport.open() > > > =A0 =A0column_parent =3D ColumnParent(column_family=3D"Test Super") > =A0 =A0slice_range =3D SliceRange(start=3D"key", finish=3D"key") > =A0 =A0#slice_range =3D SliceRange(start=3D"", finish=3D"") > =A0 =A0predicate =3D SlicePredicate(slice_range=3Dslice_range) > > =A0 =A0done =3D False > =A0 =A0seg =3D 1000 > =A0 =A0start =3D "" > > =A0 =A0while not done: > =A0 =A0 =A0 =A0#result =3D client.get_key_range("Test Keyspace", "Test Su= per", > start, "", seg, ConsistencyLevel.ONE) > =A0 =A0 =A0 =A0result =3D client.get_range_slice("Test Keyspace", > column_parent, predicate, start, "", seg, ConsistencyLevel.ONE) > > =A0 =A0 =A0 =A0if len(result) < seg: done =3D True > =A0 =A0 =A0 =A0#else: start =3D result[seg-1] > =A0 =A0 =A0 =A0else: start =3D result[seg-1].key > > > =A0 =A0 =A0 =A0for r in result: > =A0 =A0 =A0 =A0 =A0 =A0#print r > =A0 =A0 =A0 =A0 =A0 =A0print r.key > > Using get_range_slice() I see only keys from > 562ab7792af249be8e73ba2ace5a5888 to 9fd73cf2ab264571a5654c315ab6e93d, > but with get_key_range() I see keys from > 01b12cdae9464d1ab4cf2f89808883d9 to ffda307823ee43eeac590a3201b81962. > > That is, get_key_range() retrieves *all* the keys, but > get_range_slice() does not. Thus, it seems unlikely that there is a > problem with pycassa or the way I did my insertions if get_key_range() > is able to work properly. > > I also just read through the "How to retrieve keys from Cassandra ?" > thread. I agree with Jean-Denis Greze that it would be nice to have a > method to retrieve all the keys at a particular node, instead of a > range of keys. > > Jack > > On Sat, Feb 6, 2010 at 2:01 PM, Jack Culpepper = wrote: >> Well, from the output I included you can see that get_slice_range() >> does not return any keys above >> 9ffff14fd361b981faea6a04c5ef5699a96a8d6d, whereas get_key_range() >> finds keys all the way up to ffffffa1b5e3aeb9ca92d4d848280093bdf49892. >> >> My program stops if either function ever returns less keys than >> requested (1000 in this case). >> >> I have 2 nodes and a replication factor of 2, so both nodes should >> have all the data, right? >> >> If I turn off one node and try the same test, I get the same result -- >> that is, get_key_range() finds many more key than get_slice_range(). I >> haven't tested the case where I delete all the data, launch only a >> single node and do all the inserts on a single node, and then compare >> both methods. If you would like me to do that I can. >> >> Jack >> >> On Sat, Feb 6, 2010 at 10:16 AM, Jonathan Ellis wrot= e: >>> It would help if you could narrow it down to "here are the keys I >>> expect to see that I am not," especially if you can reproduce on a >>> single-node cluster. >>> >>> On Sat, Feb 6, 2010 at 2:04 AM, Jack Culpepper wrote: >>>> Hi Jonathon, >>>> >>>> I am seeing a dramatic difference in the number of keys I can scan >>>> when I use these two methods. >>>> >>>> The former (deprecated) method seems to return the correct result. >>>> That is, it's on the right order of magnitude of around 500K, and if I >>>> continue to insert keys via a separate process as I repeatedly count >>>> them, the count grows. The recommended alternative, get_range_slice(), >>>> returns far fewer keys and if I count repeatedly as I insert using a >>>> separate process, the count bounces around erratically. >>>> >>>> I am using the python thrift interface against a two node setup. I am >>>> running the current 0.5.0 release (just upgraded from rc1 since I saw >>>> some other thrift bug was fixed). Here is my program (there are three >>>> commented lines to switch from one method to the other): >>>> >>>> if sys.argv[1] =3D=3D "count_things": >>>> >>>> =A0 =A0from thrift import Thrift >>>> =A0 =A0from thrift.transport import TTransport >>>> =A0 =A0from thrift.transport import TSocket >>>> =A0 =A0from thrift.protocol.TBinaryProtocol import TBinaryProtocolAcce= lerated >>>> =A0 =A0from cassandra import Cassandra >>>> >>>> =A0 =A0socket =3D TSocket.TSocket("10.212.230.176", 9160) >>>> =A0 =A0transport =3D TTransport.TBufferedTransport(socket) >>>> =A0 =A0protocol =3D TBinaryProtocol.TBinaryProtocolAccelerated(transpo= rt) >>>> =A0 =A0client =3D Cassandra.Client(protocol) >>>> >>>> =A0 =A0transport.open() >>>> >>>> =A0 =A0column_parent =3D ColumnParent(column_family=3D"thing") >>>> =A0 =A0slice_range =3D SliceRange(start=3D"key", finish=3D"key") >>>> =A0 =A0predicate =3D SlicePredicate(slice_range=3Dslice_range) >>>> >>>> =A0 =A0done =3D False >>>> =A0 =A0seg =3D 1000 >>>> =A0 =A0start =3D "" >>>> >>>> =A0 =A0while not done: >>>> =A0 =A0 =A0 =A0#result =3D client.get_key_range("gg", "thing", start, = "", seg, >>>> ConsistencyLevel.ONE) >>>> =A0 =A0 =A0 =A0result =3D client.get_range_slice("gg", column_parent, >>>> predicate, start, "", seg, ConsistencyLevel.ONE) >>>> >>>> =A0 =A0 =A0 =A0if len(result) < seg: done =3D True >>>> =A0 =A0 =A0 =A0#else: start =3D result[seg-1] >>>> =A0 =A0 =A0 =A0else: start =3D result[seg-1].key >>>> >>>> =A0 =A0 =A0 =A0record_count +=3D len(result) >>>> >>>> =A0 =A0 =A0 =A0t =3D now() >>>> =A0 =A0 =A0 =A0dt =3D t - startTime >>>> =A0 =A0 =A0 =A0record_per_sec =3D record_count / dt >>>> =A0 =A0 =A0 =A0#print "\rstart %d now %d dt %d rec/s %.4f rec %d s %s = f >>>> %s"%(startTime,t,dt,record_per_sec,record_count,result[0],result[-1]), >>>> =A0 =A0 =A0 =A0print "\rstart %d now %d dt %d rec/s %.4f rec %d s %s f >>>> %s"%(startTime,t,dt,record_per_sec,record_count,result[0].key,result[-= 1].key), >>>> =A0 =A0print >>>> >>>> An example of the output using get_range_slice(), without a concurrent >>>> insertion process -- it counts 133674 keys. >>>> >>>> start 1265440888 now 1265441098 dt 210 rec/s 636.1996 rec 133674 s >>>> 9f9dd2c0f043902f7f571942cfac3f6c28b82cec f >>>> 9ffff14fd361b981faea6a04c5ef5699a96a8d6d >>>> >>>> Using get_key_range() I get 459351 keys, and the throughput is less: >>>> >>>> start 1265442143 now 1265443092 dt 948 rec/s 484.2775 rec 459351 s >>>> ffce8099f808d10a09db471b04793315f555ccbd f >>>> ffffffa1b5e3aeb9ca92d4d848280093bdf49892 >>>> >>>> get_range_slice() seems to skip keys in each of the segments. >>>> >>>> The "thing" column family is a super column. There are no errors >>>> reported to the log. The keys I am inserting are python generated >>>> UUIDs: >>>> >>>> import uuid >>>> key =3D uuid.uuid4().hex >>>> >>>> I'm not posting the program that inserts the data, but I can if that >>>> would be help. Thanks very much, >>>> >>>> Jack >>>> >>> >> >