Merge pull request #1591 from citusdata/fix-shard-cache-inval

Fix possible shard cache incoherency.
pull/1662/head
Marco Slot 2017-09-25 17:01:03 -07:00 committed by GitHub
commit 91d9b41822
1 changed files with 10 additions and 3 deletions

View File

@ -642,11 +642,18 @@ LookupShardCacheEntry(int64 shardId)
if (!shardEntry->tableEntry->isValid) if (!shardEntry->tableEntry->isValid)
{ {
Oid oldRelationId = shardEntry->tableEntry->relationId;
Oid currentRelationId = LookupShardRelation(shardId);
/* /*
* The cache entry might not be valid right now. Reload cache entry * The relation OID to which the shard belongs could have changed,
* and recheck (as the offset might have changed). * most notably when the extension is dropped and a shard ID is
* reused. Reload the cache entries for both old and new relation
* ID and then look up the shard entry again.
*/ */
LookupDistTableCacheEntry(shardEntry->tableEntry->relationId); LookupDistTableCacheEntry(oldRelationId);
LookupDistTableCacheEntry(currentRelationId);
recheck = true; recheck = true;
} }
} }