Skip to content

Commit

Permalink
sql: add max_prepared_transactions variable
Browse files Browse the repository at this point in the history
Informs cockroachdb#22329.

This commit adds the max_prepared_transactions session variable, returning a
value of math.MaxInt32 to indicate that there is no limit on the number of
prepared transactions that can be created.

This change has the effect of unblocking the pgjdbc XADataSourceTest test
suite, which was previously failing during initialization. Is also includes
a small patch to work around cockroachdb#31632 (unsupported deferrable qualifier) so
that each test in the XA test suite actually runs (and fails).

Release note: None
  • Loading branch information
nvanbenschoten committed Aug 20, 2024
1 parent ba7c94a commit 38034c3
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 16 deletions.
15 changes: 15 additions & 0 deletions pkg/cmd/roachtest/tests/pgjdbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ func registerPgjdbc(r registry.Registry) {
t.Fatal(err)
}

// Remove an unsupported deferrable qualifier (#31632) from the XA test
// suite setup. This prevents XADataSourceTest.mappingOfConstraintViolations
// from running properly (it fails either way), but it allows the rest of
// the XA tests to run.
if err := repeatRunE(
ctx,
t,
c,
node,
"removing unsupported deferrable qualifier from test",
"sed -i 's/ deferrable//' /mnt/data1/pgjdbc/pgjdbc/src/test/java/org/postgresql/test/xa/XADataSourceTest.java",
); err != nil {
t.Fatal(err)
}

t.Status("building pgjdbc (without tests)")
// Build pgjdbc and run a single test, this step involves some
// downloading, so it needs a retry loop as well. Just building was not
Expand Down
29 changes: 28 additions & 1 deletion pkg/cmd/roachtest/tests/pgjdbc_blocklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,34 @@ var pgjdbcBlockList = blocklist{
`org.postgresql.test.util.PasswordUtilTest.encryptionTypeValueOfOn()`: "73337",
`org.postgresql.test.util.PasswordUtilTest.mD5()`: "73337",
`org.postgresql.test.util.PasswordUtilTest.scramSha256()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.initializationError`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.autoCommit()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.closeBeforeCommit()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.commitByDifferentConnection()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.commitUnknownXid()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.committingCommittedXid()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.databaseRemovesPreparedBeforeCommit()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.databaseRemovesPreparedBeforeRollback()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.endThenJoin()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.mappingOfConstraintViolations()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.networkIssueOnCommit()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.networkIssueOnOnePhaseCommit()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.networkIssueOnRollback()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.onePhase()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.onePhaseCommitOfPrepared()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.onePhaseCommitUnknownXid()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.onePhaseCommittingCommittedXid()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.prepareUnknownXid()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.preparingPreparedXid()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.recover()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.repeatedRolledBack()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.restoreOfAutoCommit()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.restoreOfAutoCommitEndThenJoin()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.rollback()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.rollbackByDifferentConnection()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.rollbackUnknownXid()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.rollbackWithoutPrepare()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.twoPhaseCommit()`: "unknown",
`org.postgresql.test.xa.XADataSourceTest.wrapperEquals()`: "unknown",
}

var pgjdbcIgnoreList = blocklist{
Expand Down
31 changes: 16 additions & 15 deletions pkg/sql/explain_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1163,21 +1163,22 @@ func (c *stmtEnvCollector) PrintTableStats(
// explicitly excluded from env.sql of the bundle (they were deemed unlikely to
// be useful in investigations).
var skipReadOnlySessionVar = map[string]struct{}{
"crdb_version": {}, // version is included separately
"integer_datetimes": {},
"lc_collate": {},
"lc_ctype": {},
"max_connections": {},
"max_identifier_length": {},
"max_index_keys": {},
"server_encoding": {},
"server_version": {},
"server_version_num": {},
"session_authorization": {},
"session_user": {},
"system_identity": {},
"tracing": {},
"virtual_cluster_name": {},
"crdb_version": {}, // version is included separately
"integer_datetimes": {},
"lc_collate": {},
"lc_ctype": {},
"max_connections": {},
"max_identifier_length": {},
"max_index_keys": {},
"max_prepared_transactions": {},
"server_encoding": {},
"server_version": {},
"server_version_num": {},
"session_authorization": {},
"session_user": {},
"system_identity": {},
"tracing": {},
"virtual_cluster_name": {},
}

// sessionVarNeedsQuotes contains all writable session variables that have
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/logictest/testdata/logic_test/information_schema
Original file line number Diff line number Diff line change
Expand Up @@ -6167,6 +6167,7 @@ log_timezone UTC
max_connections -1
max_identifier_length 128
max_index_keys 32
max_prepared_transactions 2147483647
max_retries_for_read_committed 10
node_id 1
null_ordered_last off
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -2902,6 +2902,7 @@ log_timezone UTC N
max_connections -1 NULL NULL NULL string
max_identifier_length 128 NULL NULL NULL string
max_index_keys 32 NULL NULL NULL string
max_prepared_transactions 2147483647 NULL NULL NULL string
max_retries_for_read_committed 10 NULL NULL NULL string
node_id 1 NULL NULL NULL string
null_ordered_last off NULL NULL NULL string
Expand Down Expand Up @@ -3093,6 +3094,7 @@ log_timezone UTC N
max_connections -1 NULL user NULL -1 -1
max_identifier_length 128 NULL user NULL 128 128
max_index_keys 32 NULL user NULL 32 32
max_prepared_transactions 2147483647 NULL user NULL 2147483647 2147483647
max_retries_for_read_committed 10 NULL user NULL 10 10
node_id 1 NULL user NULL 1 1
null_ordered_last off NULL user NULL off off
Expand Down Expand Up @@ -3281,6 +3283,7 @@ log_timezone NULL NULL NULL
max_connections NULL NULL NULL NULL NULL
max_identifier_length NULL NULL NULL NULL NULL
max_index_keys NULL NULL NULL NULL NULL
max_prepared_transactions NULL NULL NULL NULL NULL
max_retries_for_read_committed NULL NULL NULL NULL NULL
multiple_active_portals_enabled NULL NULL NULL NULL NULL
node_id NULL NULL NULL NULL NULL
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/logictest/testdata/logic_test/show_source
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ log_timezone UTC
max_connections -1
max_identifier_length 128
max_index_keys 32
max_prepared_transactions 2147483647
max_retries_for_read_committed 10
node_id 1
null_ordered_last off
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,10 @@ var varGen = map[string]sessionVar{
// See https://www.postgresql.org/docs/10/static/runtime-config-preset.html#GUC-MAX-INDEX-KEYS
`max_index_keys`: makeReadOnlyVar("32"),

// Supported for PG compatibility only. MaxInt32 indicates no limit.
// See https://www.postgresql.org/docs/10/runtime-config-resource.html#GUC-MAX-PREPARED-TRANSACTIONS
`max_prepared_transactions`: makeReadOnlyVar(strconv.Itoa(math.MaxInt32)),

// CockroachDB extension.
`node_id`: {
Get: func(evalCtx *extendedEvalContext, _ *kv.Txn) (string, error) {
Expand Down

0 comments on commit 38034c3

Please sign in to comment.