Skip to content

Commit

Permalink
sql: create system.prepared_transactions table
Browse files Browse the repository at this point in the history
Informs #22329.

This commit adds a new `system.prepared_transactions` table, which will
be used to track prepared transactions. The table includes all of the
information needed to implement XA two-phase commit transactions, along
with additional metadata needed to implement `pg_catalog.pg_prepared_xacts`.

Release note: None
  • Loading branch information
nvanbenschoten committed Dec 12, 2024
1 parent 34373ea commit 63a17f2
Show file tree
Hide file tree
Showing 149 changed files with 1,153 additions and 771 deletions.
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,4 @@ trace.span_registry.enabled boolean false if set, ongoing traces can be seen at
trace.zipkin.collector string the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used. application
ui.database_locality_metadata.enabled boolean true if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute application
ui.display_timezone enumeration etc/utc the timezone used to format timestamps in the ui [etc/utc = 0, america/new_york = 1] application
version version 1000024.3-upgrading-to-1000025.1-step-010 set the active cluster version in the format '<major>.<minor>' application
version version 1000024.3-upgrading-to-1000025.1-step-012 set the active cluster version in the format '<major>.<minor>' application
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,6 @@
<tr><td><div id="setting-trace-zipkin-collector" class="anchored"><code>trace.zipkin.collector</code></div></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as &lt;host&gt;:&lt;port&gt;. If no port is specified, 9411 will be used.</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-ui-database-locality-metadata-enabled" class="anchored"><code>ui.database_locality_metadata.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if enabled shows extended locality data about databases and tables in DB Console which can be expensive to compute</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-ui-display-timezone" class="anchored"><code>ui.display_timezone</code></div></td><td>enumeration</td><td><code>etc/utc</code></td><td>the timezone used to format timestamps in the ui [etc/utc = 0, america/new_york = 1]</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000024.3-upgrading-to-1000025.1-step-010</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000024.3-upgrading-to-1000025.1-step-012</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
</tbody>
</table>
3 changes: 3 additions & 0 deletions pkg/backup/system_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,9 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{
systemschema.TableMetadata.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
systemschema.PreparedTransactionsTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
}

func rekeySystemTable(
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ txn_id txn_fingerprint_id query implicit_txn session_id start_time end_tim
query ITTI
SELECT range_id, start_pretty, end_pretty, lease_holder FROM crdb_internal.ranges
----
74 /Tenant/10 /Tenant/11 1
75 /Tenant/10 /Tenant/11 1

query ITT
SELECT range_id, start_pretty, end_pretty FROM crdb_internal.ranges_no_leases
----
74 /Tenant/10 /Tenant/11
75 /Tenant/10 /Tenant/11

query IT
SELECT zone_id, target FROM crdb_internal.zones ORDER BY 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ skipif config multiregion-9node-3region-3azs-vec-off
query I retry
SELECT DISTINCT range_id FROM [SHOW RANGES FROM TABLE messages_rbr]
----
79
80

# Update does not fail when accessing all rows in messages_rbr because lookup
# join does not error out the lookup table in phase 1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ ap-southeast-2 23
query TT
SELECT start_key, end_key FROM [SHOW RANGE FROM TABLE regional_by_row_table FOR ROW ('ap-southeast-2', 1)]
----
<before:/Table/71> …
<before:/Table/72> …

query TIIII
SELECT crdb_region, pk, pk2, a, b FROM regional_by_row_table
Expand Down Expand Up @@ -404,7 +404,7 @@ SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM INDEX r
ORDER BY 1
----
start_key end_key replicas lease_holder
<before:/Table/71> …/"\x80"/0 {1} 1
<before:/Table/72> …/"\x80"/0 {1} 1
…/"\x80"/0 …/"\xc0"/0 {4} 4
…/"\xc0"/0 <after:/Table/110/5> {7} 7

Expand Down
4 changes: 4 additions & 0 deletions pkg/ccl/spanconfigccl/spanconfigreconcilerccl/testdata/basic
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ upsert /Table/6{8-9} database system (host)
upsert /Table/{69-70} database system (host)
upsert /Table/7{0-1} database system (host)
upsert /Table/7{1-2} database system (host)
upsert /Table/7{2-3} database system (host)

exec-sql
CREATE DATABASE db;
Expand Down Expand Up @@ -140,6 +141,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Table/10{6-7} num_replicas=7 num_voters=5
/Table/10{7-8} num_replicas=7
/Table/11{2-3} num_replicas=7
Expand Down Expand Up @@ -267,6 +269,8 @@ delete /Table/7{0-1}
upsert /Table/7{0-1} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
delete /Table/7{1-2}
upsert /Table/7{1-2} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true
delete /Table/7{2-3}
upsert /Table/7{2-3} ttl_seconds=100 ignore_strict_gc=true num_replicas=5 rangefeed_enabled=true

state offset=5 limit=42
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Table/10{6-7} range default

exec-sql
Expand Down Expand Up @@ -92,6 +93,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Table/106{-/2} num_replicas=7
/Table/106/{2-3} num_replicas=7 num_voters=5
/Table/10{6/3-7} num_replicas=7
Expand Down Expand Up @@ -140,6 +142,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Table/106{-/2} ttl_seconds=3600 num_replicas=7
/Table/106/{2-3} ttl_seconds=25 num_replicas=7 num_voters=5
/Table/10{6/3-7} ttl_seconds=3600 num_replicas=7
Expand Down Expand Up @@ -178,6 +181,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Table/106{-/2} ttl_seconds=3600 num_replicas=9
/Table/106/{2-3} ttl_seconds=25 num_replicas=9 num_voters=5
/Table/10{6/3-7} ttl_seconds=3600 num_replicas=9
Expand Down Expand Up @@ -230,3 +234,4 @@ state offset=46
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Tenant/10{-\x00} database system (tenant)
/Tenant/11{-\x00} database system (tenant)
/Tenant/12{-\x00} database system (tenant)
Expand Down Expand Up @@ -119,6 +120,7 @@ upsert /Tenant/10/Table/6{8-9} database system (tenant)
upsert /Tenant/10/Table/{69-70} database system (tenant)
upsert /Tenant/10/Table/7{0-1} database system (tenant)
upsert /Tenant/10/Table/7{1-2} database system (tenant)
upsert /Tenant/10/Table/7{2-3} database system (tenant)

state offset=47
----
Expand Down Expand Up @@ -148,6 +150,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Tenant/10{-/Table/4} database system (tenant)
/Tenant/10/Table/{4-5} database system (tenant)
/Tenant/10/Table/{5-6} database system (tenant)
Expand Down Expand Up @@ -209,6 +212,7 @@ state offset=47
/Tenant/10/Table/{69-70} database system (tenant)
/Tenant/10/Table/7{0-1} database system (tenant)
/Tenant/10/Table/7{1-2} database system (tenant)
/Tenant/10/Table/7{2-3} database system (tenant)
/Tenant/11{-\x00} database system (tenant)
/Tenant/12{-\x00} database system (tenant)

Expand All @@ -233,6 +237,7 @@ upsert /Tenant/10/Table/11{3-4} rangefeed_enabled=true
state offset=81
----
...
/Tenant/10/Table/1{2-3} database system (tenant)
/Tenant/10/Table/1{3-4} database system (tenant)
/Tenant/10/Table/1{4-5} database system (tenant)
/Tenant/10/Table/1{5-6} database system (tenant)
Expand Down Expand Up @@ -285,6 +290,7 @@ state offset=81
/Tenant/10/Table/{69-70} database system (tenant)
/Tenant/10/Table/7{0-1} database system (tenant)
/Tenant/10/Table/7{1-2} database system (tenant)
/Tenant/10/Table/7{2-3} database system (tenant)
/Tenant/10/Table/10{6-7} rangefeed_enabled=true
/Tenant/10/Table/10{7-8} rangefeed_enabled=true
/Tenant/10/Table/11{2-3} rangefeed_enabled=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Tenant/10{-\x00} database system (tenant)
/Tenant/11{-\x00} database system (tenant)

Expand Down Expand Up @@ -135,6 +136,7 @@ upsert /Tenant/10/Table/6{8-9} database system (tenant)
upsert /Tenant/10/Table/{69-70} database system (tenant)
upsert /Tenant/10/Table/7{0-1} database system (tenant)
upsert /Tenant/10/Table/7{1-2} database system (tenant)
upsert /Tenant/10/Table/7{2-3} database system (tenant)

exec-sql tenant=10
CREATE DATABASE db;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Tenant/10{-\x00} database system (tenant)
/Tenant/11{-\x00} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
/Tenant/12{-\x00} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
Expand Down Expand Up @@ -104,6 +105,7 @@ state offset=47
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Tenant/10{-/Table/4} database system (tenant)
/Tenant/10/Table/{4-5} database system (tenant)
/Tenant/10/Table/{5-6} database system (tenant)
Expand Down Expand Up @@ -165,6 +167,7 @@ state offset=47
/Tenant/10/Table/{69-70} database system (tenant)
/Tenant/10/Table/7{0-1} database system (tenant)
/Tenant/10/Table/7{1-2} database system (tenant)
/Tenant/10/Table/7{2-3} database system (tenant)
/Tenant/11{-\x00} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
/Tenant/12{-\x00} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true

Expand Down Expand Up @@ -202,6 +205,7 @@ mutations discard tenant=11
state offset=81
----
...
/Tenant/10/Table/1{2-3} database system (tenant)
/Tenant/10/Table/1{3-4} database system (tenant)
/Tenant/10/Table/1{4-5} database system (tenant)
/Tenant/10/Table/1{5-6} database system (tenant)
Expand Down Expand Up @@ -254,6 +258,7 @@ state offset=81
/Tenant/10/Table/{69-70} database system (tenant)
/Tenant/10/Table/7{0-1} database system (tenant)
/Tenant/10/Table/7{1-2} database system (tenant)
/Tenant/10/Table/7{2-3} database system (tenant)
/Tenant/10/Table/10{6-7} rangefeed_enabled=true
/Tenant/10/Table/10{7-8} rangefeed_enabled=true
/Tenant/11{-/Table/4} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
Expand Down Expand Up @@ -317,6 +322,7 @@ state offset=81
/Tenant/11/Table/{69-70} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
/Tenant/11/Table/7{0-1} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
/Tenant/11/Table/7{1-2} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
/Tenant/11/Table/7{2-3} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true
/Tenant/12{-\x00} ttl_seconds=18000 ignore_strict_gc=true rangefeed_enabled=true

query-sql tenant=11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ state offset=59
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Tenant/11{-\x00} database system (tenant)
/Tenant/12{-\x00} database system (tenant)

Expand Down Expand Up @@ -58,6 +59,7 @@ state offset=60 limit=3
state offset=103
----
...
/Tenant/11/Table/4{0-1} database system (tenant)
/Tenant/11/Table/4{1-2} database system (tenant)
/Tenant/11/Table/4{2-3} database system (tenant)
/Tenant/11/Table/4{3-4} database system (tenant)
Expand Down Expand Up @@ -88,6 +90,7 @@ state offset=103
/Tenant/11/Table/{69-70} database system (tenant)
/Tenant/11/Table/7{0-1} database system (tenant)
/Tenant/11/Table/7{1-2} database system (tenant)
/Tenant/11/Table/7{2-3} database system (tenant)
/Tenant/12{-\x00} database system (tenant)

# Just another view of what the tenant's reconciler actually did. It got rid of
Expand Down Expand Up @@ -158,6 +161,7 @@ upsert /Tenant/11/Table/6{8-9} database system (tenant)
upsert /Tenant/11/Table/{69-70} database system (tenant)
upsert /Tenant/11/Table/7{0-1} database system (tenant)
upsert /Tenant/11/Table/7{1-2} database system (tenant)
upsert /Tenant/11/Table/7{2-3} database system (tenant)

# Initialize a new tenant, tenant=10, that DOES have a pre-existing tenant,
# tenant=11, next to it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ state offset=46
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Table/10{6-7} ttl_seconds=50

# Make sure future descendants observe the same.
Expand Down Expand Up @@ -189,6 +190,7 @@ state offset=46
/Table/{69-70} database system (host)
/Table/7{0-1} database system (host)
/Table/7{1-2} database system (host)
/Table/7{2-3} database system (host)
/Table/10{6-7} ttl_seconds=50
/Table/10{7-8} ttl_seconds=50

Expand Down
Loading

0 comments on commit 63a17f2

Please sign in to comment.