Commit Graph

350 Commits

Author SHA1 Message Date
Asias He
67953a65b6 db/system_keyspace: Stub load_host_ids 2015-08-18 17:06:03 +08:00
Asias He
ab40ab6c19 db/system_keyspace: Stub load_tokens 2015-08-18 17:06:02 +08:00
Asias He
7f98a89968 db/system_keyspace: Introduce init_local_cache 2015-08-18 17:06:02 +08:00
Glauber Costa
0177c7fed1 system keyspace: implement get_bootstrap_state
To avoid spreading the futures all over, we will resort to a cache with this,
the same way we did for the dc/rack information.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-17 11:03:37 -07:00
Glauber Costa
20590db87f system keyspace: implement set_bootstrap_state
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-17 11:03:37 -07:00
Glauber Costa
8a50534119 system keyspace: implement get_saved_tokens
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-17 11:03:37 -07:00
Glauber Costa
6a682d0e49 storage_service: futurize get_tokens
Because all its users are already futurized, this is actually an easy one.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-17 11:03:37 -07:00
Glauber Costa
bebb2abe4b system keyspace: factor out local_cache start code
It will now be used for other values as well.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-17 11:03:36 -07:00
Calle Wilund
8f0f4e7945 Commitlog: do more extensive dir entry probes to determine type
Since directory_entry "type" might not be set.
Ensuring that code does not remain future free or easy to read.

Fixes #157.
2015-08-17 16:56:31 +03:00
Vlad Zolotarov
4e55033dc9 db::config: improve a help output for --endpoint_snitch parameter
- Improve the output formating.
   - Comment out not supported snitches.

Fixes issue #124

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-08-16 12:55:34 +03:00
Avi Kivity
11bf4efc72 Merge "Some changes to deal with allocation failures in CL" from Calle
"Related to 108
Does not fix the problem (fully at least), but at least:
* Throws exceptions instead of crashing
* Tries to back off slighly (allocate less) if possible
* Logs it

Also recycles segments to keep them from being fragmented by mem system"
2015-08-12 17:47:25 +03:00
Calle Wilund
2db7791c6a Commitlog: Attempt to reduce allocation size for segment if alloc fails 2015-08-12 16:20:12 +02:00
Calle Wilund
4fe98d3acf Commitlog: Throw bad_alloc on memalign fail (avoid sigsegv later) 2015-08-12 16:20:11 +02:00
Calle Wilund
7191a130bb Commitlog: recycle buffers to reduce fragmentation. 2015-08-12 16:20:11 +02:00
Gleb Natapov
0b3d2de2f1 Fix mutation write timeout exception reporting
Make it compatible with CQL specification
2015-08-12 14:58:48 +03:00
Asias He
ce927105d8 db/system_keyspace: Implement update_local_tokens 2015-08-12 07:50:26 +08:00
Asias He
95dd307597 db/system_keyspace: Remove duplicated commented out code
I'm not sure what happened. We have the same commented code in both .hh
and .cc. It is very confusing when enabling some of the code. Let's
remove the duplicated code in .cc and leave the in .hh only.
2015-08-12 07:50:26 +08:00
Asias He
96fe749141 db/system_keyspace: Stub get_bootstrap_state and friends 2015-08-12 07:50:26 +08:00
Asias He
5cb5050ca1 system_keyspace: Stub get_saved_tokens 2015-08-12 07:50:26 +08:00
Calle Wilund
9a52ad84b1 BatchlogManager: make blm globally reachable distributed like other objects 2015-08-11 17:10:17 +02:00
Calle Wilund
0ded44eeee BatchlogManager: make endpoint_filter method + implement 2015-08-11 17:10:16 +02:00
Calle Wilund
b7cdd189e7 BatchlogManager: make constructible from distributed<db> (to fit main init) 2015-08-11 09:46:59 +02:00
Calle Wilund
6ac6d644be Commitlog: add logging
Note: pretty lame logging, but modeled after origin.
Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2015-08-10 18:42:41 +03:00
Shlomi Livne
cd57f2e8c4 Enable num_tokens in config
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-08-10 18:04:40 +03:00
Pekka Enberg
3bac70cb59 db/schema_tables: Fix use-after-free in create_table_from_table_partition()
Fixes #119 and fixes #120.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-10 14:44:50 +03:00
Avi Kivity
a8ff8ea442 commitlog: switch to faster crc32 implementation 2015-08-09 00:05:36 +03:00
Glauber Costa
92031be642 index_interval: another field for schema_columnfamilies
There is another field I missed, index_interval. It is not actually used for
2.1.8 - so that's why it is easy to stop, but it at least exists.

2.1.8 already has "min_index_interval" and "max_index_interval". If we see a
table that contains index_interval, that will become "min_index_interval".

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 09:30:54 -05:00
Glauber Costa
0237a73e05 system_keyspace: make collections multi-cell
They are multi-cell in Origin. This has nothing to do with 2.2 vs 2.1,
and it is just a plain bug.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 09:30:54 -05:00
Glauber Costa
a7c1e16bc2 schema_tables: properly calculate index
We are currently assigning non-partition keys the index 0. That is not what
happens in Origin:

cqlsh> create table ks.twoclust \
        (ks int, cl1 int, cl2 int, r1 text, r2 text, primary key (ks, cl1, cl2));
cqlsh> select columnfamily_name, column_name, component_index \
        from system.schema_columns where keyspace_name='ks';

 columnfamily_name | column_name | component_index
-------------------+-------------+-----------------
          twoclust |         cl1 |               0
          twoclust |         cl2 |               1
          twoclust |          ks |            null
          twoclust |          r1 |               2
          twoclust |          r2 |               2

This is happening because we use column.position(), which has no knowledge of
the clustering keys at all.  We should instead pass that by the schema, which
will then do the right thing.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 09:30:54 -05:00
Glauber Costa
21ebaeffae schema_builder: provide a build function that doesn't take compact storage.
We will invoke the schema builder from schema_tables.cc, and at that point, the
information about compact storage no longer exists anywhere. If we just call it
like this, it will be the same as calling it with compact_storage::no, which
will trigger a (wrong) recomputation for compact_storage::yes CFs

The best way to solve that, is make the compact_storage parameter mandatory
every time we create a new table - instead of defaulting to no. This will
ensure that the correct dense and compound calculation are always done when
calling the builder with a parameter, and not done at all when we call it
without a parameter.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 09:30:54 -05:00
Glauber Costa
4bfd5b9f65 schema_tables: handle caching options
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 09:30:53 -05:00
Glauber Costa
c19819290a system.size_estimates: define schema
This table exists in 2.1.8, and although it is dropped in 2.2, we
should at least list its schema.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 08:31:56 -05:00
Glauber Costa
28c0498bb6 system.local: add more fields
2.1.8 tables have 3 more fields in their system tables, that 2.2 don't.
Since we aim at 2.1 compatibility, we have to include them.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 08:31:56 -05:00
Glauber Costa
e9ec0ad7f7 schema_columnfamilies: add columns present in 2.1.8 version
They do not exist in 2.2, and don't serve a huge purpose. But we will
need them for compatibility with 2.1

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 08:31:55 -05:00
Glauber Costa
9ee7b5d8f2 legacy schema tables: disable unused tables
Let's leave their schema in here, since it's ready and we may need them in the
future. But since they are not present in 2.1.8, we will remove them from the
schema list.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-08-07 08:31:55 -05:00
Pekka Enberg
dae1119796 database: Fix create keyspace ASan error
ASan does not like commit 05c23c7f73
("database: Add create_keyspace_on_all() helper"):

  ==8112==WARNING: AddressSanitizer failed to allocate 0x7f88b84fc690 bytes
  ==8112==AddressSanitizer's allocator is terminating the process instead of returning 0
  ==8112==If you don't like this behavior set allocator_may_return_null=1
  ==8112==Sanitizer CHECK failed: ../../../../libsanitizer/sanitizer_common/sanitizer_allocator.cc:147 ((0)) != (0) (0, 0)

I was not able to determine the source of the bug. Make ASan happy by
reverting the code movement and using the "cpu zero" trick we use for
table creation.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-06 13:02:58 +03:00
Pekka Enberg
464c96d901 db/schema_tables: Wire up CF creation CQL event
The code is merge_tables() is a twisted maze of tricks that is hard to
restructure so that event notification can be done cleanly like with
keyspaces.

The problem there is that we need to run bunch of database operations
for the merging that really need to happen on all the shards.  To fix
the issue, lets cheat a little and simply only run CQL event
notification on cpu zero.

This seems to fix cluster schema propagation issues in urchin-dtest. I
can now run TestSimpleCluster.simple_create_insert_select_test without
any additional delays inserted into the test code.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 17:33:59 +03:00
Pekka Enberg
45e5eff544 db/schema_tables: Remove ifdef'd code
We already have all_tables() function converted and there's really no
use for compile() unless we switch to using CQL to create the schema
tables.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 13:56:50 +03:00
Pekka Enberg
a355c83c6c db/schema_tables.hh: Remove obsolete comment
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 13:56:49 +03:00
Pekka Enberg
99a80050e3 db: Rename legacy_schema_tables to schema_tables
There's nothing legacy about it so rename legacy_schema_tables to
schema_tables. The naming comes from a Cassandra 3.x development branch
which is not relevant for us in the near future.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 13:56:47 +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
05c23c7f73 database: Add create_keyspace_on_all() helper
Add a create_keyspace_on_all() helper which is needed for sending just
one event notification per created keyspace, not one per shard.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-05 11:50:52 +03:00
Asias He
d6c31a2668 system_keyspace: Fix more execute_cql using inet_address
We should pass inet_address.addr().

With this, tokens in system.peers are updated correctly.

(1 rows)
cqlsh> SELECT tokens from system.peers;

 tokens
------------------------------------------------------------------------
 {'-5463187748725106974', '8051017138680641610', '8833112506891013468'}

(1 rows)
2015-08-05 15:58:55 +08:00
Asias He
1b7b199bdf system_keyspace: Fix remove_endpoint
I got this error If I pass inet_address to it.

boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_any_cast>
> (boost::bad_any_cast: failed conversion using boost::any_cast)
2015-08-05 15:29:32 +08:00
Pekka Enberg
0b762338c1 database: Futurize update_column_family()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-03 13:41:16 +03:00
Pekka Enberg
59c5be12ae db/legacy_schema_tables: Convert create_table_from_name()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-08-03 12:41:01 +03:00
Nadav Har'El
1d31a929b9 config: fix options with string_map type
Several of Scylla's options (in db/config.hh) have the type "string_map"
(unordered_map<sstring, sstring>). The intent was such options could get
multiple "key=value" settings. However, this never actually worked correctly,
and had two bugs:

 1. Any option name with a space in it would fail, for example:
       $ scylla --logger-log-level  'BatchLog Manager=info'
       error: the argument ('BatchLog Manager=info') for option '--level'
              is invalid

 2. Trying to set multiple entries in the map did *not* work. For example,
       $ scylla --logger-log-level  a=info --logger-log-level b=info
       error: option '--level' cannot be specified more than once

The problem is that boost::program_options does not actually understand
unordered_map<sstring, sstring>: It doesn't know it is a container (it
only recognizes std::vector) so it doesn't allow multiple options, and
it doesn't know how to convert a string to it, so it uses boost::lexical_cast
which for strings, cuts the string at a space...

The solution is to write a custom "validate()" function overload, which
boost::program_options uses to validate (and consume) options into object
types it doesn't understand by default. Getting this function in the right
place in the code was a difficult exercise, but here it is, a working
implementation :-) And it fixes the above two bugs.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-08-02 17:19:35 +03:00
Shlomi Livne
199f4d2545 Add enable-in-memory-data-store,enable-commitlog,enable-cache config
Abillity to enable/disable specific sub-modules - this settings do not
affect system tables which are allways persisted,cached and written to
commitlog

enable-in-memory-data-store marks if tables will be written/read to/from
disk
enable-commitllog marks if tables will be written to commitlog
enable-cache marks if tables will be written/read to/from cache

Please note in-memory-data-store does not change the read path so "old"
sstables are still read and cache may be used to cache their data

Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-08-02 17:19:30 +03:00
Paweł Dziepak
53be987a6d db: read default ttl from legacy schema tables
Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
2015-07-30 14:10:06 +02:00
Tomasz Grabiec
c68c37ae2f Revert "schema: support dropped columns"
This reverts commit 9887bc5f5f.

Breaks "CREATE TABLE" statement.
2015-07-30 10:56:01 +02:00