@@ -8,6 +8,7 @@ package upgrades
8
8
import (
9
9
"context"
10
10
"fmt"
11
+ "time"
11
12
12
13
"github.com/cockroachdb/cockroach/pkg/clusterversion"
13
14
"github.com/cockroachdb/cockroach/pkg/kv"
@@ -16,7 +17,6 @@ import (
16
17
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
17
18
"github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkeys"
18
19
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
19
- "github.com/cockroachdb/cockroach/pkg/sql/catalog/lease"
20
20
"github.com/cockroachdb/cockroach/pkg/sql/catalog/nstree"
21
21
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
22
22
"github.com/cockroachdb/cockroach/pkg/upgrade"
@@ -79,7 +79,7 @@ func upgradeDescriptors(
79
79
batchSize := 100
80
80
// Any batch size below this will use high priority.
81
81
const HighPriBatchSize = 25
82
- repairBatchTimeLimit := lease . LeaseDuration . Get ( & d . Settings . SV )
82
+ repairBatchTimeLimit := 1 * time . Minute
83
83
currentIdx := 0
84
84
idsToRewrite := ids .Ordered ()
85
85
for currentIdx <= len (idsToRewrite ) {
@@ -102,7 +102,18 @@ func upgradeDescriptors(
102
102
b := txn .KV ().NewBatch ()
103
103
for _ , mut := range muts {
104
104
if ! mut .GetPostDeserializationChanges ().HasChanges () {
105
- continue
105
+ // In the upgrade to 25.4, we do a one-time rewrite of all
106
+ // descriptors in order to upgrade them to use the new type
107
+ // serialization format.
108
+ // See https://github.com/cockroachdb/cockroach/issues/152629.
109
+ if d .Settings .Version .IsActive (ctx , clusterversion .V25_4 ) {
110
+ continue
111
+ }
112
+ // Skip the unconditional rewrite if this is a database descriptor,
113
+ // as those never reference types.
114
+ if mut .DescriptorType () == catalog .Database {
115
+ continue
116
+ }
106
117
}
107
118
key := catalogkeys .MakeDescMetadataKey (d .Codec , mut .GetID ())
108
119
b .CPut (key , mut .DescriptorProto (), mut .GetRawBytesInStorage ())
@@ -215,7 +226,7 @@ WHERE
215
226
batchSize := 100
216
227
// Any batch size below this will use high priority.
217
228
const HighPriBatchSize = 25
218
- repairBatchTimeLimit := lease . LeaseDuration . Get ( & d . Settings . SV )
229
+ repairBatchTimeLimit := 1 * time . Minute
219
230
for {
220
231
var rowsUpdated tree.DInt
221
232
err := timeutil .RunWithTimeout (ctx , "descriptor-repair" , repairBatchTimeLimit , func (ctx context.Context ) error {
0 commit comments