Commit Graph

53 Commits

Author SHA1 Message Date
Glauber Costa
9c464aff9b database: clean up various APIs
In much of our column_families APIs, we need to pass a pointer to the database.
The only reason we do that, is so we can properly handle the commit log entries
after we seal the current memtables into sstables.

Now that we store a pointer to the commit log in the CF itself at the time it
is created, we no longer have to do it. As a result, the APIs are a lot
cleaner, with no gratuitous parameters.

My motivation for this was the flush method, but as a result, apply() also gets
cleaner.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-15 10:24:20 -04:00
Avi Kivity
4b1fd3d48d Merge "Set currently commented out properties for system tables" from Glauber
"Some of the system tables will set gc_grace_seconds, or default_time_to_live
but right now we are commenting them out.

The best way to do it would have been to somehow save the fields so we don't need to
set it all the time - as this function is effectively doing.

However, those fields would feel very spurious in the constructor, and it is not
like there isn't a lot of other things for us to set. More importantly, calling
those schema functions is a very rare event. We usually call it once and store
the pointer somewhere.

With that, we're very close to implementing everything that the system tables
needs set, missing only COMPACT STORAGE and information about compaction
strategy."
2015-07-14 10:52:22 +03:00
Glauber Costa
5ac6ed72f4 system tables: set default ttl according to Origin settings
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-13 23:58:03 -04:00
Glauber Costa
7b1b8f0e09 system tables: set gc grace period according to Origin settings
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-13 23:58:03 -04:00
Tomasz Grabiec
d4ec9d9566 system_keyspace: Remove the out-of-date comment from query()
The function is currently just a simple wrapper over
storage_proxy::query(). The comment has description of details which
are much lower level than this interface.
2015-07-13 10:27:02 +02:00
Tomasz Grabiec
9aed3fdbfc system_keyspace: Simplify query() by using partition_slice_builder 2015-07-13 10:27:02 +02:00
Tomasz Grabiec
bc0874d299 db: Move storage_proxy::query_local() to db::system_keyspace::query() 2015-07-13 10:27:02 +02:00
Tomasz Grabiec
ad99e84505 storage_proxy: Take schema_ptr in query()
It will be needed for reconciliation.
2015-07-12 12:54:38 +02:00
Glauber Costa
c73d4cba16 system_keyspaces: update hints dropped
Again, not terribly complicated.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:09:00 +02:00
Glauber Costa
0bf09f6af8 system_keyspace: implement update_preferred_ip
This one is quite simple, we just need very basic translation

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:09:00 +02:00
Glauber Costa
fe154efffe system_keyspace: implement (remote) update_tokens
There are two versions of update_tokens: one for the tokens used by this node,
which goes to the local table, and another for the remote tokens, used by
remote nodes, which goes to the peers table.

The former was implemented, the latter was not. Implement it.

One node: Origin does not issue a flush here, at least in the version of the
code we imported. However, a flush is present in all other variants, and won't
hurt, aside from creating an extra, probably very small, sstable. So I'm
flushing.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:09:00 +02:00
Glauber Costa
31f4601329 system_keyspace: remove duplication for blocking flush
We ended up with two different implementations of force_blocking_flush,
none of them ideal.

This patch merges both in one that makes more sense, getting rid of the
duplication.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-10 10:09:00 +02:00
Glauber Costa
afee9ab72a system_keyspaces: implement remove_endpoint
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-09 11:58:31 -04:00
Glauber Costa
e559959632 system_keyspace: implement update_peer_info
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-09 11:58:31 -04:00
Glauber Costa
38465dea70 system_keyspaces: implement load_dc_rack_info
To implement that, we will resort to a cache mechanism, instead of doing the
query all the time.  This is mainly because we want to avoid overfuturization
of the callers, that are usually just interested in passing simple strings
around.

We will be able to intercept all updates to it, and maintain consistency with our
internal cache. The updates are not done in this patchset.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-09 11:58:30 -04:00
Glauber Costa
bac0a8a680 legacy_schema_tables: convert save_system_keyspace_schema()
This function is called at bootstrap, to make sure the system tables exist in
the keyspace list. I honestly don't know why do we have to force a delete +
reconstruct. But let's keep consistency with Origin here.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-09 08:12:47 -04:00
Glauber Costa
cb103449a5 db: move query_context to a header
Do this so we can use it from legacy_schema_tables as well

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-09 00:12:08 -04:00
Avi Kivity
a2e270f3d4 Merge "wire update tokens" from Glauber
"As previously said, there were some unidentified bugs that prevented update_tokens from
working properly. The first one was sent alongside the series, the second one took me more
time, but it is fixed here."
2015-07-08 16:01:37 +03:00
Calle Wilund
4ba0bf7ac6 system_keyspace : add support for storing and reading truncation
* Straight re-impl of origin code
* Uses system tables not yet created, so does not actuall work...
2015-07-08 10:59:57 +02:00
Glauber Costa
12dc7ebd26 system.local: convert update tokens
At this point, users of the interface are futurized already, so we
just need to make sure they call the right function.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 20:24:43 -04:00
Glauber Costa
137cf22abf system.local: convert host_id functions
They are already futurized, we just have to implement them.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:23 -04:00
Glauber Costa
a9e69a34cb system.local: convert bootstrap state
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:23 -04:00
Glauber Costa
6d58675092 system.local: force blocking flush
Allows a CF to be flushed, and wait for it to finish.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:23 -04:00
Glauber Costa
072de63427 system.local: convert check_health
This function is called at startup and makes sure that the cluster_name field
in system.local exists, and if it exists, that it matches the expected value.

To simplifly things, I am leaving the sstable check out. For us, that would be
a map-reduce operation, and if the sstables are indeed corrupted, we would have
caught that already for sure.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:23 -04:00
Glauber Costa
30008bc0b1 system.local: schema version
This patch provide a function to store the current schema version.
Currently, it is called every time the node boots, with a random schema.
That is incorrect and will be fixed shortly. But for now, cqlsh needs
to see a valid value here, so this will do.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:23 -04:00
Glauber Costa
e5d27d6485 system.local: setup version fields
Done every time the node boots, unconditionally.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:23 -04:00
Glauber Costa
0f68010152 futurize get_local_host_id and set_local_host_id
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:23 -04:00
Glauber Costa
157f5991ac system keyspace: setup queries
We won't create our own versions of database and query_proxy, so we need
some setup to be done. The current code will capture those variables and
setup the structure used to conduct the queries. Later on, it will also
carry on the database's basic setup.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2015-07-07 11:38:22 -04:00
Tomasz Grabiec
a1f6dec067 result_set: Introduce from_raw_result() factory method 2015-07-02 13:25:46 +02:00
Tomasz Grabiec
c9e5508e3c result_set_builder: Make build() return unwrapped object
It's better to let the user decide which kind (if any) of smart
pointer to wrap it into.
2015-07-02 13:25:46 +02:00
Vlad Zolotarov
e47e0dcde9 locator: moved endpoint_dc_rack from db::system_keyspace to locator namespace
This is meant to resolve to dependecy loop between token_metadata.hh
and system_keyspace.hh.

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
2015-06-29 14:35:47 +03: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
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
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
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
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
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
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
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
4dc488afb2 database: Store metadata in 'struct keyspace'
Store a lw_shared_ptr<keyspace_metadata> in struct keyspace so callers
in migration manager, for example, can look it up.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-25 09:12:29 +02:00
Pekka Enberg
cd35617855 database: Use keyspace_metadata for creation functions
Use the keyspace_metadata type for keyspace creation functions. This is
needed to be able to have a mapping from keyspace name to keyspace
metadata for various call-sites.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
2015-05-19 15:27:47 +03:00
Avi Kivity
dda5cbfd0d db: make column_family and keyspace configurable
Currently used for the data directory.
2015-05-18 15:00:31 +03:00
Tomasz Grabiec
06f198b10c schema: Add id field
It uniquely identifies column_family globally. Will be used for
column_family lookups.
2015-04-15 20:33:48 +02:00
Tomasz Grabiec
a11aa768dc db: Remove outdated comment 2015-04-15 20:33:48 +02:00
Calle Wilund
d3fe0c5182 Refactor db/keyspace/column_family toplogy
* database now holds all keyspace + column family object
* column families are mapped by uuid, either generated or explicit
* lookup by name tuples or uuid
* finder functions now return refs + throws on missing obj
2015-04-01 10:08:00 +02:00
Avi Kivity
18e7ea58d4 db: add collection-typed fields to system keyspace 2015-03-30 14:28:16 +03:00
Tomasz Grabiec
e6ad9df1c9 db: Add db::system_keyspace::make() for creating the system keyspace 2015-03-11 16:01:13 +01:00
Nadav Har'El
e7a59652b5 Add comments to schemas in system_keyspace
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
2015-03-02 15:18:41 +01:00