/
reactor_state.go
642 lines (595 loc) · 19.7 KB
/
reactor_state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
// Copyright 2021 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package orchestrator
import (
"reflect"
"time"
"github.com/goccy/go-json"
"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/tiflow/cdc/model"
cerrors "github.com/pingcap/tiflow/pkg/errors"
"github.com/pingcap/tiflow/pkg/etcd"
"github.com/pingcap/tiflow/pkg/orchestrator/util"
"go.uber.org/zap"
)
const defaultCaptureRemoveTTL = 5
// GlobalReactorState represents a global state which stores all key-value pairs in ETCD
type GlobalReactorState struct {
ClusterID string
Role string
Owner map[string]struct{}
Captures map[model.CaptureID]*model.CaptureInfo
Upstreams map[model.UpstreamID]*model.UpstreamInfo
Changefeeds map[model.ChangeFeedID]*ChangefeedReactorState
pendingPatches [][]DataPatch
// onCaptureAdded and onCaptureRemoved are hook functions
// to be called when captures are added and removed.
onCaptureAdded func(captureID model.CaptureID, addr string)
onCaptureRemoved func(captureID model.CaptureID)
captureRemoveTTL int
toRemoveCaptures map[model.CaptureID]time.Time
}
// NewGlobalState creates a new global state.
func NewGlobalState(clusterID string, captureSessionTTL int) *GlobalReactorState {
captureRemoveTTL := captureSessionTTL / 2
if captureRemoveTTL < defaultCaptureRemoveTTL {
captureRemoveTTL = defaultCaptureRemoveTTL
}
return &GlobalReactorState{
ClusterID: clusterID,
Owner: map[string]struct{}{},
Captures: make(map[model.CaptureID]*model.CaptureInfo),
Upstreams: make(map[model.UpstreamID]*model.UpstreamInfo),
Changefeeds: make(map[model.ChangeFeedID]*ChangefeedReactorState),
captureRemoveTTL: captureRemoveTTL,
toRemoveCaptures: make(map[model.CaptureID]time.Time),
}
}
// NewGlobalStateForTest creates a new global state for test.
func NewGlobalStateForTest(clusterID string) *GlobalReactorState {
return NewGlobalState(clusterID, 0)
}
// UpdatePendingChange implements the ReactorState interface
func (s *GlobalReactorState) UpdatePendingChange() {
for c, t := range s.toRemoveCaptures {
if time.Since(t) >= time.Duration(s.captureRemoveTTL)*time.Second {
log.Info("remote capture offline", zap.Any("info", s.Captures[c]), zap.String("role", s.Role))
delete(s.Captures, c)
if s.onCaptureRemoved != nil {
s.onCaptureRemoved(c)
}
delete(s.toRemoveCaptures, c)
}
}
}
// Update implements the ReactorState interface
func (s *GlobalReactorState) Update(key util.EtcdKey, value []byte, _ bool) error {
k := new(etcd.CDCKey)
err := k.Parse(s.ClusterID, key.String())
if err != nil {
return errors.Trace(err)
}
switch k.Tp {
case etcd.CDCKeyTypeOwner:
if value != nil {
s.Owner[k.OwnerLeaseID] = struct{}{}
} else {
delete(s.Owner, k.OwnerLeaseID)
}
return nil
case etcd.CDCKeyTypeCapture:
if value == nil {
log.Info("remote capture offline detected", zap.Any("info", s.Captures[k.CaptureID]), zap.String("role", s.Role))
s.toRemoveCaptures[k.CaptureID] = time.Now()
return nil
}
var newCaptureInfo model.CaptureInfo
err := newCaptureInfo.Unmarshal(value)
if err != nil {
return cerrors.ErrUnmarshalFailed.Wrap(err).GenWithStackByArgs()
}
log.Info("remote capture online", zap.Any("info", newCaptureInfo), zap.String("role", s.Role))
if s.onCaptureAdded != nil {
s.onCaptureAdded(k.CaptureID, newCaptureInfo.AdvertiseAddr)
}
s.Captures[k.CaptureID] = &newCaptureInfo
case etcd.CDCKeyTypeChangefeedInfo,
etcd.CDCKeyTypeChangeFeedStatus,
etcd.CDCKeyTypeTaskPosition:
changefeedState, exist := s.Changefeeds[k.ChangefeedID]
if !exist {
if value == nil {
return nil
}
changefeedState = NewChangefeedReactorState(s.ClusterID, k.ChangefeedID)
s.Changefeeds[k.ChangefeedID] = changefeedState
}
if err := changefeedState.UpdateCDCKey(k, value); err != nil {
return errors.Trace(err)
}
if value == nil && !changefeedState.Exist() {
s.pendingPatches = append(s.pendingPatches, changefeedState.getPatches())
delete(s.Changefeeds, k.ChangefeedID)
}
case etcd.CDCKeyTypeUpStream:
if value == nil {
log.Info("upstream is removed",
zap.Uint64("upstreamID", k.UpstreamID),
zap.Any("info", s.Upstreams[k.UpstreamID]),
zap.String("role", s.Role))
delete(s.Upstreams, k.UpstreamID)
return nil
}
var newUpstreamInfo model.UpstreamInfo
err := newUpstreamInfo.Unmarshal(value)
if err != nil {
return cerrors.ErrUnmarshalFailed.Wrap(err).GenWithStackByArgs()
}
log.Info("new upstream is add", zap.Uint64("upstream", k.UpstreamID),
zap.Any("info", newUpstreamInfo), zap.String("role", s.Role))
s.Upstreams[k.UpstreamID] = &newUpstreamInfo
case etcd.CDCKeyTypeMetaVersion:
default:
log.Warn("receive an unexpected etcd event", zap.String("key", key.String()),
zap.ByteString("value", value), zap.String("role", s.Role))
}
return nil
}
// GetPatches implements the ReactorState interface
// Every []DataPatch slice in [][]DataPatch slice is the patches of a ChangefeedReactorState
func (s *GlobalReactorState) GetPatches() [][]DataPatch {
pendingPatches := s.pendingPatches
for _, changefeedState := range s.Changefeeds {
pendingPatches = append(pendingPatches, changefeedState.getPatches())
}
s.pendingPatches = nil
return pendingPatches
}
// SetOnCaptureAdded registers a function that is called when a capture goes online.
func (s *GlobalReactorState) SetOnCaptureAdded(f func(captureID model.CaptureID, addr string)) {
s.onCaptureAdded = f
}
// SetOnCaptureRemoved registers a function that is called when a capture goes offline.
func (s *GlobalReactorState) SetOnCaptureRemoved(f func(captureID model.CaptureID)) {
s.onCaptureRemoved = f
}
// ChangefeedReactorState represents a changefeed state which stores all key-value pairs of a changefeed in ETCD
type ChangefeedReactorState struct {
ClusterID string
ID model.ChangeFeedID
Info *model.ChangeFeedInfo
Status *model.ChangeFeedStatus
TaskPositions map[model.CaptureID]*model.TaskPosition
pendingPatches []DataPatch
skipPatchesInThisTick bool
}
// NewChangefeedReactorState creates a new changefeed reactor state
func NewChangefeedReactorState(clusterID string,
id model.ChangeFeedID,
) *ChangefeedReactorState {
return &ChangefeedReactorState{
ClusterID: clusterID,
ID: id,
TaskPositions: make(map[model.CaptureID]*model.TaskPosition),
}
}
// GetID returns the changefeed ID.
func (s *ChangefeedReactorState) GetID() model.ChangeFeedID {
return s.ID
}
// GetChangefeedInfo returns the changefeed info.
func (s *ChangefeedReactorState) GetChangefeedInfo() *model.ChangeFeedInfo {
return s.Info
}
// GetChangefeedStatus returns the changefeed status.
func (s *ChangefeedReactorState) GetChangefeedStatus() *model.ChangeFeedStatus {
return s.Status
}
// SetWarning sets the warning to changefeed
func (s *ChangefeedReactorState) SetWarning(lastError *model.RunningError) {
s.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
if info == nil {
return nil, false, nil
}
info.Warning = lastError
return info, true, nil
})
}
// SetError sets the error to changefeed
func (s *ChangefeedReactorState) SetError(lastError *model.RunningError) {
s.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
if info == nil {
return nil, false, nil
}
info.Error = lastError
return info, true, nil
})
}
// RemoveChangefeed removes the changefeed and clean the information and status.
func (s *ChangefeedReactorState) RemoveChangefeed() {
// remove info
s.PatchInfo(func(info *model.ChangeFeedInfo) (
*model.ChangeFeedInfo, bool, error,
) {
return nil, true, nil
})
// remove changefeedStatus
s.PatchStatus(
func(status *model.ChangeFeedStatus) (
*model.ChangeFeedStatus, bool, error,
) {
return nil, true, nil
})
}
// ResumeChnagefeed resumes the changefeed and set the checkpoint ts.
func (s *ChangefeedReactorState) ResumeChnagefeed(overwriteCheckpointTs uint64) {
s.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
changed := false
if info == nil {
return nil, changed, nil
}
if overwriteCheckpointTs > 0 {
info.StartTs = overwriteCheckpointTs
changed = true
}
if info.Error != nil {
info.Error = nil
changed = true
}
return info, changed, nil
})
s.PatchStatus(func(status *model.ChangeFeedStatus) (
*model.ChangeFeedStatus, bool, error,
) {
if overwriteCheckpointTs > 0 {
oldCheckpointTs := status.CheckpointTs
status = &model.ChangeFeedStatus{
CheckpointTs: overwriteCheckpointTs,
MinTableBarrierTs: overwriteCheckpointTs,
AdminJobType: model.AdminNone,
}
log.Info("overwriting the tableCheckpoint ts",
zap.String("namespace", s.ID.Namespace),
zap.String("changefeed", s.ID.ID),
zap.Any("oldCheckpointTs", oldCheckpointTs),
zap.Any("newCheckpointTs", status.CheckpointTs),
)
return status, true, nil
}
return status, false, nil
})
}
// TakeProcessorErrors reuturns the error of the changefeed and clean the error.
func (s *ChangefeedReactorState) TakeProcessorErrors() []*model.RunningError {
var runningErrors map[string]*model.RunningError
for captureID, position := range s.TaskPositions {
if position.Error != nil {
if runningErrors == nil {
runningErrors = make(map[string]*model.RunningError)
}
runningErrors[position.Error.Code] = position.Error
log.Error("processor reports an error",
zap.String("namespace", s.ID.Namespace),
zap.String("changefeed", s.ID.ID),
zap.String("captureID", captureID),
zap.Any("error", position.Error))
s.PatchTaskPosition(captureID, func(position *model.TaskPosition) (*model.TaskPosition, bool, error) {
if position == nil {
return nil, false, nil
}
position.Error = nil
return position, true, nil
})
}
}
if runningErrors == nil {
return nil
}
result := make([]*model.RunningError, 0, len(runningErrors))
for _, err := range runningErrors {
result = append(result, err)
}
return result
}
// TakeProcessorWarnings reuturns the warning of the changefeed and clean the warning.
func (s *ChangefeedReactorState) TakeProcessorWarnings() []*model.RunningError {
var runningWarnings map[string]*model.RunningError
for captureID, position := range s.TaskPositions {
if position.Warning != nil {
if runningWarnings == nil {
runningWarnings = make(map[string]*model.RunningError)
}
runningWarnings[position.Warning.Code] = position.Warning
log.Warn("processor reports a warning",
zap.String("namespace", s.ID.Namespace),
zap.String("changefeed", s.ID.ID),
zap.String("captureID", captureID),
zap.Any("warning", position.Warning))
s.PatchTaskPosition(captureID, func(position *model.TaskPosition) (*model.TaskPosition, bool, error) {
if position == nil {
return nil, false, nil
}
// set Warning to nil after it has been handled
position.Warning = nil
return position, true, nil
})
}
}
if runningWarnings == nil {
return nil
}
result := make([]*model.RunningError, 0, len(runningWarnings))
for _, err := range runningWarnings {
result = append(result, err)
}
return result
}
// CleanUpTaskPositions removes the task positions of the changefeed.
func (s *ChangefeedReactorState) CleanUpTaskPositions() {
for captureID := range s.TaskPositions {
s.PatchTaskPosition(captureID, func(position *model.TaskPosition) (*model.TaskPosition, bool, error) {
return nil, true, nil
})
}
}
// UpdateChangefeedState returns the task status of the changefeed.
func (s *ChangefeedReactorState) UpdateChangefeedState(feedState model.FeedState,
adminJobType model.AdminJobType,
epoch uint64,
) {
s.PatchStatus(func(status *model.ChangeFeedStatus) (*model.ChangeFeedStatus, bool, error) {
if status == nil {
return status, false, nil
}
if status.AdminJobType != adminJobType {
status.AdminJobType = adminJobType
return status, true, nil
}
return status, false, nil
})
s.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
changed := false
if info == nil {
return nil, changed, nil
}
if info.State != feedState {
info.State = feedState
changed = true
}
if info.AdminJobType != adminJobType {
info.AdminJobType = adminJobType
changed = true
if epoch > 0 {
previous := info.Epoch
info.Epoch = epoch
log.Info("update changefeed epoch",
zap.String("namespace", s.ID.Namespace),
zap.String("changefeed", s.ID.ID),
zap.Uint64("perviousEpoch", previous),
zap.Uint64("currentEpoch", info.Epoch))
}
}
return info, changed, nil
})
}
// UpdatePendingChange implements the ReactorState interface
func (s *ChangefeedReactorState) UpdatePendingChange() {
}
// Update implements the ReactorState interface
func (s *ChangefeedReactorState) Update(key util.EtcdKey, value []byte, _ bool) error {
k := new(etcd.CDCKey)
if err := k.Parse(s.ClusterID, key.String()); err != nil {
return errors.Trace(err)
}
if err := s.UpdateCDCKey(k, value); err != nil {
log.Error("failed to update status", zap.String("key", key.String()), zap.ByteString("value", value))
return errors.Trace(err)
}
return nil
}
// UpdateCDCKey updates the state by a parsed etcd key
func (s *ChangefeedReactorState) UpdateCDCKey(key *etcd.CDCKey, value []byte) error {
var e interface{}
switch key.Tp {
case etcd.CDCKeyTypeChangefeedInfo:
if key.ChangefeedID != s.ID {
return nil
}
if value == nil {
s.Info = nil
return nil
}
s.Info = new(model.ChangeFeedInfo)
e = s.Info
case etcd.CDCKeyTypeChangeFeedStatus:
if key.ChangefeedID != s.ID {
return nil
}
if value == nil {
s.Status = nil
return nil
}
s.Status = new(model.ChangeFeedStatus)
e = s.Status
case etcd.CDCKeyTypeTaskPosition:
if key.ChangefeedID != s.ID {
return nil
}
if value == nil {
delete(s.TaskPositions, key.CaptureID)
return nil
}
position := new(model.TaskPosition)
s.TaskPositions[key.CaptureID] = position
e = position
default:
return nil
}
if err := json.Unmarshal(value, e); err != nil {
return errors.Trace(err)
}
if key.Tp == etcd.CDCKeyTypeChangefeedInfo {
s.Info.VerifyAndComplete()
}
return nil
}
// Exist returns false if all keys of this changefeed in ETCD is not exist
func (s *ChangefeedReactorState) Exist() bool {
return s.Info != nil || s.Status != nil || len(s.TaskPositions) != 0
}
// Active return true if the changefeed is ready to be processed
func (s *ChangefeedReactorState) Active(captureID model.CaptureID) bool {
return s.Info != nil && s.Status != nil && s.Status.AdminJobType == model.AdminNone
}
// GetPatches implements the ReactorState interface
func (s *ChangefeedReactorState) GetPatches() [][]DataPatch {
return [][]DataPatch{s.getPatches()}
}
func (s *ChangefeedReactorState) getPatches() []DataPatch {
pendingPatches := s.pendingPatches
s.pendingPatches = nil
return pendingPatches
}
// CheckCaptureAlive checks if the capture is alive, if the capture offline,
// the etcd worker will exit and throw the ErrLeaseExpired error.
func (s *ChangefeedReactorState) CheckCaptureAlive(captureID model.CaptureID) {
k := etcd.CDCKey{
ClusterID: s.ClusterID,
Tp: etcd.CDCKeyTypeCapture,
CaptureID: captureID,
}
key := k.String()
patch := &SingleDataPatch{
Key: util.NewEtcdKey(key),
Func: func(v []byte) ([]byte, bool, error) {
// If v is empty, it means that the key-value pair of capture info is not exist.
// The key-value pair of capture info is written with lease,
// so if the capture info is not exist, the lease is expired
if len(v) == 0 {
return v, false, cerrors.ErrLeaseExpired.GenWithStackByArgs()
}
return v, false, nil
},
}
s.pendingPatches = append(s.pendingPatches, patch)
}
// CheckChangefeedNormal checks if the changefeed state is runnable,
// if the changefeed status is not runnable, the etcd worker will skip all patch of this tick
// the processor should call this function every tick to make sure the changefeed is runnable
func (s *ChangefeedReactorState) CheckChangefeedNormal() {
s.skipPatchesInThisTick = false
s.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
if info == nil || info.AdminJobType.IsStopState() {
s.skipPatchesInThisTick = true
return info, false, cerrors.ErrEtcdTryAgain.GenWithStackByArgs()
}
return info, false, nil
})
s.PatchStatus(func(status *model.ChangeFeedStatus) (*model.ChangeFeedStatus, bool, error) {
if status == nil {
return status, false, nil
}
if status.AdminJobType.IsStopState() {
s.skipPatchesInThisTick = true
return status, false, cerrors.ErrEtcdTryAgain.GenWithStackByArgs()
}
return status, false, nil
})
}
// PatchInfo appends a DataPatch which can modify the ChangeFeedInfo
func (s *ChangefeedReactorState) PatchInfo(fn func(*model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error)) {
key := &etcd.CDCKey{
ClusterID: s.ClusterID,
Tp: etcd.CDCKeyTypeChangefeedInfo,
ChangefeedID: s.ID,
}
s.patchAny(key.String(), changefeedInfoTPI, func(e interface{}) (interface{}, bool, error) {
// e == nil means that the key is not exist before this patch
if e == nil {
return fn(nil)
}
return fn(e.(*model.ChangeFeedInfo))
})
}
// PatchStatus appends a DataPatch which can modify the ChangeFeedStatus
func (s *ChangefeedReactorState) PatchStatus(fn func(*model.ChangeFeedStatus) (*model.ChangeFeedStatus, bool, error)) {
key := &etcd.CDCKey{
ClusterID: s.ClusterID,
Tp: etcd.CDCKeyTypeChangeFeedStatus,
ChangefeedID: s.ID,
}
s.patchAny(key.String(), changefeedStatusTPI, func(e interface{}) (interface{}, bool, error) {
// e == nil means that the key is not exist before this patch
if e == nil {
return fn(nil)
}
return fn(e.(*model.ChangeFeedStatus))
})
}
// PatchTaskPosition appends a DataPatch which can modify the TaskPosition of a specified capture
func (s *ChangefeedReactorState) PatchTaskPosition(captureID model.CaptureID, fn func(*model.TaskPosition) (*model.TaskPosition, bool, error)) {
key := &etcd.CDCKey{
ClusterID: s.ClusterID,
Tp: etcd.CDCKeyTypeTaskPosition,
CaptureID: captureID,
ChangefeedID: s.ID,
}
s.patchAny(key.String(), taskPositionTPI, func(e interface{}) (interface{}, bool, error) {
// e == nil means that the key is not exist before this patch
if e == nil {
return fn(nil)
}
return fn(e.(*model.TaskPosition))
})
}
var (
taskPositionTPI *model.TaskPosition
changefeedStatusTPI *model.ChangeFeedStatus
changefeedInfoTPI *model.ChangeFeedInfo
)
func (s *ChangefeedReactorState) patchAny(key string, tpi interface{}, fn func(interface{}) (interface{}, bool, error)) {
patch := &SingleDataPatch{
Key: util.NewEtcdKey(key),
Func: func(v []byte) ([]byte, bool, error) {
if s.skipPatchesInThisTick {
return v, false, cerrors.ErrEtcdIgnore.GenWithStackByArgs()
}
var e interface{}
if v != nil {
tp := reflect.TypeOf(tpi)
e = reflect.New(tp.Elem()).Interface()
err := json.Unmarshal(v, e)
if err != nil {
return nil, false, errors.Trace(err)
}
}
ne, changed, err := fn(e)
if err != nil {
return nil, false, errors.Trace(err)
}
if !changed {
return v, false, nil
}
if reflect.ValueOf(ne).IsNil() {
return nil, true, nil
}
nv, err := json.Marshal(ne)
if err != nil {
return nil, false, errors.Trace(err)
}
return nv, true, nil
},
}
s.pendingPatches = append(s.pendingPatches, patch)
}