You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
crosscluster/physical: add reader tenant system table id offset setting
This patch adds the private
physical_cluster_replication.reader_system_table_id_offset setting, which a pcr
customer can set on the destination system tenant to some very large number,
like 1,000,000, which will bootstrap the reader tenant with dynamically
allocated system table ids to be offset+i. This setting can be set when the
reader tenant fails to start up because a source table id collides with a
system table id.
Informs #152909
Release note: none
// swap a system table ID and a user table ID to simulate a cluster that has interleaving user and system table ids.
131
+
scaryTableIDRemapFunc:=`
132
+
CREATE OR REPLACE FUNCTION renumber_desc(oldID INT, newID INT) RETURNS BOOL AS
133
+
$$
134
+
BEGIN
135
+
-- Rewrite the ID within the descriptor
136
+
SELECT crdb_internal.unsafe_upsert_descriptor(
137
+
newid,
138
+
crdb_internal.json_to_pb(
139
+
'cockroach.sql.sqlbase.Descriptor',
140
+
d
141
+
),
142
+
true
143
+
)
144
+
FROM (
145
+
SELECT id,
146
+
json_set(
147
+
json_set(
148
+
crdb_internal.pb_to_json(
149
+
'cockroach.sql.sqlbase.Descriptor',
150
+
descriptor,
151
+
false
152
+
),
153
+
ARRAY['table', 'id'],
154
+
newid::STRING::JSONB
155
+
),
156
+
ARRAY['table', 'modificationTime'],
157
+
json_build_object(
158
+
'wallTime',
159
+
(
160
+
(
161
+
extract('epoch', now())
162
+
* 1000000
163
+
)::INT8
164
+
* 1000
165
+
)::STRING
166
+
)
167
+
) AS d
168
+
FROM system.descriptor
169
+
WHERE id IN (oldid,)
170
+
);
171
+
-- Update the namespace entry and delete the old descriptor.
172
+
SELECT crdb_internal.unsafe_upsert_namespace_entry("parentID", "parentSchemaID", name, newID, true) FROM (SELECT "parentID", "parentSchemaID", name, id FROM system.namespace where id =oldID) UNION ALL
0 commit comments