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

CodeFirst Shard DB Creation missing Sharding Schema/SPs #147

Open
ConX-Ryan opened this Issue Nov 14, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@ConX-Ryan

ConX-Ryan commented Nov 14, 2016

Exception thrown "Could not find stored procedure '__ShardManagement.spBulkOperationShardMappingsLocal'"

When ListShardMap.CreatePointMapping is called on the freshly created Shard DB.

I can confirm that the EF schemas have been created properly but all the sharding schemas and SPs are not present.

Seems to occur more often we dropping and recreating a shard with the same name using the same Shard Manager DB

client version 1.3.3
please let me know if you require more info.

@jaredmoo

This comment has been minimized.

Member

jaredmoo commented Nov 14, 2016

Before deleting a shard database, you should remove it from the shard map manager using ShardMap.DeleteShard. This is the safe way to delete because before allowing the shard to be deleted, the shard map manager will check that there are no mappings to the shard (and if there are no mappings to the shard, then hopefully that shard should be empty of sharded data - although that last part is your responsibility, shard map manager cannot verify that for you).

At this point since you already deleted the database, you can instead remove the shard db from the shard map manager using RecoveryManager.DetachShard. This is normally dangerous to do, since all mappings to that shard will deleted, which is why DeleteShard is preferred.

So then if you create a new database with the same name, you need to call ShardMap.CreateShard to create sharding schemas on that shard db and add that shard db to the shard map manager. However you didn't call this, so the sharding schema wasn't created. (Note that CreateShard will fail if you didn't call DeleteShard or DetachShard earlier.)

@ConX-Ryan

This comment has been minimized.

ConX-Ryan commented Nov 14, 2016

Thanks very much for your explanation!

@jaredmoo

This comment has been minimized.

Member

jaredmoo commented Nov 14, 2016

Cheers. Hope this fixes your problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment