Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPE-2695] + [partial DPE-2700] POC Identify primary shard + Prevent removal of Primary shards #267

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

MiaAltieri
Copy link
Contributor

@MiaAltieri MiaAltieri commented Oct 12, 2023

Issue

Primary shards are not identified, this can pose problems if removing a primary shard

Solution

Identify primary shards and prevent their removal

Follow up PR

move databases that use a primary shard to a different shard if removing primary (I don't want to add this to this PR as to reduce the complexity in the review)

Testing

As this is a POC there are no integration tests added, instead tests were performed by hand

# deploy shards + config server
juju deploy ./*charm --config role="config-server" config-server-one 
juju deploy ./*charm --config role="shard" shard-one 
juju deploy ./*charm --config role="shard" shard-two 

# relate shards
juju integrate config-server-one:config-server shard-one:sharding
juju integrate config-server-one:config-server shard-two:sharding

# write data to shard-one
juju ssh config-server-one/0
charmed-mongodb.mongosh <URI>
use test_db
db.createCollection("cool_animals")
db.cool_animals.insertOne({"horses":"unicorn"})
sh.enableSharding("test_db")

# write data to shard-two
use test_db_2
db.createCollection("cool_animals")
db.cool_animals.insertOne({"horses":"unicorn"})
sh.enableSharding("test_db")
db.adminCommand( { movePrimary : "test_db_2", to : "shard-one" } )

# show both shards
use config 
show collections 
db.databases.find()

# exit
exit
exit

# remove shard and verify error in config server and forever wait in shard 
juju remove-relation config-server-one:config-server shard-two:sharding
juju status --watch 1s

delgod
delgod previously approved these changes Oct 12, 2023
@MiaAltieri MiaAltieri merged commit cef5746 into 6/edge Oct 13, 2023
@MiaAltieri MiaAltieri deleted the identify-primary-shard branch October 13, 2023 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants