We remove the poller too early; after _ready_to_respond becomes ready,
it is likely to have been inserted again.
Fix by moving it after _ready_to_respond.
From Avi:
We currently send out each cql transport response in its own packet, which
is very inefficient.
Use a poller to schedule responses to be flushed out, which allows multiple
responses to be sent out in one packet, reducing tcp stack overhead.
I see ~50% improvement with this on my desktop (single core).
Instead of flushing responses immediately, ask a reactor poller to flush
them for us. This lets several responses to be flushed out together in
one packet.
get_query_state() creates new query state if it cannot find existing
one. Because of that it cannot be safely called from multiple cpus.
The solution is taking advantage form the fact that
query_processor::prepare() only needs a const reference to client_state
object.
Fixes#329.
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
"This series optimizes CQL query parameter handling by avoiding memory
allocation and copies where possible. I have only tested with the POSIX
stack and have not seen performance difference in cassandra-stress
because Linux networking dominates the profiles. The optimizations
should improve things with DPDK, though, because the
cql_server::read_query_options() hotspot is effectively eliminated."
Store values as bytes view when possible. This improves the CQL protocol
option parsing path by avoiding allocating memory and copying individual
values as "bytes" objects.
Please note that we retain the non-view version for internal queries
where performance is not as important.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
While we have a with_gate() call when using the connection, it is
somewhere deep in the bowels of process_request_one(). If that
continuation is deferred, the gate can be closed without anyone
noticing that a request is still working on it; when we do hit the
with_gate, we'll see a use-after-free.
Encapsulate the '_values' vector to make it easier to switch the
underlying type from bytes_opt to bytes_view_opt.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
There are two counters for the "current number of open connections" in the cql_server:
- _connects: incremented every time a new connection is opened. Should be used for
a derived statistics of connections/sec
- _connections: incremented and decremented every time a new connection is opened/closed
correspondingly.
_connects has been registered as a source for both derived and gauge collectd statistics by
mistake while it had to be registered for a derived counter only and _connections had to be
registered as a source for a gauge counter.
Fixes issue #143
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Move the connection class to server.hh so that we can move event
notifier implementation to a separate source file.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Move member function definitions outside of the class definition in
preparation for moving the latter to a header file.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
We need to also catch exceptions in top-level connection::process() so
that they are converted to proper CQL protocol errors.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
We do serialization in transport/server.cc and there's no need for
the equals() and hashCode() function so just drop ifdef'd code.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
The last two arguments to vector::insert() are flipped which causes us
to fill the vector with 'b' bytes of value 0x01. Switch to the single
element insertion variant to fix the issue.
Spotted by dtest push notification tests.
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
We also need to encode the event type in the response message. Fixes the
following dtest breakage:
cassandra.connection: ERROR: Error decoding response from Cassandra. opcode: 000c; message contents: '\x83\x00\xff\xff\x0c\x00\x00\x00\x17\x00\x07CREATED\x00\x08KEYSPACE\x00\x02ks'
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/cassandra/connection.py", line 431, in process_msg
flags, opcode, body, self.decompressor)
File "/usr/lib64/python2.7/site-packages/cassandra/protocol.py", line 123, in decode_response
msg = msg_class.recv_body(body, protocol_version, user_type_map)
File "/usr/lib64/python2.7/site-packages/cassandra/protocol.py", line 803, in recv_body
raise NotSupportedError('Unknown event type %r' % event_type)
NotSupportedError: Unknown event type u'CREATED'
Reported-by: Shlomi Livne <shlomi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
"This series implements initial support for CQL events. We introduce
migration_listener hook in migration manager as well as event notifier
in the CQL server that's built on top of it to send out the events via
CQL binary protocol. We also wire up create keyspace events to the
system so subscribed clients are notified when a new keyspace is
created.
There's still more work to be done to support all the events. That
requires some work to restructure existing code so it's better to merge
this initial series now and avoid future code conflicts."