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