Search code examples
asp.netazure-elastic-scale

Azure Elastic Scale: MarkMappingOffline does not prevent shards from being searched


Just looking for some clearer understanding of what happens under the hood when RangeShardMappings are marked offline.

I understand mappings need to be set offline to update and delete shards and mappings.

I would like to keep mappings but prevent Azure Map Manager using particular mappings at any particular time, I was hoping that simply marking them as offline would allow me to do this, however it seems to have no impact to search results.

According to MS Docs (https://learn.microsoft.com/en-us/azure/sql-database/sql-database-elastic-scale-shard-map-management)

Certain operations on shard mappings are only allowed when a mapping is in an “offline” state, including UpdateMapping and DeleteMapping. When a mapping is offline, a data-dependent request based on a key included in that mapping will return an error. In addition, when a range is first taken offline, all connections to the affected shard are automatically killed in order to prevent inconsistent or incomplete results for queries directed against ranges being changed.

However this is not the behaviour I am experiencing. Offline maps are still returning result sets. Are these mappings stored in cache?


Solution

  • The main purpose of marking a mapping offline is to prevent connections using OpenConnectionForKey. The mapping is still visible, after all if the mapping was invisible then you would have no way to mark it back online later.

    Offline maps are still returning result sets.

    Ah, now I understand your question. Shard map manager has no knowledge or control over the underlying data in the database. This means that it's possible for the shard map to bIt's your responsibility to ensure that your query where clause contains a filter which matches the mapping that you requested. You can also use row-level security to ensure that your queries return only the correct result sets.