Skip to content

Commit d476689

Browse files
authored
feat: disable described statement cache timeout by default (GoogleCloudPlatform#4409)
* feat: disable described statement cache timeout by default The timeout for the described statements cache was set to 30 minutes by default. This default is now set to Long.MAX_VALUE, as elements in this cache are (almost) never invalidated. They would only be invalidated if the data type of an existing column would change while the application is running, which is a very rare event. The added number of roundtrips that are added by invalidating elements in this cache once every 30 minutes does not weigh up against the tiny probability that any elements are actually invalid. * build: add expected system table
1 parent 2e09673 commit d476689

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

.ci/e2e-expected/backslash-dt.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
testdb_e2e_psql_v?? | spanner_sys | column_operations_stats_10minute | VIEW | | | | | | | | | | | | |
4848
testdb_e2e_psql_v?? | spanner_sys | column_operations_stats_hour | VIEW | | | | | | | | | | | | |
4949
testdb_e2e_psql_v?? | spanner_sys | column_operations_stats_minute | VIEW | | | | | | | | | | | | |
50+
testdb_e2e_psql_v?? | spanner_sys | graph_operation_execution_status | VIEW | | | | | | | | | | | | |
5051
testdb_e2e_psql_v?? | spanner_sys | lock_stats_top_10minute | VIEW | | | | | | | | | | | | |
5152
testdb_e2e_psql_v?? | spanner_sys | lock_stats_top_hour | VIEW | | | | | | | | | | | | |
5253
testdb_e2e_psql_v?? | spanner_sys | lock_stats_top_minute | VIEW | | | | | | | | | | | | |
@@ -91,5 +92,5 @@
9192
testdb_e2e_psql_v?? | spanner_sys | txn_stats_total_minute | VIEW | | | | | | | | | | | | |
9293
testdb_e2e_psql_v?? | spanner_sys | user_split_points | VIEW | | | | | | | | | | | | |
9394
testdb_e2e_psql_v?? | spanner_sys | vector_index_metrics_history | VIEW | | | | | | | | | | | | |
94-
(90 rows)
95+
(91 rows)
9596

src/main/java/com/google/cloud/spanner/pgadapter/metadata/OptionsMetadata.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,11 @@ public enum DdlTransactionMode {
707707
private static final String OPTION_DESCRIBE_CACHE_EXPIRE_MINUTES =
708708
"describe_cache_expire_minutes";
709709
private static final String OPTION_DESCRIBE_CACHE_MAX_SIZE = "describe_cache_max_size";
710-
private static final long DEFAULT_DESCRIBE_CACHE_EXPIRE_MINUTES = 30L;
710+
// The default for this cache is not to expire elements. The reason is that the values in this
711+
// cache would only be invalidated if the datatype of an existing column would change, which is
712+
// highly unlikely to occur for a production system.
713+
private static final long DEFAULT_DESCRIBE_CACHE_EXPIRE_MINUTES =
714+
Duration.ofSeconds(Long.MAX_VALUE).toMinutes();
711715
private static final long DEFAULT_DESCRIBE_CACHE_MAX_SIZE = 5000L;
712716

713717
private final Map<String, String> environment;

src/test/java/com/google/cloud/spanner/pgadapter/metadata/OptionsMetadataTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.io.File;
4141
import java.io.IOException;
4242
import java.io.PrintStream;
43+
import java.time.Duration;
4344
import java.util.Collections;
4445
import org.junit.Test;
4546
import org.junit.runner.RunWith;
@@ -101,7 +102,8 @@ public void testCustomMaxBacklog() {
101102
public void testDefaultDescribeCacheOptions() {
102103
OptionsMetadata options =
103104
new OptionsMetadata(new String[] {"-p", "p", "-i", "i", "-c", "credentials.json"});
104-
assertEquals(30L, options.getDescribeCacheExpireMinutes());
105+
assertEquals(
106+
Duration.ofSeconds(Long.MAX_VALUE).toMinutes(), options.getDescribeCacheExpireMinutes());
105107
assertEquals(5000L, options.getDescribeCacheMaxSize());
106108
}
107109

0 commit comments

Comments
 (0)