Commit Graph

1919 Commits

Author SHA1 Message Date
Tomasz Grabiec
b77367dabe cql3: Simplify primary key membership checks 2015-02-27 10:48:56 +01:00
Tomasz Grabiec
609e893055 unimplemented: Separate subject from behavior
You can now do:

  fail(unimplemented::cause::PAGING);

and:

  warn(unimplemented::cause::PAGING);
2015-02-27 10:48:56 +01:00
Tomasz Grabiec
1f9d22f7e3 types: Fix read_simple*() variants to work for unaligned positions
Since types can be embedded at any position in memory we cannot assume
alignment.

Side note: It seems that on x86 access to the variable via packed<>
does not result in any extra instructions.
2015-02-27 10:48:56 +01:00
Tomasz Grabiec
00984609cb types: Add abstract_tyep::is_value_compatible_with() method 2015-02-27 10:48:56 +01:00
Tomasz Grabiec
f21d85cfc5 tests: Stop distributed db when test ends
Fixes:

cql_query_test: ./core/distributed.hh:150: distributed<Service>::~distributed() [with Service = database]: Assertion `_instances.empty()' failed.
2015-02-27 10:48:55 +01:00
Tomasz Grabiec
1dfc7267db cql3: Fix formatting in relation.hh 2015-02-27 10:46:05 +01:00
Avi Kivity
a7132359a8 Merge branch 'glommer/sstables-v2' of github.com:cloudius-systems/seastar-dev into db
Sstable support from Glauber:

"These are the new sstable parsers, based on recursive templates.
They currently read the following files successfully:
 - Filter
 - Statistics
 - Compression
 - Summary (sans the indices, which are schema dependent)

The TOC file is also parsed, but slightly different because it contains
a newline separated list of strings. The CRC and Digest files are not
yet read, but they are only used for consistency checking, which can wait.

Aside from that, only missing the Data and Index files themselves."
2015-02-26 19:17:52 +02:00
Glauber Costa
8015b1c1bb sstable: unit tests
This tests the sstable parsing code. The tables provided as exemple are real
tables, that I was using to test my code manually.

The corrupt tables, however, are corrupted by hand.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-02-26 12:14:20 -05:00
Glauber Costa
fb3682cb4f sstable statistics file
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 12:14:19 -05:00
Glauber Costa
0d98caf885 summary file
TODO: read in the actual index. This is schema-dependent.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 12:14:19 -05:00
Glauber Costa
1b75a5bccb bloom filter
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 12:14:19 -05:00
Glauber Costa
d810f03bb7 compression file
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 12:14:19 -05:00
Glauber Costa
3e4ab6848b read toc
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 12:14:19 -05:00
Glauber Costa
cc4f8f09e5 parser: disk_hash type
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 12:06:25 -05:00
Glauber Costa
110facf479 parser: more basic types
bool, enum and double.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 12:06:25 -05:00
Glauber Costa
001606209a sstable parser
This is a parser for the sstable files based on template recursion.
With this, one can easily extend it to parse any complex data structure
by writing

    parse(in, struct.a, struct.b ... );

This patch contains the most basic types used during parsing as building
blocks.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-02-26 12:06:25 -05:00
Glauber Costa
b7281bd463 sstables: initial file
This represents an sstable with its multiple in-disk file. We don't yet
read any of them, though.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 12:06:25 -05:00
Avi Kivity
ede9a5b634 build: enable native network stack for urchin 2015-02-26 18:49:28 +02:00
Avi Kivity
d39c844ea3 Merge branch 'master' of github.com:cloudius-systems/seastar into db
Conflicts:
	configure.py
	database.cc (added missing include)
	utils/serialize.hh (added missing inlines)
2015-02-26 17:57:18 +02:00
Tomasz Grabiec
1fadd7d608 net: Move ipv4_addr constructor to the source file
boost::join() provided by boost/algorithm/string.hpp conflicts with
boost::join() from boost/range/join.hpp. It looks like a boost issue
but let's not pollute the namespace unnecesssarily.

Regarding the change in configure.py, it looks like scollectd.cc is
part of the 'core' package, but it needs 'net/api.hh', so I added
'net/net.cc' to core.
2015-02-26 17:34:27 +02:00
Glauber Costa
6b77cf7d08 linecount: change rw to ro
Avi says it is enough.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-02-26 17:30:02 +02:00
Glauber Costa
9861bfca01 open_file_dma: allow the specification of open flags
It is sometimes frustrating to use open_file_dma, because it has the hardcoded
behavior of always assuming O_CREAT. Sometimes this is not desirable, and it
would be nice to have the option not to do so.

Note that, by design, I am only including in the open_flags enum things that we
want the user of the API to control. Stuff like O_DIRECT should not be
optional, and therefore is not included in the visible interface.

Because of that I am changing the function signature to include a paramater
that specifies whether or not we should create the file if it does not exist.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-02-26 17:30:02 +02:00
Nadav Har'El
4df5e6acff Start translating db/SystemKeyspace.java to C++
Only partially translated. I had to comment out some "static"
specifications to avoid compiler warnings because these are not used yet.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
2015-02-26 14:55:03 +01:00
Nadav Har'El
ede451b7f8 Add db/SystemKeyspace.java from origin
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-26 14:54:34 +01:00
Pekka Enberg
a3b2a70f65 tests/perf: CQL statement parser performance test
Add a performance test case for CQL statement parsing to better
understand its performance impact. We also include ANTLR tokenizer and
parser setup as that's what we do in query_processor for each request.

Running the test on my Haswell machine yields the following results:

  [penberg@nero urchin]$ build/release/tests/perf/perf_cql_parser
  Timing CQL statement parsing...
  108090.10 tps
  125366.11 tps
  124400.64 tps
  124274.75 tps
  124850.85 tps

That means that CQL parsing alone sets an upper limit of 120k requests
per second for Urchin for a single core.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-26 14:14:53 +01:00
Dor Laor
6f36fd48ad Tiny nitpicks in readme file 2015-02-26 13:07:50 +02:00
Dor Laor
381717a66e Run ispell on README.md 2015-02-26 13:07:37 +02:00
Dor Laor
1492ae9040 README: Add explanation about 100% cpu consumption and recommended configuration 2015-02-26 12:40:15 +02:00
Avi Kivity
76b19e920b Merge branch 'slab' of github.com:cloudius-systems/seastar-dev
Slabify memcached, from Raphael.
2015-02-26 11:49:11 +02:00
Tomasz Grabiec
cd7a05660e tests: Simplify schema object construction 2015-02-26 10:03:19 +02:00
Raphael S. Carvalho
67560bec48 test: Add slab allocator testcase
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-25 19:32:57 -03:00
Raphael S. Carvalho
aa6d850228 memcached: Integrate slab allocator
* Item structure was changed to work with slab, where its last field
is used to access key, value, and ascii prefix, respectively.
* Item structured was worked to have a smaller footprint. It was
reduced from 104 bytes to 72 bytes.
* Reclaimer was temporarily disabled.
* Global LRU was removed from the cache. Now LRU eviction is done
on a per-slab-class basis, whenever the slab allocator runs out of
slab pages.
* Fragmentation issue is naturally solved with the slab algorithm,
where slab classes have chunks of the same size.
2015-02-25 19:29:36 -03:00
Raphael S. Carvalho
6dea362304 Add experimental::string_view option to scattered_message::append_static
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-25 19:29:36 -03:00
Raphael S. Carvalho
66117b2697 memcached: Expiry should be stored as a 32-bit value
Expiration time is a 32-bit value as specified by memcached protocol.
Thus, no need to store it as a 64-bit value. When the value is needed,
convert it to the target type. Change intended to save space from
item structure.
In addition, there is no need to insert an entry into _alive when
expiration time is zero, meaning item will never expire.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-25 19:29:36 -03:00
Raphael S. Carvalho
03ae698ce1 core: Add slab allocator
* Slab allocator resembles the one used by stock memcached, where
it's composed of slab classes and slab classes are composed of
chunks of the same size.
* Per-slab-class LRU is also available.
* Slab allocator exports stats to collectd.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
2015-02-25 19:29:36 -03:00
Raphael S. Carvalho
b461b42ce8 memcached: Revert flashcached
Flashcached integration was done relying on certain similarities between
flashcached and memcached. Old assumptions no longer hold.
As a result, the current code is terrible to integrate the slab allocator
into it, while keeping flashcached alive.
This patch reverts flashcached from memcached. It should be re-integrated
in the future, but definitely in a better way.
2015-02-25 19:29:36 -03:00
Nadav Har'El
8701273006 Add inet type
In v2: rebase, and add a more descriptive exception if trying to deserialize
an ipv6 address.

Add to list of types the Internet address type, known as INET in CQL
or as InetAddressType in the Cassandra code.

I based this code on stuff I found in InetAddressType and
InetAddressSerializer in the Cassandra code.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-25 15:57:05 +01:00
Pekka Enberg
4d0c58c5e8 transport/server: Stop printing queries
There's no point in printing out every query, especially when running
cassandra-stress.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 14:06:11 +02:00
Tomasz Grabiec
ec262ab3e9 cql3: Fix use-after-free on statement
Reported by Pekka:

READ of size 8 at 0x611000062ee8 thread T6
    #0 0x64d20f in std::unique_ptr<cql3::attributes, std::default_delete<cql3::attributes> >::get() const /usr/include/c++/4.9.2/bits/unique_ptr.h:305
    #1 0x641532 in std::unique_ptr<cql3::attributes, std::default_delete<cql3::attributes> >::operator->() const /usr/include/c++/4.9.2/bits/unique_ptr.h:299
    #2 0x63af5b in cql3::statements::modification_statement::get_time_to_live(cql3::query_options const&) const cql3/statements/modification_statement.hh:190
    #3 0x61e072 in _ZZN4cql310statements22modification_statement22make_update_parametersE13lw_shared_ptrISt6vectorI13basic_sstringIcjLj31EESaIS5_EEES2_IS3_INSt12experimental8optionalIS5_EESaISB_EEERKNS_13query_optionsEblENKUlT_E_clINSA_ISt13unordered_mapIS5_St3mapIjN5boost3anyESt4lessIjESaISt4pairIKjSO_EEE15serialized_hash16serialized_equalSaISR_IKS5_SV_EEEEEEEDaSI_ (/home/penberg/urchin/build/debug/seastar+0x61e072)
    #4 0x625ce1 in apply core/apply.hh:34
    #5 0x625df4 in apply<cql3::statements::modification_statement::make_update_parameters(lw_shared_ptr<std::vector<basic_sstring<char, unsigned int, 31u> > >, lw_shared_ptr<std::vector<std::experimental::optional<basic_sstring<char, unsigned int, 31u> > > >, const cql3::query_options&, bool, int64_t)::<lambda(auto:18)>, std::experimental::optional<std::unordered_map<basic_sstring<char, unsigned int, 31u>, std::map<unsigned int, boost::any, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, boost::any> > >, serialized_hash, serialized_equal, std::allocator<std::pair<const basic_sstring<char, unsigned int, 31u>, std::map<unsigned int, boost::any, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, boost::any> > > > > > > > core/apply.hh:41
    #6 0x628354 in _ZZN6futureIINSt12experimental8optionalISt13unordered_mapI13basic_sstringIcjLj31EESt3mapIjN5boost3anyESt4lessIjESaISt4pairIKjS7_EEE15serialized_hash16serialized_equalSaISA_IKS4_SE_EEEEEEE4thenIZN4cql310statements22modification_statement22make_update_parametersE13lw_shared_ptrISt6vectorIS4_SaIS4_EEESR_ISS_INS1_IS4_EESaISW_EEERKNSO_13query_optionsEblEUlT_E_EENSt9result_ofIFT_OSL_EE4typeEOS16_NSt9enable_ifIXsr9is_futureIIS1A_EE5valueEPvE4typeEENUlRS13_E_clI12future_stateIISL_EEEEDaRS16_ (/home/penberg/urchin/build/debug/seastar+0x628354)
    #7 0x628503 in _ZZN6futureIINSt12experimental8optionalISt13unordered_mapI13basic_sstringIcjLj31EESt3mapIjN5boost3anyESt4lessIjESaISt4pairIKjS7_EEE15serialized_hash16serialized_equalSaISA_IKS4_SE_EEEEEEE8scheduleIZNSM_4thenIZN4cql310statements22modification_statement22make_update_parametersE13lw_shared_ptrISt6vectorIS4_SaIS4_EEESS_IST_INS1_IS4_EESaISX_EEERKNSP_13query_optionsEblEUlT_E_EENSt9result_ofIFT_OSL_EE4typeEOS17_NSt9enable_ifIXsr9is_futureIIS1B_EE5valueEPvE4typeEEUlRS14_E_EEvS1C_EN21task_with_ready_state3runEv (/home/penberg/urchin/build/debug/seastar+0x628503)
    #8 0x7a6600 in reactor::run_tasks(circular_buffer<std::unique_ptr<task, std::default_delete<task> >, std::allocator<std::unique_ptr<task, std::default_delete<task> > > >&, unsigned long) core/reactor.cc:691
    #9 0x7a8ccc in reactor::run() core/reactor.cc:785
    #10 0x7b0bef in smp::configure(boost::program_options::variables_map)::{lambda()#1}::operator()() const (/home/penberg/urchin/build/debug/seastar+0x7b0bef)
    #11 0x84011d in _M_invoke /usr/include/c++/4.9.2/functional:2039
    #12 0x860c97 in std::function<void ()>::operator()() const /usr/include/c++/4.9.2/functional:2439
    #13 0x8e45fa in posix_thread::start_routine(void*) core/posix.cc:50
    #14 0x7f25abb05529 in start_thread (/lib64/libpthread.so.0+0x7529)
    #15 0x7f25ab84179c in __clone (/lib64/libc.so.6+0x10079c)

0x611000062ee8 is located 40 bytes inside of 216-byte region [0x611000062ec0,0x611000062f98)
freed by thread T6 here:
    #0 0x7f25af4bf64f in operator delete(void*) (/lib64/libasan.so.1+0x5864f)
    #1 0x684dbf in shared_ptr_count_for<cql3::statements::update_statement>::~shared_ptr_count_for() core/shared_ptr.hh:261
    #2 0x63de36 in shared_ptr<cql3::cql_statement>::~shared_ptr() core/shared_ptr.hh:326
    #3 0x772711 in cql3::statements::parsed_statement::prepared::~prepared() cql3/statements/parsed_statement.hh:60
    #4 0x77591d in std::default_delete<cql3::statements::parsed_statement::prepared>::operator()(cql3::statements::parsed_statement::prepared*) const /usr/include/c++/4.9.2/bits/unique_ptr.h:76
    #5 0x772cef in std::unique_ptr<cql3::statements::parsed_statement::prepared, std::default_delete<cql3::statements::parsed_statement::prepared> >::~unique_ptr() /usr/include/c++/4.9.2/bits/unique_ptr.h:236
    #6 0x76c8ea in cql3::query_processor::process(std::experimental::basic_string_view<char, std::char_traits<char> > const&, service::query_state&, cql3::query_options&) cql3/query_processor.cc:51
    #7 0x554e9c in cql_server::connection::process_query(unsigned short, temporary_buffer<char>) transport/server.cc:408
    #8 0x553a7a in cql_server::connection::process_request()::{lambda(future<std::experimental::optional<cql_binary_frame_v3> >&&)#1}::operator()(future<std::experimental::optional<cql_binary_frame_v3> >&&) const::{lambda(temporary_buffer<char>)#1}::operator()(temporary_buffer) const (/home/penberg/urchin/build/debug/seastar+0x553a7a)
    #9 0x55df9e in apply core/apply.hh:34
    #10 0x55e0b1 in apply<cql_server::connection::process_request()::<lambda(future<std::experimental::optional<cql_binary_frame_v3> >&&)>::<lambda(temporary_buffer<char>)>, temporary_buffer<char> > core/apply.hh:41
    #11 0x55e43b in then<cql_server::connection::process_request()::<lambda(future<std::experimental::optional<cql_binary_frame_v3> >&&)>::<lambda(temporary_buffer<char>)> > core/future.hh:480
    #12 0x5542c1 in cql_server::connection::process_request()::{lambda(future<std::experimental::optional<cql_binary_frame_v3> >&&)#1}::operator()(future<std::experimental::optional<cql_binary_frame_v3> >&&) const (/home/penberg/urchin/build/debug/seastar+0x5542c1)
    #13 0x564846 in _ZZNO6futureIINSt12experimental8optionalI19cql_binary_frame_v3EEEE12then_wrappedIZN10cql_server10connection15process_requestEvEUlOS4_E_EENSt9result_ofIFT_S4_EE4typeEOSB_ENUlRT_E_clI12future_stateIIS3_EEEEDaRSB_ (/home/penberg/urchin/build/debug/seastar+0x564846)
    #14 0x5649c7 in _ZZN7promiseIINSt12experimental8optionalI19cql_binary_frame_v3EEEE8scheduleIZNO6futureIIS3_EE12then_wrappedIZN10cql_server10connection15process_requestEvEUlOS7_E_EENSt9result_ofIFT_S7_EE4typeEOSE_EUlRT_E_EEvSI_EN15task_with_state3runEv (/home/penberg/urchin/build/debug/seastar+0x5649c7)
    #15 0x7a6600 in reactor::run_tasks(circular_buffer<std::unique_ptr<task, std::default_delete<task> >, std::allocator<std::unique_ptr<task, std::default_delete<task> > > >&, unsigned long) core/reactor.cc:691
    #16 0x7a8ccc in reactor::run() core/reactor.cc:785
    #17 0x7b0bef in smp::configure(boost::program_options::variables_map)::{lambda()#1}::operator()() const (/home/penberg/urchin/build/debug/seastar+0x7b0bef)
    #18 0x84011d in _M_invoke /usr/include/c++/4.9.2/functional:2039
    #19 0x860c97 in std::function<void ()>::operator()() const /usr/include/c++/4.9.2/functional:2439
    #20 0x8e45fa in posix_thread::start_routine(void*) core/posix.cc:50
    #21 0x7f25abb05529 in start_thread (/lib64/libpthread.so.0+0x7529)

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
2015-02-25 12:48:54 +01:00
Pekka Enberg
fd0a6e0596 types: Fix bytes_type_impl unimplemented methods
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 13:39:10 +02:00
Avi Kivity
81a42a3d13 Merge branch 'penberg/long-type-improvements' of github.com:cloudius-systems/sea
star-dev into db

Long type improvements, from Pekka:

"There's unimplemented methods in long_type_impl that are already
implemented in int32_type_impl. Generify the latter and use that for
long_type_impl as well."
2015-02-25 13:38:26 +02:00
Pekka Enberg
8d740220d2 transport/server: Make request processing errors visible
If request processing throws an exception, print it to stdout rather
than silently ignoring it. Eventually we need to respond with ERROR
message to the client.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 13:37:27 +02:00
Pekka Enberg
9f49033279 types: Use integer_type_impl for long_type_impl
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 13:17:36 +02:00
Pekka Enberg
e98584713e types: Introduce generic integer_type_impl
Introduce a generic integer_type_impl that's based on int32_type_impl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 13:17:36 +02:00
Pekka Enberg
bd9547ba77 types: Use sizeof(int32_t) instead of hard-coded 4
Switch to sizeof in preparation for converting int32_type_impl into a
generic integer_type_impl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 13:08:16 +02:00
Gleb Natapov
11f5a8e398 add default constructors to iostreams and connected_socket
Makes life of a programmer easier since it allows to define variables of
those types ahead of object creation.
2015-02-25 12:50:03 +02:00
Nadav Har'El
b64f26832e reactor: terminate cleanly in or_terminate()
The ".or_terminate()" continuation is needed when one needs to exit the
application on an unhandled exception, instead of just letting the event
loop continue to spin forever.

or_terminate() currently calls std::terminate() which only incidentally
(as a gcc-specific implementation) prints out the exception's type; It
then calls abort(), which results in a painfully slow core dump. This
abort() is NOT helpful, because at that point the debugger can only find
where abort() was called, not where the original exception was thrown (see
issue #32).

So instead of calling std::terminate(), this patch switches to calling
engine().exit(), to cleanly shut down the application, without dumping
core. It also prints, like gcc's std::terminate(), the exception's type.
This printing requires non-standard gcc extensions.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-02-25 12:28:34 +02:00
Pekka Enberg
6b65fcf85f transport/server: Query response messages
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 11:23:15 +01:00
Tomasz Grabiec
e0bff0c28e tests: Add test exploiting dynamic_pointer_cast bug 2015-02-25 11:56:07 +02:00
Pekka Enberg
39f4a58bde cql3: Implement use_statement::execute()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-02-25 10:18:18 +01:00