ric2b / mongo

The Mongo Database
http://www.mongodb.org/
0 stars 0 forks source link

Notes #1

Open ric2b opened 8 years ago

ric2b commented 8 years ago

Relevant files?

ric2b commented 8 years ago

Important files

ric2b commented 8 years ago

cluster_shard_collection_cmd -> shard_key_pattern -> keypattern

ric2b commented 8 years ago

shard_key_pattern.cpp -> add bool ShardKeyPattern::isGeoPattern() ?

ric2b commented 8 years ago

keypattern.cpp -> add static bool is GeoKeyPattern(const BSONObj& pattern)?

ric2b commented 8 years ago

Valid and non-valid index keys: \db\catalog\index_key_validate_test.cpp

ric2b commented 7 years ago

Files where enableSharding is mentioned but I don't know what they do: src/mongo/s/config.cpp src/mongo/s/config.h src/mongo/s/catalog/sharding_catalog_client.h src/mongo/s/catalog/sharding_catalog_client_impl.cpp src/mongo/s/catalog/sharding_catalog_client_impl.h

ric2b commented 7 years ago

s/grid.h

/**
 * Holds the global sharding context. Single instance exists for a running server. Exists on
 * both MongoD and MongoS.
 */

s/grid.h::catalogClient

/**
 * Returns a pointer to a ShardingCatalogClient to use for accessing catalog data stored on the
 * config servers.
*/

catalogClient::enableSharding

/**
 * Creates a new database or updates the sharding status for an existing one. Cannot be
 * used for the admin/config/local DBs, which should not be created or sharded manually
 * anyways.
 *
 * Returns Status::OK on success or any error code indicating the failure. These are some
 * of the known failures:
 *  - DatabaseDifferCase - database already exists, but with a different case
 *  - ShardNotFound - could not find a shard to place the DB on
 */
ric2b commented 7 years ago

s/commands/cluster_shard_collection.cpp

// The proposed shard key must be validated against the set of existing indexes.
// In particular, we must ensure the following constraints
//
// 1. All existing unique indexes, except those which start with the _id index,
//    must contain the proposed key as a prefix (uniqueness of the _id index is
//    ensured by the _id generation process or guaranteed by the user).
//
// 2. If the collection is not empty, there must exist at least one index that
//    is "useful" for the proposed key.  A "useful" index is defined as follows
//    Useful Index:
//         i. contains proposedKey as a prefix
//         ii. is not a sparse index, partial index, or index with a non-simple collation
//         iii. contains no null values
//         iv. is not multikey (maybe lift this restriction later)
//         v. if a hashed index, has default seed (lift this restriction later)
//
// 3. If the proposed shard key is specified as unique, there must exist a useful,
//    unique index exactly equal to the proposedKey (not just a prefix).
//
// After validating these constraint:
//
// 4. If there is no useful index, and the collection is non-empty, we
//    must fail.
//
// 5. If the collection is empty, and it's still possible to create an index
//    on the proposed key, we go ahead and do so.