Commit Graph

306 Commits

Author SHA1 Message Date
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
Glauber Costa
9887bc5f5f schema: support dropped columns
Because we don't support alter table, we won't have anyone actually manipulating this.
But we will set up so it appears properly as an empty map in queries.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-29 18:44:59 -04:00
Glauber Costa
f49eb92880 schema: speculative retry
When added to the schema and handled by legacy_schema_tables.cc, will then
appear correctly in the respective system tables.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-29 18:44:59 -04:00
Glauber Costa
01e5fcad5e schema: memtable flush period
currently set to 0, which is Origin's default

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-29 18:44:59 -04:00
Avi Kivity
dce642f472 commitlog: fix use-after-free of file during close
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-29 20:36:03 +03:00
Nadav Har'El
280c450892 Fix compilation
The at_exit() callback needs to return a future. In one place we forgot,
and now that at_exit() takes an std::function<>, this is verified at
compilation time and fails compilation.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-28 10:28:08 +02:00
Pekka Enberg
0b8c67ed79 exceptions: Move unavailable_exception to exceptions.hh
Move unavailable_exception to exceptions.hh where other CQL transport
level exceptions are defined in.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 10:06:18 +03:00
Pekka Enberg
055e25ed43 db/consistency_level: Move enum to separate header
Move 'consistency_level' enumeration to a separate header file to fix
dependency issues that arise when we move 'unavailable_exception' to
exceptions.hh.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 10:06:18 +03:00
Pekka Enberg
7fc1311d4a db/consistency_level: Move implementation to .cc file
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 10:06:18 +03:00
Pekka Enberg
32378708d0 db/consistency_level: Remove ifdef'd code
Cleanup consistency_level.hh by removing untranslated code that's been
sitting in the tree for a while.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 09:36:36 +03:00
Pekka Enberg
826f21643f transport/server: Fix UNAVAILABLE error encoding
This fixes UNAVAILABLE error encoding to follow the CQL binary protocol
spec.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-28 09:27:52 +03:00
Avi Kivity
73dfa66b8a remove "reversed_type.hh"
Not used (and fix one accidental use).
2015-07-25 17:34:56 +03:00
Glauber Costa
7669563900 type_parser: support reversed types
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-24 22:55:08 -04:00
Avi Kivity
bb3aef7fd9 Merge "Basic schema handling of compact strategy" from Glauber
"With this patchset, cqlsh's describe table command now work"
2015-07-23 16:47:29 +03:00
Avi Kivity
be32746c58 Merge "Handle Compact Storage" from Glauber
"This is my current proposal for Compact Storage tables - plus
the needed infrastructure.

Getting rid of the CellName abstraction allows us to simplify
things by quite a lot: now all we need is to mark whether or
not a table is composite, and provide functions to play the
role of the comparator when dealing with the strings."
2015-07-23 16:20:31 +03:00
Tomasz Grabiec
3fd682de4b db/legacy_schema_tables: Fix dead lock in create table statement
merge_schema() was recursively calling itself, causing it to block
iself on a non-recursive lock.
2015-07-23 12:37:42 +02:00
Gleb Natapov
f122ee39b9 storage_proxy: return proper error codes to transport layer
Transport layer expects to get error code in an exception of type
exceptions::cassandra_exception. Fix code to use it as a base for
all user visible exceptions and put correct error code there.
2015-07-23 12:32:21 +03:00
Pekka Enberg
78ee9e7478 db/system_keyspace: Fix "peers" table "schema_version" column type
The column type of "schema_version" is set to UTF8 which results in the
following value conversion errors:

  storage_service: fail to update schema_version for 127.0.0.2: 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)

Change the column type to UUID like in Origin. Fixes #35.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-23 09:37:32 +03:00
Glauber Costa
f778e2aea2 system keyspace: set compaction strategy options for system.hints
This is the last system table that needed parameters. All them are
now devoid of fixmes

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-23 00:02:11 -04:00
Glauber Costa
2c3463cf1f schema: handle compaction strategy options
We will store the options in the schema, but it is not yet used by
the compaction code.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-23 00:02:11 -04:00
Glauber Costa
d1496944d9 sstables: handle compaction strategy
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-23 00:02:11 -04:00
Glauber Costa
5c33549be5 system tables: mark some system tables as compact storage
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:10:22 -04:00
Glauber Costa
09631cbf5a schema: fix comparator field
We were currently using the regular column name as the comparator. That is
only correct in some specific cases, in particular, of a non-compound cell name,
that has no collections.

Now that we have the cell_name.hh infrastructure, we can use it.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:10:21 -04:00
Glauber Costa
d5b4731e49 schema: make all schemas be generated by the schema_builder
Some of the fields in the schema will not not be passed directly, but
calculated by the schema_builder. This is because they are not simple values of
the form a = x, but slightly more complex and have to be derived from other
properties (for instance, the amount of clustering keys).

For those values, a default value does not really make sense. Take for instance
the case of the comparator: there is always a comparator, and there is not any
comparator that can serve as a default. Which comparator to use depend on
whether or not the table has collections, whether or not it has clustering
keys, and whether or not it is marked as compact storage.

Making all tables go through the builder is a guarantee that all of them
will have their values set.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:10:21 -04:00
Glauber Costa
ddf6a2d8d5 schema: add a new column_kind
Origin has another column_kind, that we lack: compact_value. This kind is
used to identify regular columns of dense tables.

Take for instance, the following table:

CREATE TABLE ks2.compact (
    ks text,
    cl1 text,
    cl2 text,
    PRIMARY KEY (ks, cl1)
) WITH COMPACT STORAGE

cqlsh> select keyspace_name, columnfamily_name, column_name, type from system.schema_columns \
       where keyspace_name='ks2' and columnfamily_name='compact';

 keyspace_name | columnfamily_name | column_name | type
---------------+-------------------+-------------+----------------
           ks2 |           compact |         cl1 | clustering_key
           ks2 |           compact |         cl2 |  compact_value
           ks2 |           compact |          ks |  partition_key

We will treat those columns as regular columns for most purposes. Because of
that, we don't need to separate them from the regular columns when we sort
initially, for instance. All we have to do is change its type.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:10:21 -04:00
Glauber Costa
66a10c3b38 schema: add empty column for dense tables that do not have a regular column
This is how it happens for Origin. Take for instance the following CF:

CREATE TABLE ks2.noregular_cs2 (
    ks text,
    cl1 text,
    cl2 text,
    PRIMARY KEY (ks, cl1, cl2)
) WITH COMPACT STORAGE;

cqlsh> select keyspace_name, columnfamily_name, column_name from system.schema_columns \
       where keyspace_name='ks2' and columnfamily_name='noregular_cs2';

 keyspace_name | columnfamily_name | column_name
---------------+-------------------+-------------
           ks2 |     noregular_cs2 |                <===== added this.
           ks2 |     noregular_cs2 |         cl1
           ks2 |     noregular_cs2 |         cl2
           ks2 |     noregular_cs2 |          ks

In order to achieve that, we need to relax the test in db/legacy_schema_tables.cc.
It will throw in case it finds an empty name.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-22 23:10:21 -04:00
Tomasz Grabiec
e416e800c8 commitlog: Fix use-after-move
"f" was passed to make_file_input_stream() after it was moved-from.
2015-07-22 19:21:57 +03:00
Pekka Enberg
ea668b5d41 db/legacy_schema_tables: Merge schema locking
Add locking to merge_schema() to ensure only one CPU is able to fiddle
with internals at a time.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-22 18:03:17 +03:00
Gleb Natapov
98fae1a010 storage_proxy: handle read timeout 2015-07-22 13:44:46 +03:00
Avi Kivity
a547b881a7 Merge "Schema pull" from Pekka
"This series enables the schema pull functionality. It's used to
synchronize schema at node startup for schema changes that happened in
the cluster while the node was down.

Node 1:

  # Node 2 is not running.

  [penberg@nero apache-cassandra-2.1.7]$ ./bin/cqlsh --no-color 127.0.0.1
  Connected to Test Cluster at 127.0.0.1:9042.
  [cqlsh 5.0.1 | Cassandra 2.2.0 | CQL spec 3.2.0 | Native protocol v3]
  Use HELP for help.
  cqlsh> CREATE KEYSPACE keyspace3 WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
  cqlsh> SELECT * FROM system.schema_keyspaces;

   keyspace_name | durable_writes | strategy_class                             | strategy_options
  ---------------+----------------+--------------------------------------------+----------------------------
       keyspace3 |           True |                             SimpleStrategy | {"replication_factor":"1"}
          system |           True | org.apache.cassandra.locator.LocalStrategy |                         {}

  (2 rows)
  cqlsh> SELECT key, schema_version FROM system.local;

   key   | schema_version
  -------+--------------------------------------
   local | c3a18ddc-80c5-3a25-b82d-57178a318771

  (1 rows)

Node 2:

  # Node 2 is started.

  [penberg@nero apache-cassandra-2.1.7]$ ./bin/cqlsh --no-color 127.0.0.2
  Connected to Test Cluster at 127.0.0.2:9042.
  [cqlsh 5.0.1 | Cassandra 2.2.0 | CQL spec 3.2.0 | Native protocol v3]
  Use HELP for help.
  cqlsh> SELECT * FROM system.schema_keyspaces;

   keyspace_name | durable_writes | strategy_class                             | strategy_options
  ---------------+----------------+--------------------------------------------+----------------------------
       keyspace3 |           True |                             SimpleStrategy | {"replication_factor":"1"}
          system |           True | org.apache.cassandra.locator.LocalStrategy |                         {}

  (2 rows)
  cqlsh> SELECT key, schema_version FROM system.local;

   key   | schema_version
  -------+--------------------------------------
   local | c3a18ddc-80c5-3a25-b82d-57178a318771

  (1 rows)"
2015-07-22 13:32:47 +03:00
Pekka Enberg
791031fbc7 database: Extract update_schema_version_and_announce() function
It's needed in storage proxy.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-22 11:57:00 +03:00
Nadav Har'El
4edf7fe206 clean up uses of lw_shared_ptr<file>
recently, "file" started to use a shared_ptr internally, and is already
copy-able and reference counted, and there is no reason to use
lw_shared_ptr<file>. This patch cleans up a few remaining places where
lw_shared_ptr<file> was used.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-07-22 11:51:40 +03:00
Pekka Enberg
757522c597 db/legacy_schema_tables: Convert convertSchemaToMutations() to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-07-22 11:24:37 +03:00
Glauber Costa
0ea8a27b47 system_keyspace: stop the local cache.
Apparently we need to register the stop function explicitly. That was not being
visible before, because the urchin binary was failing on exit before this for
some other reason. Once that was fixed, this one became apparent.

Scylla can correctly shutdown now.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-21 17:21:53 +03:00
Asias He
268f2fa8a1 db/system_keyspace: Change host_id to uuid_type 2015-07-21 17:00:15 +08:00
Asias He
fa2aee57ac utils: Move util/serialization.hh to utils/serialization.hh
Now we will not have the ugly utils and util directories, only utils.
2015-07-21 16:12:54 +08:00
Avi Kivity
fee1f68b61 Add changes missing from previous commit 2015-07-20 17:28:45 +03:00
Avi Kivity
4a95f1589c Merge seastar upstream
Adjust make_file_*_stream() callers for updated seastar API.
2015-07-20 17:02:46 +03:00
Glauber Costa
443178ef81 schema: remove set_default_time_to_live
Make calls go through the builder. Current caller is patched.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 20:40:40 -04:00
Glauber Costa
8b68fb5ff6 schema: remove set_gc_grace_period
Make all callers go through the builder. Current callers - there are many
in the system tables code, are patched.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 20:40:40 -04:00
Glauber Costa
c71dace86c type_parser: reword exception message
The current message makes exactly at least no sense.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-17 10:23:11 +02:00
Glauber Costa
e5dbbc61a2 type_parser: parse tuples
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-16 09:47:00 -04:00
Glauber Costa
8b94cc8654 type_parser: don't duplicate parsing code.
According to the comments, we are doing this for simplicity, to avoid
creating a new type_parse object.

However, while this approach works well for the simple case where we expect
a single token, it won't work as the parser becomes more able to recognize
other cases.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-16 09:47:00 -04:00
Glauber Costa
9b96a2441a type parser: detect frozen types
Note that the multicell attribute can't be part of the parse instance, because
otherwise we would either freeze every subsequent element, or complicate the
flow considerably to handle it.

It is instead, passed as a parameter to get_instance_types(), which will then
have to be propagated to parse() and get_abstract_type()

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-16 09:47:00 -04:00
Glauber Costa
31e22034f2 type_parser: fix a bug with recursive parsing
We currently have a bug when parsing collection types that contains collections
themselves.

We call the recursion correctly, but get_abstract_type gets its value by copy, not
reference. Therefore, all work it does in the _idx manipulation is done in the copy,
and when the callee returns, the caller, with its _idx unchanged, will try recursing
again.

Fix it by passing by reference

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-16 09:47:00 -04:00