C* users,

The simple code below demonstrates pycassa failing to write values containing more than one-tenth that thrift_framed_transport_size_in_mb. It writes a single column row using a UUID key.

For example, with the default of

        thrift_framed_transport_size_in_mb: 15

the code below shows pycassa failing on rows of 1.5MB of data:

2013-05-10 16:09:13,251 10441:69: adding 
UUID('59f14d33-c4a6-49ce-80ce-48a3ee433cbf') with 1.500000 MB
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:13,370 10441:25: connection_failed: reset pool??

Sometimes it says "TSocket read 0 bytes" and other times "Connection reset by peer". I have tried changing the thrift_framed_transport_size_in_mb and the 10% pattern holds. Possibly related to:

        https://github.com/pycassa/pycassa/issues/168

I thought the whole point of framed transport was to split things up so they can be larger than a single frame. Is that wrong? This is breaking at just 10% of the frame size.

Maybe we broke something else?

Pycassa is using framed transport -- see assert in code below.

This AWS m1.xlarge was constructed just for this test using DataStax AMI:

  http://www.datastax.com/docs/1.2/install/install_ami

http://ec2-23-22-224-180.compute-1.amazonaws.com:8888/opscenter/index.html


The code and log output are attached. The log was generating running on another m1.xlarge running in the same Amazon data center.

Thanks for any ideas.
-John

import uuid
import getpass
import logging
logger = logging.getLogger('test')
logger.setLevel( logging.INFO)

ch = logging.StreamHandler()
ch.setLevel( logging.DEBUG )
formatter = logging.Formatter('%(asctime)s %(process)d:%(lineno)d: %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)

## get the Cassandra client library
import pycassa
from pycassa.pool import ConnectionPool
from pycassa.system_manager import SystemManager, SIMPLE_STRATEGY, \
    LEXICAL_UUID_TYPE, ASCII_TYPE, BYTES_TYPE

log = pycassa.PycassaLogger()
log.set_logger_name('pycassa_library')
log.set_logger_level('debug')
log.get_logger().addHandler(logging.StreamHandler())

class Listener(object):
    def connection_failed(self, dic):
        logger.critical('connection_failed: reset pool??')

## this is an m1.xlarge doing nothing but supporting this test
server = 'ec2-23-22-224-180.compute-1.amazonaws.com:9160'
keyspace = 'testkeyspace_' + getpass.getuser().replace('-', '_')
family = 'testcf'
sm = SystemManager(server)
try:
    sm.drop_keyspace(keyspace)
except pycassa.InvalidRequestException:
    pass
sm.create_keyspace(keyspace, SIMPLE_STRATEGY, {'replication_factor': '1'})
sm.create_column_family(keyspace, family, super=False,
                        key_validation_class = LEXICAL_UUID_TYPE,
                        default_validation_class  = LEXICAL_UUID_TYPE,
                        column_name_class = ASCII_TYPE)
sm.alter_column(keyspace, family, 'test', ASCII_TYPE)
sm.close()

pool = ConnectionPool(keyspace, [server], max_retries=10, pool_timeout=0, 
pool_size=10, timeout=120)
pool.fill()
pool.add_listener( Listener() )

## assert that we are using framed transport
import thrift
conn = pool._q.get()
assert isinstance(conn.transport, thrift.transport.TTransport.TFramedTransport)
pool._q.put(conn)

try:
    for k in range(20):
        ## write some data to cassandra using increasing data sizes
        big_data = ' ' * 2**18 * k
        num_rows = 10
        keys = []
        rows = []
        for i in xrange(num_rows):
            key = uuid.uuid4()
            rows.append((key, dict(test=big_data)))
            keys.append(key)

        testcf = pycassa.ColumnFamily(pool, family)
        with testcf.batch() as batch:
            for (key, data_dict) in rows:
                data_size = len(data_dict.values()[0])
                logger.critical('adding %r with %.6f MB' % (key, 
float(data_size)/2**20))
                batch.insert(key, data_dict)

        logger.critical('%d rows written' % num_rows)

finally:
    sm = SystemManager(server)
    try:
        sm.drop_keyspace(keyspace)
    except pycassa.InvalidRequestException:
        pass
    sm.close()
    logger.critical('clearing test keyspace: %r' % keyspace)
Server list obtained for pool 140020167927056: 
[ec2-23-22-224-180.compute-1.amazonaws.com:9160]
Connection 140020167927568 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167927696 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167927824 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167927952 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928208 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928336 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928464 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928592 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928720 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167927696 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167927696 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,195 10441:69: adding 
UUID('debded77-177d-4823-b4eb-7341255372aa') with 0.000000 MB
2013-05-10 16:09:12,196 10441:69: adding 
UUID('896e0d96-290b-438d-84b9-87ae2d1c272c') with 0.000000 MB
2013-05-10 16:09:12,196 10441:69: adding 
UUID('41eba66e-da11-4053-aea0-170b7d03af18') with 0.000000 MB
2013-05-10 16:09:12,196 10441:69: adding 
UUID('b6299099-b31b-4165-9054-b12a02288f1f') with 0.000000 MB
2013-05-10 16:09:12,196 10441:69: adding 
UUID('dfb06f0d-7f0b-49b2-bea6-e62847b4ded5') with 0.000000 MB
2013-05-10 16:09:12,196 10441:69: adding 
UUID('d1e3f937-516d-49b7-8bee-997a77038672') with 0.000000 MB
2013-05-10 16:09:12,196 10441:69: adding 
UUID('8eea2955-ab72-4e8b-915b-21bd71cff51e') with 0.000000 MB
2013-05-10 16:09:12,197 10441:69: adding 
UUID('bd882ee8-a620-4222-aad2-debd92b2b1be') with 0.000000 MB
2013-05-10 16:09:12,197 10441:69: adding 
UUID('3ae4ff69-4686-426a-83a7-132c7435393e') with 0.000000 MB
2013-05-10 16:09:12,197 10441:69: adding 
UUID('27f6699c-01f3-462e-97cd-757f19ac370d') with 0.000000 MB
Connection 140020167927824 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167927824 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,203 10441:72: 10 rows written
Connection 140020167927952 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167927952 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,206 10441:69: adding 
UUID('e5ee6198-3880-4579-8f83-0eeeec8a1a1d') with 0.250000 MB
2013-05-10 16:09:12,206 10441:69: adding 
UUID('f7ce1976-18a9-4790-90ac-d6341963e65a') with 0.250000 MB
2013-05-10 16:09:12,206 10441:69: adding 
UUID('d8587106-1a1f-4b94-bc76-9b78ce95b382') with 0.250000 MB
2013-05-10 16:09:12,206 10441:69: adding 
UUID('77d7deb8-441a-4757-a785-1d5afbb92f81') with 0.250000 MB
2013-05-10 16:09:12,207 10441:69: adding 
UUID('17e1c41b-1b15-496e-8b51-98fb13b291eb') with 0.250000 MB
2013-05-10 16:09:12,207 10441:69: adding 
UUID('d4b9e067-ed9f-4f17-b10a-48d51877ad6d') with 0.250000 MB
2013-05-10 16:09:12,207 10441:69: adding 
UUID('336fae12-cc6a-42aa-80fd-9a7db154562e') with 0.250000 MB
2013-05-10 16:09:12,207 10441:69: adding 
UUID('7b213ef6-e2a9-4c20-a328-655ef689d2a0') with 0.250000 MB
2013-05-10 16:09:12,207 10441:69: adding 
UUID('3508f1e5-3064-428c-b22b-421e48e162c6') with 0.250000 MB
2013-05-10 16:09:12,207 10441:69: adding 
UUID('c743c923-7340-4a07-8c0a-36eca4dc8b86') with 0.250000 MB
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,312 10441:72: 10 rows written
Connection 140020167928208 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928208 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,316 10441:69: adding 
UUID('b8f6c940-ca61-4a38-9f82-28ae087d1978') with 0.500000 MB
2013-05-10 16:09:12,316 10441:69: adding 
UUID('7b3a481f-63d3-4e4c-b124-61a4c4c4179a') with 0.500000 MB
2013-05-10 16:09:12,316 10441:69: adding 
UUID('fd7a8bff-a50b-4aa8-8180-eb04cd9c70ca') with 0.500000 MB
2013-05-10 16:09:12,317 10441:69: adding 
UUID('dad0e0ad-de50-46b5-b349-aab996a84a0a') with 0.500000 MB
2013-05-10 16:09:12,317 10441:69: adding 
UUID('aaf38f6f-56b1-4e3f-9575-857c611b71cd') with 0.500000 MB
2013-05-10 16:09:12,317 10441:69: adding 
UUID('8dae5085-27f0-4097-b353-cc2a6f6c3be8') with 0.500000 MB
2013-05-10 16:09:12,317 10441:69: adding 
UUID('2780d943-6957-4688-96a0-be81dcaad088') with 0.500000 MB
2013-05-10 16:09:12,317 10441:69: adding 
UUID('15424312-849b-4bba-93f2-bca4ef42abe1') with 0.500000 MB
2013-05-10 16:09:12,317 10441:69: adding 
UUID('502c3bbf-003a-4b84-bcea-08500638e68a') with 0.500000 MB
2013-05-10 16:09:12,318 10441:69: adding 
UUID('72c634bb-d295-46e8-a1e2-6effef8be8c9') with 0.500000 MB
Connection 140020167928336 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928336 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,475 10441:72: 10 rows written
Connection 140020167928464 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928464 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,479 10441:69: adding 
UUID('e67801ce-d150-4710-bfe7-a146f4b3f8b0') with 0.750000 MB
2013-05-10 16:09:12,479 10441:69: adding 
UUID('a0a8448c-61d1-4d8b-80a8-8c09a9e1a32c') with 0.750000 MB
2013-05-10 16:09:12,480 10441:69: adding 
UUID('482d185f-c9fd-4121-a8d2-1e10ae7930bc') with 0.750000 MB
2013-05-10 16:09:12,480 10441:69: adding 
UUID('b4b2fd24-b5d5-4c85-b81a-aa9024c9968c') with 0.750000 MB
2013-05-10 16:09:12,480 10441:69: adding 
UUID('44940d72-d1ff-441c-ae04-abcce1c962ec') with 0.750000 MB
2013-05-10 16:09:12,480 10441:69: adding 
UUID('3c7fe04a-0cf1-42a5-b4e0-5eb3ef2d0b1c') with 0.750000 MB
2013-05-10 16:09:12,480 10441:69: adding 
UUID('5db2fc4c-6f79-430d-b3a0-6c3931c7a60b') with 0.750000 MB
2013-05-10 16:09:12,480 10441:69: adding 
UUID('4a2fd8c4-0073-46c8-9683-135e7bb11bee') with 0.750000 MB
2013-05-10 16:09:12,480 10441:69: adding 
UUID('183eef30-da2e-4efe-9b9d-7f18e79e6ed7') with 0.750000 MB
2013-05-10 16:09:12,481 10441:69: adding 
UUID('10678cfb-caa5-4198-83b1-d90c83209454') with 0.750000 MB
Connection 140020167928592 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928592 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,685 10441:72: 10 rows written
Connection 140020167928720 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928720 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,690 10441:69: adding 
UUID('13b9860e-b963-4ee4-b26e-c890c58a6854') with 1.000000 MB
2013-05-10 16:09:12,690 10441:69: adding 
UUID('9c97ae91-a4a5-4638-91fb-4217dbab8da9') with 1.000000 MB
2013-05-10 16:09:12,690 10441:69: adding 
UUID('3e2313f5-07fe-42c5-b9f0-2621b0636757') with 1.000000 MB
2013-05-10 16:09:12,690 10441:69: adding 
UUID('9b6c6119-ccd4-4402-a8ff-ab065a826e94') with 1.000000 MB
2013-05-10 16:09:12,690 10441:69: adding 
UUID('e99a3d21-c621-4fde-a665-3f75297a4385') with 1.000000 MB
2013-05-10 16:09:12,690 10441:69: adding 
UUID('8b2cab54-9cff-4d7c-9b10-2bbf0e8f0afa') with 1.000000 MB
2013-05-10 16:09:12,691 10441:69: adding 
UUID('4835a35c-f1e5-4084-92cc-8d1c83454884') with 1.000000 MB
2013-05-10 16:09:12,691 10441:69: adding 
UUID('d7e4b7b5-1f70-4f57-8d0e-50fdbbc4d563') with 1.000000 MB
2013-05-10 16:09:12,691 10441:69: adding 
UUID('1ec2894e-b7b8-4591-a642-94573e06f654') with 1.000000 MB
2013-05-10 16:09:12,691 10441:69: adding 
UUID('5e47db9e-ee9e-42fb-a923-24c6d5fb8c4c') with 1.000000 MB
Connection 140020167927568 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167927568 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,932 10441:72: 10 rows written
Connection 140020167927696 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167927696 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:12,937 10441:69: adding 
UUID('a336537e-41b3-42dc-9d0a-6ea217afb00d') with 1.250000 MB
2013-05-10 16:09:12,937 10441:69: adding 
UUID('cfb1ad2c-df54-440f-9ccd-8800fc19eeac') with 1.250000 MB
2013-05-10 16:09:12,937 10441:69: adding 
UUID('b2d2749b-2439-40c2-8327-60ec3a872234') with 1.250000 MB
2013-05-10 16:09:12,937 10441:69: adding 
UUID('695382ff-785e-4d8c-9e3f-90d69c232111') with 1.250000 MB
2013-05-10 16:09:12,937 10441:69: adding 
UUID('75978a00-9547-44cb-9d23-9c239b2a04ab') with 1.250000 MB
2013-05-10 16:09:12,938 10441:69: adding 
UUID('ae91ece0-da76-4991-bd79-57d820df4948') with 1.250000 MB
2013-05-10 16:09:12,938 10441:69: adding 
UUID('cb3df9fe-07a5-49ee-8ea5-148a64f28561') with 1.250000 MB
2013-05-10 16:09:12,938 10441:69: adding 
UUID('dc5ce59b-f2a6-4c3b-947f-e7288b73de3b') with 1.250000 MB
2013-05-10 16:09:12,938 10441:69: adding 
UUID('619c5df1-7401-4417-a605-00d695d29484') with 1.250000 MB
2013-05-10 16:09:12,938 10441:69: adding 
UUID('4f8064ed-c7b2-4851-baa1-1ab7974c36a0') with 1.250000 MB
Connection 140020167927824 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167927824 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:13,230 10441:72: 10 rows written
Connection 140020167927952 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167927952 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked in to pool 140020167927056
2013-05-10 16:09:13,250 10441:69: adding 
UUID('d8a31630-3b90-46d0-9e34-1b7638044c62') with 1.500000 MB
2013-05-10 16:09:13,250 10441:69: adding 
UUID('ba14b6fc-f9ed-4d33-b64d-d705f405ad22') with 1.500000 MB
2013-05-10 16:09:13,250 10441:69: adding 
UUID('0b08d080-ec72-4f6e-b4a1-1227b8e28dac') with 1.500000 MB
2013-05-10 16:09:13,250 10441:69: adding 
UUID('d6a9c9fc-5775-4da7-92db-2f7cc89e6761') with 1.500000 MB
2013-05-10 16:09:13,250 10441:69: adding 
UUID('970b13be-b61d-4ff5-b13c-dd329f307337') with 1.500000 MB
2013-05-10 16:09:13,251 10441:69: adding 
UUID('ba608688-adc1-4b3c-b97d-64bc7c26b997') with 1.500000 MB
2013-05-10 16:09:13,251 10441:69: adding 
UUID('c72574d5-f562-4780-8a86-b509138bf3d0') with 1.500000 MB
2013-05-10 16:09:13,251 10441:69: adding 
UUID('6e795783-2eb3-4a1f-84a5-0554d568c461') with 1.500000 MB
2013-05-10 16:09:13,251 10441:69: adding 
UUID('8f79775e-ef9d-4879-8b0f-4b2dd42c3f2b') with 1.500000 MB
2013-05-10 16:09:13,251 10441:69: adding 
UUID('59f14d33-c4a6-49ce-80ce-48a3ee433cbf') with 1.500000 MB
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:13,370 10441:25: connection_failed: reset pool??
Connection 140020167966864 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928208 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:13,485 10441:25: connection_failed: reset pool??
Connection 140020167966928 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928336 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:13,618 10441:25: connection_failed: reset pool??
Connection 140020167968592 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928464 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:13,791 10441:25: connection_failed: reset pool??
Connection 140020167969424 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928592 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:14,045 10441:25: connection_failed: reset pool??
Connection 140020167970768 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167928720 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:14,459 10441:25: connection_failed: reset pool??
Connection 140020167970256 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167927568 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:15,193 10441:25: connection_failed: reset pool??
Connection 140020167970384 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167927696 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:16,569 10441:25: connection_failed: reset pool??
Connection 140020167967824 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167927824 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:19,230 10441:25: connection_failed: reset pool??
Connection 140020167969552 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167927952 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:24,451 10441:25: connection_failed: reset pool??
Connection 140020167968336 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167966864 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:34,794 10441:25: connection_failed: reset pool??
Connection 140020167968976 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) 
opened for pool 140020167927056
Connection 140020167966928 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) was 
checked out from pool 140020167927056
Connection 140020167928080 (ec2-23-22-224-180.compute-1.amazonaws.com:9160) in 
pool 140020167927056 failed: [Errno 104] Connection reset by peer
2013-05-10 16:09:55,380 10441:25: connection_failed: reset pool??
import uuid
import getpass
import logging
logger = logging.getLogger('test')
logger.setLevel( logging.INFO)

ch = logging.StreamHandler()
ch.setLevel( logging.DEBUG )
formatter = logging.Formatter('%(asctime)s %(process)d:%(lineno)d: %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)

## get the Cassandra client library
import pycassa
from pycassa.pool import ConnectionPool
from pycassa.system_manager import SystemManager, SIMPLE_STRATEGY, \
    LEXICAL_UUID_TYPE, ASCII_TYPE, BYTES_TYPE

log = pycassa.PycassaLogger()
log.set_logger_name('pycassa_library')
log.set_logger_level('debug')
log.get_logger().addHandler(logging.StreamHandler())

class Listener(object):
    def connection_failed(self, dic):
        logger.critical('connection_failed: reset pool??')

## this is an m1.xlarge doing nothing but supporting this test
server = 'ec2-23-22-224-180.compute-1.amazonaws.com:9160'
keyspace = 'testkeyspace_' + getpass.getuser().replace('-', '_')
family = 'testcf'
sm = SystemManager(server)
try:
    sm.drop_keyspace(keyspace)
except pycassa.InvalidRequestException:
    pass
sm.create_keyspace(keyspace, SIMPLE_STRATEGY, {'replication_factor': '1'})
sm.create_column_family(keyspace, family, super=False,
                        key_validation_class = LEXICAL_UUID_TYPE,
                        default_validation_class  = LEXICAL_UUID_TYPE,
                        column_name_class = ASCII_TYPE)
sm.alter_column(keyspace, family, 'test', ASCII_TYPE)
sm.close()

pool = ConnectionPool(keyspace, [server], max_retries=10, pool_timeout=0, pool_size=10, timeout=120)
pool.fill()
pool.add_listener( Listener() )

## assert that we are using framed transport
import thrift
conn = pool._q.get()
assert isinstance(conn.transport, thrift.transport.TTransport.TFramedTransport)
pool._q.put(conn)

try:
    for k in range(20):
        ## write some data to cassandra using increasing data sizes
        big_data = ' ' * 2**18 * k
        num_rows = 10
        keys = []
        rows = []
        for i in xrange(num_rows):
            key = uuid.uuid4()
            rows.append((key, dict(test=big_data)))
            keys.append(key)

        testcf = pycassa.ColumnFamily(pool, family)
        with testcf.batch() as batch:
            for (key, data_dict) in rows:
                data_size = len(data_dict.values()[0])
                logger.critical('adding %r with %.6f MB' % (key, float(data_size)/2**20))
                batch.insert(key, data_dict)

        logger.critical('%d rows written' % num_rows)

finally:
    sm = SystemManager(server)
    try:
        sm.drop_keyspace(keyspace)
    except pycassa.InvalidRequestException:
        pass
    sm.close()
    logger.critical('clearing test keyspace: %r' % keyspace)

Reply via email to