Commit Graph

119 Commits

Author SHA1 Message Date
Avi Kivity
987294a412 Add missing copyrights 2015-09-20 10:16:11 +03:00
Avi Kivity
93871e4392 tranport: more straightforward poller removal during connection close
Instead of calling do_flush(), just remove the connection from the poll
list directly.
2015-09-19 09:22:32 +03:00
Pekka Enberg
87d6ea940d transport/server: Improve "truncated frame" error message
Include expected size as well as frame length to improve debuggability.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-09-19 08:46:37 +03:00
Avi Kivity
5f32c00f5f transport: fix removal of response batch poller when then connection terminates
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.
2015-09-17 20:08:07 +02:00
Tomasz Grabiec
6fa49e8fbc Merge tag 'avi/cql-batching/v2' from seastar-dev.git
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).
2015-09-16 16:56:47 +02:00
Avi Kivity
675c0bbdd4 transport: batch responses
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.
2015-09-16 15:04:19 +03:00
Avi Kivity
518720fcbb transport: disable zero-copy
Zero-copy requires pushing a packet to the output stream, which defeats any
attempt at batching.  Disable it for now; we will revisit it later.
2015-09-16 14:19:23 +03:00
Calle Wilund
7d502e2301 transport/server.cc: Implement process_batch
Equivalent of Origins BatchMessage.
2015-09-15 11:20:16 +02:00
Paweł Dziepak
977f2ff0a7 transport: do not call get_query_state() on other cpus
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>
2015-09-10 18:02:45 +03:00
Pekka Enberg
fd9336afa6 transport/server: Fix keyspace schema change serializations
There's in-wire format difference between v1/v2 and the later v3
protocols. Fixes #307.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-09-10 10:35:59 +03:00
Paweł Dziepak
39c29a3fb4 types: add decimal type
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-09-08 16:04:48 +02:00
Avi Kivity
cc6fa97b35 Revert "transport: improve exception handling on connection close"
This reverts commit 0558a56ab5.  As Vlad points
out, it is bogus.  Real fix in 5ddbaf8612.
2015-09-01 15:16:18 +03:00
Avi Kivity
0558a56ab5 transport: improve exception handling on connection close
An exception would cause us not to wait on the _ready_to_respond future,
causing a use-after-free.
2015-08-31 14:45:11 +03:00
Avi Kivity
a9a3b47781 Merge "Optimize CQL query parameters" from Pekka
"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."
2015-08-24 09:19:56 +03:00
Pekka Enberg
10c6eee221 transport/server: Use sstring_view for query option names
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-24 09:06:13 +03:00
Pekka Enberg
5263b712fb transport/server: read_string_view() helper
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-24 09:06:13 +03:00
Pekka Enberg
6dee204db2 cql3/query_options: Store values as bytes view
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>
2015-08-24 09:06:13 +03:00
Avi Kivity
f2e612ebd8 transport: log another request write processing error
An assertion failure (abandoned promise) led me to believe an error is
generated and ignored here.  Let's try to trap it.
2015-08-23 19:36:57 +03:00
Avi Kivity
8377236273 transport: protect against race in using cql connection gate
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.
2015-08-23 19:34:53 +03:00
Avi Kivity
2b4eaf83ab transport: set TCP_NODELAY
Reduces latency.
2015-08-18 15:48:36 +03:00
Paweł Dziepak
944d0e5366 transport: encode tuple types properly
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-08-17 14:42:21 +02:00
Pekka Enberg
5b9901d693 cql3/query_options: Encapsulate underlying values
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>
2015-08-17 09:48:58 +03:00
Vlad Zolotarov
cb55bdbfbc transport: register the correct "current number of open connections" statistics counter source
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>
2015-08-16 12:56:11 +03:00
Gleb Natapov
0b3d2de2f1 Fix mutation write timeout exception reporting
Make it compatible with CQL specification
2015-08-12 14:58:48 +03:00
Pekka Enberg
5c99a58b27 transport: Move cql_server and event_notifier to transport namespace
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-12 09:59:36 +03:00
Pekka Enberg
3ab87c216e transport/server: Use pragma once as include guard
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-12 09:59:36 +03:00
Pekka Enberg
a3c194b050 transport/server: Move event_notifier class to separate file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-12 09:59:35 +03:00
Pekka Enberg
3ad4e4e829 transport/server: Move connection class definition to server.hh
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>
2015-08-12 09:59:09 +03:00
Pekka Enberg
42f865a3de transport/server: Clean up connection class definition
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>
2015-08-12 09:25:09 +03:00
Pekka Enberg
d461443bf2 transport/server: Fix error handling in parse_frame()
Throw a protocol exception instead of killing the process with abort().

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-11 14:33:30 +03:00
Pekka Enberg
48abeefdda transport/server: Fix connection version mismatch validation
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-11 14:33:30 +03:00
Pekka Enberg
bb067782d7 transport/server: Fix CQL binary protocol version validation
We only support up to CQL protocol v3. Fixes #117.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-11 14:33:30 +03:00
Pekka Enberg
ad041207a4 transport/server: Catch all request processing errors
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>
2015-08-11 14:33:21 +03:00
Pekka Enberg
33ce99b732 transport/event: Move implementation to source file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-07 09:28:46 +03:00
Pekka Enberg
fad7b28abf transport/event: Convert ifdef'd assertion
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-07 09:23:51 +03:00
Pekka Enberg
ce9f78932e transport/event: Fix class definition indentation
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-07 09:21:28 +03:00
Pekka Enberg
4b5a89be69 transport/event: Eliminate ifdef'd code
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>
2015-08-06 15:55:51 +03:00
Pekka Enberg
c706fc9ea8 transport/server: Fix logger format strings
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:55:01 +03:00
Pekka Enberg
c8128de562 transport/server: Hook event notifier to lifecycle events
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:48 +03:00
Pekka Enberg
dc4171e8d7 transport/server: Fix response::write_inet()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:40 +03:00
Pekka Enberg
096e02469e transport/server: Fix response::write_byte()
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>
2015-08-06 15:26:40 +03:00
Pekka Enberg
92c813d562 transport/server: Topology and status change event encoding
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:40 +03:00
Pekka Enberg
f5ac4a3738 transport/event: Convert TopologyChange and StatusChange to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 15:26:40 +03:00
Vlad Zolotarov
a77ca1c29b cql_server::do_accepts(): Use logger.debug() for connection errors logging
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-06 13:03:20 +03:00
Pekka Enberg
e5ca713e72 transport/server: Fix schema change event encoding
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>
2015-08-05 15:16:50 +03:00
Avi Kivity
55ca295154 Merge "Initial CQL event support" from Pekka
"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."
2015-08-05 12:56:37 +03:00
Pekka Enberg
66f7f05eef transport/server: Wire up event notifier to process_register()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:52 +03:00
Pekka Enberg
07c8f0b1ac transport/server: Add read_string_list() helper
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:51 +03:00
Pekka Enberg
27068fe912 transport/server: Event notifier
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:51 +03:00
Pekka Enberg
6e29d51c0a transport/server: Add write_schema_change_event() helper
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:51 +03:00