Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
[Alta DbKVS] Part 8: Serialization of Oracle Config Change (#5964)
Browse files Browse the repository at this point in the history
Although this is not a common operation, internal timelock implementation serializes KVS config, including that of Oracle. In #5942 we accidentally changed the _serialized_ form of the Oracle config. Note that this doesn't affect config _deserialization_, which covers most (non-timelock) AtlasDB users.
  • Loading branch information
jeremyk-91 authored Mar 15, 2022
1 parent 366e1ac commit f5dad7f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions atlasdb-dbkvs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation project(':timestamp-api')

testImplementation 'com.google.guava:guava'
testImplementation 'com.palantir.conjure.java.runtime:conjure-java-jackson-serialization'
testImplementation 'com.palantir.safe-logging:safe-logging'
testImplementation 'com.zaxxer:HikariCP'
testImplementation 'org.slf4j:slf4j-api'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public boolean longIdentifierNamesSupported() {
}

@Value.Derived
@JsonIgnore
public OracleIdentifierLengthLimits identifierLengthLimits() {
return longIdentifierNamesSupported()
? OracleIdentifierLengthLimitOptions.ORACLE_12_2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.palantir.atlasdb.keyvalue.dbkvs;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.palantir.atlasdb.AtlasDbConstants;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
Expand All @@ -27,8 +25,6 @@
* Tracks length limits on tables and identifier names within Oracle.
*/
@Value.Immutable
@JsonDeserialize(as = ImmutableOracleIdentifierLengthLimits.class)
@JsonSerialize(as = ImmutableOracleIdentifierLengthLimits.class)
public interface OracleIdentifierLengthLimits {
int identifierLengthLimit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.google.common.collect.ImmutableList;
import com.palantir.atlasdb.keyvalue.dbkvs.impl.OverflowMigrationState;
import com.palantir.conjure.java.serialization.ObjectMappers;
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -153,6 +156,25 @@ public void canSetTableMappingExplicitly() {
}
}

@Test
public void serializedFormDoesNotIncludeLengthLimits() throws JsonProcessingException {
JsonMapper jsonMapper = ObjectMappers.newServerJsonMapper();

OracleDdlConfig config =
createLongNameSupportingOracleConfigWithPrefixes(getPrefixWithLength(8), getPrefixWithLength(15));
assertThat(jsonMapper.writeValueAsString(config)).doesNotContain("identifierLengthLimits");
}

@Test
public void serializeAndDeserializeIsNoOp() throws JsonProcessingException {
JsonMapper jsonMapper = ObjectMappers.newServerJsonMapper();

OracleDdlConfig config =
createLongNameSupportingOracleConfigWithPrefixes(getPrefixWithLength(44), getPrefixWithLength(33));
assertThat(jsonMapper.readValue(jsonMapper.writeValueAsString(config), OracleDdlConfig.class))
.isEqualTo(config);
}

private static OracleDdlConfig createLegacyCompatibleOracleConfigWithPrefixes(
String tablePrefix, String overflowTablePrefix) {
return createOracleDdlConfig(tablePrefix, overflowTablePrefix, false);
Expand All @@ -170,7 +192,7 @@ private static ImmutableOracleDdlConfig createOracleDdlConfig(
.overflowTablePrefix(overflowTablePrefix)
.overflowMigrationState(OverflowMigrationState.FINISHED)
.longIdentifierNamesSupported(longIdentifierNamesSupported)
.useTableMapping(false)
.forceTableMapping(false)
.build();
}

Expand Down
7 changes: 7 additions & 0 deletions changelog/@unreleased/pr-5964.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: fix
fix:
description: |-
Serialization of `identifierLengthLimits` as part of serializing an `OracleDdlConfig` no longer happens.
Note that this doesn't affect config _deserialization_, which covers most (non-timelock) AtlasDB users.
links:
- https://github.com/palantir/atlasdb/pull/5964

0 comments on commit f5dad7f

Please sign in to comment.