Skip to content

Commit

Permalink
Merge #41089 #41130
Browse files Browse the repository at this point in the history
41089: zone: Fix zone configuration application bug r=andreimatei a=rohany

There was a bug that allowed zone configuration application on indexes
to leak into the zone configurations for partitions, due to a subtlety in
ZoneConfig.GetSubzone. This PR fixes the bug with zone configuration
application and adds a test.

This PR is necessary for #40493 to land.

An example of this is as follows:

```
CREATE TABLE infect (x INT PRIMARY KEY);
ALTER TABLE infect PARTITION BY LIST (x) ( PARTITION p1 VALUES IN (1));
ALTER INDEX infect@primary CONFIGURE ZONE USING num_replicas=5;
ALTER PARTITION p1 OF TABLE infect CONFIGURE ZONE USING
constraints='[+dc=dc1]';
```
Before, the zone configuration for p1 would *also have* num_replicas=5
set, which should not be the case. This PR ensures that the zone
configuration for p1 only has constraints set.

Release Justification: Important bug fix.

Release note (bug fix): Fixing bug where zone configuration application
on indexes could leak into configurations on partitions.

41130: roachtest: update hibernate blacklist after new syntax support r=jordanlewis a=rafiss

Some tests that used to fail pass now since we support SELECT FOR UPDATE
syntax.

relates to #40538 

Release justification: test only change

Release note: None

Co-authored-by: Rohan Yadav <rohany@cockroachlabs.com>
Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
  • Loading branch information
3 people committed Sep 26, 2019
3 parents 6939978 + c5aba04 + 084919a commit 12c640b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
15 changes: 15 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/zone
Original file line number Diff line number Diff line change
Expand Up @@ -762,3 +762,18 @@ ALTER RANGE default CONFIGURE ZONE USING num_replicas = 3

statement ok
ALTER TABLE system.jobs CONFIGURE ZONE USING num_replicas = 3

# Test that index configurations don't infect partition configurations.
# Specifically we are testing that values written to infect@primary's
# zone configuration does not appear in partition p1 of infect@primary's zone config.
statement ok
CREATE TABLE infect (x INT PRIMARY KEY);
ALTER TABLE infect PARTITION BY LIST (x) ( PARTITION p1 VALUES IN (1));
ALTER INDEX infect@primary CONFIGURE ZONE USING num_replicas=5;
ALTER PARTITION p1 OF TABLE infect CONFIGURE ZONE USING constraints='[+dc=dc1]'

query TT
SELECT partition_name, zone_config FROM [SHOW PARTITIONS FROM TABLE infect]
----
p1 constraints = '[+dc=dc1]'

3 changes: 2 additions & 1 deletion pkg/cmd/roachtest/hibernate.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ func registerHibernate(r *testRegistry) {
// Also note that this is expected to return an error, since the test suite
// will fail. And it is safe to swallow it here.
_ = c.RunE(ctx, node,
`cd /mnt/data1/hibernate/hibernate-core/ && ./../gradlew test -Pdb=cockroach`,
`cd /mnt/data1/hibernate/hibernate-core/ && `+
`HIBERNATE_CONNECTION_LEAK_DETECTION=true ./../gradlew test -Pdb=cockroach`,
)

t.Status("collecting the test results")
Expand Down
10 changes: 0 additions & 10 deletions pkg/cmd/roachtest/hibernate_blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ var hibernateBlackList19_2 = blacklist{
"org.hibernate.test.annotations.lob.VersionedLobTest.testVersionUnchangedString": "26725",
"org.hibernate.test.annotations.manytoone.referencedcolumnname.ManyToOneReferencedColumnNameTest.testReoverableExceptionInFkOrdering": "24062",
"org.hibernate.test.annotations.onetoone.hhh9798.OneToOneJoinTableTest.storeNonUniqueRelationship": "5807",
"org.hibernate.test.annotations.query.QueryAndSQLTest.testNativeQueryWithFormulaAttributeWithoutAlias": "unknown",
"org.hibernate.test.annotations.xml.hbm.HbmWithIdentityTest.testManyToOneAndInterface": "24062",
"org.hibernate.test.bulkid.GlobalTemporaryTableBulkCompositeIdTest.testDeleteFromEngineer": "5807",
"org.hibernate.test.bulkid.GlobalTemporaryTableBulkCompositeIdTest.testDeleteFromPerson": "5807",
Expand Down Expand Up @@ -156,7 +155,6 @@ var hibernateBlackList19_2 = blacklist{
"org.hibernate.test.immutable.entitywithmutablecollection.inverse.VersionedEntityWithInverseOneToManyJoinTest.testOneToManyCollectionOptimisticLockingWithUpdate": "5807",
"org.hibernate.test.immutable.entitywithmutablecollection.noninverse.EntityWithNonInverseOneToManyJoinTest.testOneToManyCollectionOptimisticLockingWithUpdate": "5807",
"org.hibernate.test.immutable.entitywithmutablecollection.noninverse.VersionedEntityWithNonInverseOneToManyJoinTest.testOneToManyCollectionOptimisticLockingWithUpdate": "5807",
"org.hibernate.test.insertordering.InsertOrderingWithCascadeOnPersist.testInsertOrderingAvoidingForeignKeyConstraintViolation": "6583",
"org.hibernate.test.insertordering.InsertOrderingWithJoinedTableInheritance.testBatchOrdering": "5807",
"org.hibernate.test.insertordering.InsertOrderingWithJoinedTableInheritance.testBatchingAmongstSubClasses": "5807",
"org.hibernate.test.insertordering.InsertOrderingWithJoinedTableMultiLevelInheritance.testBatchingAmongstSubClasses": "5807",
Expand Down Expand Up @@ -209,21 +207,13 @@ var hibernateBlackList19_2 = blacklist{
"org.hibernate.test.locking.LockModeTest.testLegacyCriteriaAliasSpecific": "6583",
"org.hibernate.test.locking.LockModeTest.testLoading": "6583",
"org.hibernate.test.locking.LockModeTest.testQuery": "6583",
"org.hibernate.test.locking.LockModeTest.testQueryUsingLockOptions": "6583",
"org.hibernate.test.locking.LockModeTest.testRefreshWithExplicitHigherLevelLockMode": "6583",
"org.hibernate.test.locking.PessimisticReadSkipLockedTest.testPostgreSQLSkipLocked": "6583",
"org.hibernate.test.locking.PessimisticWriteLockTimeoutTest.testNoWait": "6583",
"org.hibernate.test.locking.PessimisticWriteLockTimeoutTest.testSkipLocked": "6583",
"org.hibernate.test.locking.PessimisticWriteSkipLockedTest.testPostgreSQLSkipLocked": "6583",
"org.hibernate.test.locking.UpgradeSkipLockedTest.testPostgreSQLSkipLocked": "6583",
"org.hibernate.test.locking.paging.PagingAndLockingTest.testCriteria": "6583",
"org.hibernate.test.locking.paging.PagingAndLockingTest.testHql": "6583",
"org.hibernate.test.mixed.MixedTest.testMixedInheritance": "26725",
"org.hibernate.test.naturalid.mutable.cached.CachedMutableNaturalIdNonStrictReadWriteTest.testReattachementUnmodifiedInstance": "6583",
"org.hibernate.test.naturalid.mutable.cached.CachedMutableNaturalIdStrictReadWriteTest.testReattachementUnmodifiedInstance": "6583",
"org.hibernate.test.naturalid.nullable.NullableNaturalIdTest.testNaturalIdNullValueOnPersist": "6583",
"org.hibernate.test.naturalid.nullable.NullableNaturalIdTest.testNaturalIdQuerySupportingNullValues": "6583",
"org.hibernate.test.naturalid.nullable.NullableNaturalIdTest.testUniqueAssociation": "6583",
"org.hibernate.test.notfound.OptionalEagerMappedByNotFoundTest.testOneToOneJoinException": "5807",
"org.hibernate.test.notfound.OptionalEagerMappedByNotFoundTest.testOneToOneJoinIgnore": "5807",
"org.hibernate.test.notfound.OptionalEagerMappedByNotFoundTest.testOneToOneSelectException": "5807",
Expand Down
13 changes: 13 additions & 0 deletions pkg/config/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,19 @@ func (z *ZoneConfig) GetSubzone(indexID uint32, partition string) *Subzone {
return nil
}

// GetSubzoneExact is similar to GetSubzone but does not find the most specific
// subzone that applies to a specified index and partition, as it finds either the
// exact config that applies, or returns nil.
func (z *ZoneConfig) GetSubzoneExact(indexID uint32, partition string) *Subzone {
for _, s := range z.Subzones {
if s.IndexID == indexID && s.PartitionName == partition {
copySubzone := s
return &copySubzone
}
}
return nil
}

// GetSubzoneForKeySuffix returns the ZoneConfig for the subzone that contains
// keySuffix, if it exists and its position in the subzones slice.
func (z ZoneConfig) GetSubzoneForKeySuffix(keySuffix []byte) (*Subzone, int32) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/set_zone_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (n *setZoneConfigNode) startExec(params runParams) error {

var partialSubzone *config.Subzone
if index != nil {
partialSubzone = partialZone.GetSubzone(uint32(index.ID), partition)
partialSubzone = partialZone.GetSubzoneExact(uint32(index.ID), partition)
if partialSubzone == nil {
partialSubzone = &config.Subzone{Config: *config.NewZoneConfig()}
}
Expand Down

0 comments on commit 12c640b

Please sign in to comment.