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.
134
+
scaryTableIDRemapFunc:=`
135
+
CREATE OR REPLACE FUNCTION renumber_desc(oldID INT, newID INT) RETURNS BOOL AS
136
+
$$
137
+
BEGIN
138
+
-- Rewrite the ID within the descriptor
139
+
SELECT crdb_internal.unsafe_upsert_descriptor(
140
+
newid,
141
+
crdb_internal.json_to_pb(
142
+
'cockroach.sql.sqlbase.Descriptor',
143
+
d
144
+
),
145
+
true
146
+
)
147
+
FROM (
148
+
SELECT id,
149
+
json_set(
150
+
json_set(
151
+
crdb_internal.pb_to_json(
152
+
'cockroach.sql.sqlbase.Descriptor',
153
+
descriptor,
154
+
false
155
+
),
156
+
ARRAY['table', 'id'],
157
+
newid::STRING::JSONB
158
+
),
159
+
ARRAY['table', 'modificationTime'],
160
+
json_build_object(
161
+
'wallTime',
162
+
(
163
+
(
164
+
extract('epoch', now())
165
+
* 1000000
166
+
)::INT8
167
+
* 1000
168
+
)::STRING
169
+
)
170
+
) AS d
171
+
FROM system.descriptor
172
+
WHERE id IN (oldid,)
173
+
);
174
+
-- Update the namespace entry and delete the old descriptor.
175
+
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