Skip to content

Commit afe7da6

Browse files
committed
update
Signed-off-by: husharp <jinhao.hu@pingcap.com>
1 parent bd80719 commit afe7da6

File tree

6 files changed

+15
-0
lines changed

6 files changed

+15
-0
lines changed

pkg/cache/ttl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"time"
2020

2121
"github.com/pingcap/log"
22+
"github.com/tikv/pd/pkg/logutil"
2223
"github.com/tikv/pd/pkg/syncutil"
2324
"go.uber.org/zap"
2425
)
@@ -142,6 +143,7 @@ func (c *ttlCache) Clear() {
142143
}
143144

144145
func (c *ttlCache) doGC() {
146+
defer logutil.LogPanic()
145147
ticker := time.NewTicker(c.gcInterval)
146148
defer ticker.Stop()
147149

pkg/systimemon/systimemon.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ import (
2020

2121
"github.com/pingcap/log"
2222
"github.com/tikv/pd/pkg/errs"
23+
"github.com/tikv/pd/pkg/logutil"
2324
"go.uber.org/zap"
2425
)
2526

2627
// StartMonitor calls systimeErrHandler if system time jump backward.
2728
func StartMonitor(ctx context.Context, now func() time.Time, systimeErrHandler func()) {
29+
defer logutil.LogPanic()
2830
log.Info("start system time monitor")
2931
tick := time.NewTicker(100 * time.Millisecond)
3032
defer tick.Stop()

server/election/lease.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/pingcap/log"
2323
"github.com/tikv/pd/pkg/errs"
2424
"github.com/tikv/pd/pkg/etcdutil"
25+
"github.com/tikv/pd/pkg/logutil"
2526
"github.com/tikv/pd/pkg/typeutil"
2627
"go.etcd.io/etcd/clientv3"
2728
"go.uber.org/zap"
@@ -129,6 +130,7 @@ func (l *lease) keepAliveWorker(ctx context.Context, interval time.Duration) <-c
129130
ch := make(chan time.Time)
130131

131132
go func() {
133+
defer logutil.LogPanic()
132134
ticker := time.NewTicker(interval)
133135
defer ticker.Stop()
134136

@@ -137,6 +139,7 @@ func (l *lease) keepAliveWorker(ctx context.Context, interval time.Duration) <-c
137139

138140
for {
139141
go func() {
142+
defer logutil.LogPanic()
140143
start := time.Now()
141144
ctx1, cancel := context.WithTimeout(ctx, l.leaseTimeout)
142145
defer cancel()

server/region_syncer/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/pingcap/log"
2525
"github.com/tikv/pd/pkg/errs"
2626
"github.com/tikv/pd/pkg/grpcutil"
27+
"github.com/tikv/pd/pkg/logutil"
2728
"github.com/tikv/pd/server/core"
2829
"github.com/tikv/pd/server/storage"
2930
"go.uber.org/zap"
@@ -117,6 +118,7 @@ func (s *RegionSyncer) StartSyncWithLeader(addr string) {
117118
ctx := s.mu.clientCtx
118119

119120
go func() {
121+
defer logutil.LogPanic()
120122
defer s.wg.Done()
121123
// used to load region from kv storage to cache storage.
122124
bc := s.server.GetBasicCluster()

server/tso/allocator_manager.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/tikv/pd/pkg/errs"
3232
"github.com/tikv/pd/pkg/etcdutil"
3333
"github.com/tikv/pd/pkg/grpcutil"
34+
"github.com/tikv/pd/pkg/logutil"
3435
"github.com/tikv/pd/pkg/slice"
3536
"github.com/tikv/pd/pkg/syncutil"
3637
"github.com/tikv/pd/server/config"
@@ -361,6 +362,7 @@ func (am *AllocatorManager) getLocalTSOAllocatorPath() string {
361362

362363
// similar logic with leaderLoop in server/server.go
363364
func (am *AllocatorManager) allocatorLeaderLoop(ctx context.Context, allocator *LocalTSOAllocator) {
365+
defer logutil.LogPanic()
364366
defer log.Info("server is closed, return local tso allocator leader loop",
365367
zap.String("dc-location", allocator.GetDCLocation()),
366368
zap.String("local-tso-allocator-name", am.member.Member().Name))
@@ -612,6 +614,7 @@ func (am *AllocatorManager) allocatorUpdater() {
612614

613615
// updateAllocator is used to update the allocator in the group.
614616
func (am *AllocatorManager) updateAllocator(ag *allocatorGroup) {
617+
defer logutil.LogPanic()
615618
defer am.wg.Done()
616619
select {
617620
case <-ag.ctx.Done():
@@ -662,6 +665,7 @@ func (am *AllocatorManager) allocatorPatroller(serverCtx context.Context) {
662665
// ClusterDCLocationChecker collects all dc-locations of a cluster, computes some related info
663666
// and stores them into the DCLocationInfo, then finally writes them into am.mu.clusterDCLocations.
664667
func (am *AllocatorManager) ClusterDCLocationChecker() {
668+
defer logutil.LogPanic()
665669
// Wait for the PD leader to be elected out.
666670
if am.member.GetLeader() == nil {
667671
return

server/tso/global_allocator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/pingcap/kvproto/pkg/pdpb"
2727
"github.com/pingcap/log"
2828
"github.com/tikv/pd/pkg/errs"
29+
"github.com/tikv/pd/pkg/logutil"
2930
"github.com/tikv/pd/pkg/slice"
3031
"github.com/tikv/pd/pkg/tsoutil"
3132
"github.com/tikv/pd/pkg/typeutil"
@@ -338,6 +339,7 @@ func (gta *GlobalTSOAllocator) SyncMaxTS(
338339
// Send SyncMaxTSRequest to all allocator leaders concurrently.
339340
wg.Add(1)
340341
go func(ctx context.Context, conn *grpc.ClientConn, respCh chan<- *syncResp) {
342+
defer logutil.LogPanic()
341343
defer wg.Done()
342344
syncMaxTSResp := &syncResp{}
343345
syncCtx, cancel := context.WithTimeout(ctx, rpcTimeout)

0 commit comments

Comments
 (0)