Commit Graph

182 Commits

Author SHA1 Message Date
Glauber Costa
7fa8071dde fix creation of keyspaces
When we call merge_keyspaces, we end up calling db.add_keyspace, which means we
don't do parts of creation of a keyspace - like creating the directory. This works
in some situations where all the work was already done, but not in others.

We should be calling create_keyspace instead, which will take care of all that
for us. That will include creating a directory when one is needed.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-24 12:44:05 -04:00
Tomasz Grabiec
dc6bfb63da system_keyspace: Introduce query()
Simple method to get all data from a system table.

Note: Perhaps we should move storage_proxy::query_local() here as well.
2015-06-24 18:13:02 +03:00
Avi Kivity
3d22623a6b Merge "Flush schema changes to disk" from Glauber
"This is the current patchset to flush and persist schema changes to disk.
It is not perfect, in the sense that older changes still in flight won't be
waited for. But as we discussed - at this moment we'll just note that, and
leave the fix for later"
2015-06-24 17:08:33 +03:00
Gleb Natapov
7d846e842c use write_request_timeout_in_ms for write request timeout
Fixes another fixme. Also change default value to 2000 which seams to
be what origin uses.
2015-06-24 12:51:33 +03:00
Glauber Costa
d6b14c967f db: flush system tables to disk
We flush the mutation we receive, and this is not complete yet.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-23 15:23:37 -04:00
Glauber Costa
83d4a47a21 stop using get() / get0() arbitrarily
Being able to just get() a future inside a thread is a very nice functionality,
but we should be more careful a to when we do it. In particular, we are doing this
in a function inside db::legacy_schema_tables, because that function is supposed to
be used - so far - only inside a threaded function.

That approach simplify things, but at a great reusability cost. That means that this
function can now only be reused inside thread code.

This patch turns the offender into a normal future function, and moves the get0() to
code that is directly under seastar::async.

As a rule of thumb, we should stay away from ever doing get / get0 in functions that
are not used directly by async code.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-23 21:16:56 +03:00
Tomasz Grabiec
b9288d9fa7 db: Make column_family managed by lw_shared_ptr<>
It will be share-owned by readers.
2015-06-23 13:49:24 +02:00
Vlad Zolotarov
3520d4de10 locator: introduce a global distributed<snitch_ptr> i_endpoint_snitch::snitch_instance()
Snitch class semantics defined to be per-Node. To make it so we
introduce here a static member in an i_endpoint_snitch class that
has to contain the pointer to the relevant snitch class instance.

Since the snitch contents are not always pure const it has to be per
shard, therefore we'll make it a "distributed". All the I/O is going
to take place on a single shard and if there are changes - they are going
to be propagated to the rest of the shards.

The application is responsible to initialize this distributed<shnitch>
before it's used for the first time.

This patch effectively reverts most of the "locator: futurize
snitch creation" a2594015f9 patch - the part that modifies the
code that was creating the snitch instance. Since snitch is
created explicitly by the application and all the rest of the code
simply assumes that the above global is initialized we won't need
all those changes any more and the code will get back to be nice and simple
as it was before the patch above.

So, to summarize, this patch does the following:
   - Reverts the changes introduced by a2594015f9 related to the fact that
     every time a replication strategy was created there should have been created
     a snitch that would have been stored in this strategy object. More specifically,
     methods like keyspace::create_replication_strategy() do not return a future<>
     any more and this allows to simplify the code that calls it significantly.
   - Introduce the global distributed<snitch_ptr> object:
      - It belongs to the i_endpoint_snitch class.
      - There has been added a corresponding interface to access both global and
        shard-local instances.
      - locator::abstract_replication_strategy::create_replication_strategy() does
        not accept snitch_ptr&& - it'll get and pass the corresponding shard-local
        instance of the snitch to the replication strategy's constructor by itself.
      - Adjusted the existing snitch infrastructure to the new semantics:
         - Modified the create_snitch() to create and start all per-shard snitch
           instances and update the global variable.
         - Introduced a static i_endpoint_snitch::stop_snitch() function that properly
           stops the global distributed snitch.
         - Added the code to the gossiping_property_file_snitch that distributes the
           changed data to all per-shard snitch objects.
         - Made all existing snitches classes properly maintain their state in order
           to be able to shut down cleanly.
         - Patched both urchin and cql_query_test to initialize a snitch instance before
           all other services.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v6:
   - Rebased to the current master.
   - Extended a commit message a little - the summary.

New in v5:
   - database::create_keyspace(): added a missing _keyspaces.emplace()

New in v4:
   - Kept the database::create_keyspace() to return future<> by Glauber's request
     and added a description to this method that needs to be changed when Glauber
     adds his bits that require this interface.
2015-06-22 23:18:31 +03:00
Glauber Costa
a7d612f196 schema tables: add missing columns
We left some columns at a FIXME state, because we didn't have all types
implemented to reflect this. In particular, all collection types were left
behind.

Now that we do, let's refresh the system table's schemas.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-22 19:09:38 +03:00
Shlomi Livne
b3e4094e11 Updating setting of system keyspace strategy to be local_strategy
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-06-22 14:18:42 +03:00
Glauber Costa
e6090146e5 merge tables: properly generate column family config
We are currently generating an empty config, which is wrong and won't
propagate important characteristics of the keyspace.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-18 09:22:20 -04:00
Glauber Costa
a95a529865 database: allow for empty data file directories
A lot of our tests run in memory only, but now that our write path is complete,
we may start running into problems soon, as we write down the sstables.

It would be nice to force the database to run in-memory only in some situations.
Even in the real world, some scenarios may benefit from that in the future.

This patch forces durable_writes to be always false in case we force the data
directory to be an empty list.

For system tables, the patch also fixes a bug. Because system tables were
forceably initialized with durable_writes = false, we would never write them to
disk, even when we were supposed to.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-06-18 09:22:20 -04:00
Avi Kivity
8ec6826dca Merge "Enable snitch via config" from Shlomi 2015-06-18 13:46:09 +03:00
Gleb Natapov
a338407e29 make storage_proxy object distributed
storage_proxy holds per cpu state now to track clustering, so it has to
be distributed otherwise smp setup does not work.
2015-06-17 15:14:06 +02:00
Pekka Enberg
38187f2e72 db/legacy_schema_tables: Instantiate columns from system tables
Read the system tables and instantiate table columns to in-memory data
structures.

NOTE! We only support one component per partition and clustering key
because there is no way to pass component index to the schema builder.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 12:25:18 +03:00
Pekka Enberg
0fb6d6f2cb db/marshal: Convert TypeParser to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 12:25:18 +03:00
Pekka Enberg
506a8f4598 db/marshal: Import TypeParser.java
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 12:25:18 +03:00
Pekka Enberg
1c45cdcb3b db/legacy_schema_tables: Store column component index
Make sure add_column_to_schema_mutation() also sets "column_index" for a
column that is stored to system tables.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 11:18:53 +02:00
Glauber Costa
72cc16299c system keyspaces: use existing constant instead of hardcoding keyspace name
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 09:41:57 +03:00
Glauber Costa
e1ba4d8fe1 system_keyspace: don't read from bogus ks
The current code moves ks inside the database, then reads from it.
That's wrong. Make it right.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-17 09:41:50 +03:00
Pekka Enberg
2d9397de58 db/legacy_schema_tables: Store columns to system tables
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-16 12:20:20 +02:00
Pekka Enberg
2776b5e657 db/legacy_schema_tables: Add missing attributes in add_table_to_schema_mutation()
Add attributes that we didn't support when the code was first
translated. Please note that we still don't cover all of the so somebody
needs to revisit this later.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-16 12:20:20 +02:00
Shlomi Livne
84da02d67f Enable endpoint_snitch
Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-06-15 15:32:13 +03:00
Avi Kivity
743b6efd54 Merge "initial mutation clustering" from Gleb 2015-06-15 13:25:01 +03:00
Gleb Natapov
969134280a initial mutation clustering code 2015-06-15 12:53:10 +03:00
Gleb Natapov
7cee40bff2 add frozen_mutation serializer 2015-06-15 12:51:09 +03:00
Gleb Natapov
2d409250f2 remove ad-hoc token_metadata creation 2015-06-15 12:51:09 +03:00
Pekka Enberg
e12cbb1836 db/legacy_schema_tables: Use async() for merge_schema()
Convert the merge_schema() function to use async() to make the code
easier to read and write.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-15 12:50:07 +03:00
Tomasz Grabiec
c53ed98731 Merge branch 'shlomi/enable_cluster_via_config' from seatar-dev.git 2015-06-15 09:22:41 +02:00
Vlad Zolotarov
e045d8465c db: use snitch name from the configuration file
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-14 15:31:58 +03:00
Shlomi Livne
2c6ba8971f Different seperator for map elements
Origin's --seed-provider-parameters format is seeds=<ip1>,<ip2>,<ip3> to
align with yaml configuration file format and command line options a
different seperator must be used instead of "," - switched to using ";"

Signed-off-by: Shlomi Livne <shlomi@cloudius-systems.com>
2015-06-14 11:32:57 +03:00
Pekka Enberg
5b4c073170 db/legacy_schema_tables: Store keyspace strategy options
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-11 13:02:42 +03:00
Pekka Enberg
d088cb8181 Fix keyspace strategy options to preserve key-value ordering
Fix keyspace strategy options to preserve key-value ordering by
switching to std::map. We need this to be able to store the map in
database as JSON because unordered maps can cause the schema merging
code to attempt a keyspace update, which we don't support, even though
the values did not change.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-11 13:02:42 +03:00
Vlad Zolotarov
a2594015f9 locator: futurize snitch creation
- Forbid explicit snitch creation with constructor.
   - Allow the creation of snitches only with locator::make_snitch() template
     function.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v4:
   - Make sure the snitch is stopped before it's destroyed when _snitch_is_ready
     is returned in an exceptional state.

New in v2:
   - Change snitch_ptr to be std::unique_ptr<i_endpoint_snitch>
   - abstract_replication_strategy::create_replication_strategy(): explicitly
     specify (template) types of create_object() parameters.
   - Re-arrange the loop in marge_keyspaces() so that lambdas that depend on
     "this" complete before there is a chance that "this" gets destroyed.
   - create_keyspace(): Don't add a new keyspace if a keyspace with this name
     already exists.
   - i_endpoint_snitch: added a stop() virtual method
      - Added a stop() pure virtual method.
      - Added an enum class snitch_state and a _state member initialized to snitch_state::initializing,
        added an assert() in a destructor requiring _state to become snitch_state::stopped,
        which should be set when stop() is complete.
   - rack_inferring_snitch: added a stop() method.
   - simple_snitch: added a stop() method.
   - Added stop() methods to abstract_replication_strategy and keyspace.
   - Updated database::stop() to wait for all keyspaces in _keyspaces to stop.
2015-06-09 15:33:38 +03:00
Vlad Zolotarov
73278798a9 added missing methods (stubs) required for snitch implementation
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>

New in v2:
   - storage_service: add a non-const version of get_token_metadata().
   - get_broadcast_address(): check if net::get_messaging_service().local_is_initialized()
     before calling net::get_local_messaging_service().listen_address().
   - get_broadcast_address(): return an inet_address by value.
   - system_keyspace: introduce db::system_keyspace::endpoint_dc_rack
   - fb_utilities: use listen_address as broadcast_address for now
2015-06-09 15:33:29 +03:00
Shlomi Livne
bd89fa4905 config: add string_list (vec of sstring) as config data type + use for datadir
To handle the fact that --data-file-directories is supposed to be 1+
folders.

Note that boost::program_ops already "reserves" the use of std::vector
as reciever of values for multitoken options (i.e. those with more than
one value). Thus, values recieving a list of tokens via command line
should adhere to the multi-token rules, i.e. space separated values.

End result is that --data-file-directories now accept multiple paths,
white space separated,
i.e. --data-file-directories <path1> <path2>
And as it turns out, this is really a nicer way of writing stuff than
using "," or ":" seperation of paths etc, so...

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2015-06-09 10:40:45 +03:00
Pekka Enberg
d25bd89ee1 db/legacy_schema_tables: Convert table merging to C++
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-08 14:59:06 +03:00
Avi Kivity
e343295667 commitlog: don't pass a temporary string to std::regex_match
The match results will point nowhere, and libstdc++ 5 rightly rejects it.
2015-06-08 09:23:18 +03:00
Pekka Enberg
1cac0c7b31 db/legacy_schema_tables: Fix read_schema_for_keyspaces()
Fix the check in read_schema_for_keyspaces() to not insert empty
result sets in the return value. There's no functional change as the
merge algorithms already deal with the case. However, the code is now
closer to what origin does.

Spotted while reading the code.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-05 12:58:46 +03:00
Pekka Enberg
fcd6f147fc db/legacy_schema_tables.cc: Use schema_result::value_type instead of std::pair
Switch to schema_result::value_type instead of the open-coded std::pair
so that the actual types are defined in one place.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-03 19:14:39 +02:00
Pekka Enberg
2eeabfcebc db/legacy_schema_tables: Fix merge_keyspaces()
Keys that are in "entries_only_on_right" need to be looked up from
"after". Fixes a regression introduced in commit 5418e32
("map_difference: Simplify difference value").

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-03 13:43:48 +02:00
Calle Wilund
2c603cc4bd SecondaryIndex Java -> c++
Initial translation
2015-06-03 10:13:52 +02:00
Calle Wilund
7a03c9275e Index: Import java files 2015-06-03 10:13:52 +02:00
Pekka Enberg
5418e32fc7 map_difference: Simplify difference value
Simplify the return value of map_difference() to return set of keys.
This makes it possible to use the function with value types such as
foreign_ptr<> that are non-copyable.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-03 09:19:00 +03:00
Pekka Enberg
2a68aefca9 db/legacy_schema_tables: Use sstring as schema results key
There's no need to use decorated_key as schema results map key because
we just convert it back to a keyspace name string. It does, however,
cause problems when trying to pass the results around to different CPUs
so just switch to the sstring type.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-06-02 12:24:11 +03:00
Calle Wilund
0729580f84 Separate replay_position into its own header
Less include bloat...

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
2015-06-01 14:17:43 +03:00
Gleb Natapov
fc176415f1 remove leftovers from db/serializer.hh 2015-06-01 09:31:58 +02:00
Asias He
3b4c233f55 system_keyspace: Add get_local_host_id and set_local_host_id 2015-06-01 11:24:39 +08:00
Pekka Enberg
257511d271 db/legacy_schema_tables: make_create_table_mutations()
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-27 16:22:13 +03:00
Pekka Enberg
a388b088c6 map_difference: Parametrize value comparison
If map value type is lw_shared_ptr<T>, for example, we need to be able
to pass our own value comparison function to the difference() function.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-27 16:22:13 +03:00