Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "abort lock table when tn restart (#20915)" #20981

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions pkg/lockservice/lock_table_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,12 @@ func (l *lockTableAllocator) Get(
return l.registerBind(binds, group, tableID, originTableID, sharding)
}

func (l *lockTableAllocator) KeepLockTableBind(
serviceID string,
version uint64,
) bool {
func (l *lockTableAllocator) KeepLockTableBind(serviceID string) bool {
b := l.getServiceBinds(serviceID)
if b == nil {
return false
}
return b.active() && (version == 0 || version == l.version)
return b.active()
}

func (l *lockTableAllocator) AddCannotCommit(values []pb.OrphanTxn) [][]byte {
Expand Down Expand Up @@ -838,16 +835,12 @@ func (l *lockTableAllocator) handleKeepLockTableBind(
req *pb.Request,
resp *pb.Response,
cs morpc.ClientSession) {
resp.KeepLockTableBind.OK = l.KeepLockTableBind(
req.KeepLockTableBind.ServiceID,
req.KeepLockTableBind.Version,
)
resp.KeepLockTableBind.OK = l.KeepLockTableBind(req.KeepLockTableBind.ServiceID)
if !resp.KeepLockTableBind.OK {
// resp.KeepLockTableBind.Status = pb.Status_ServiceCanRestart
writeResponse(l.logger, cancel, resp, nil, cs)
return
}
resp.KeepLockTableBind.Version = l.version
b := l.getServiceBinds(req.KeepLockTableBind.ServiceID)
if b.isStatus(pb.Status_ServiceLockEnable) {
if req.KeepLockTableBind.Status != pb.Status_ServiceLockEnable {
Expand Down
4 changes: 1 addition & 3 deletions pkg/lockservice/lock_table_allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ func TestKeepaliveBind(t *testing.T) {
time.Sleep(time.Millisecond * 20)
}

assert.True(t, a.KeepLockTableBind("s1", 0))

assert.False(t, a.KeepLockTableBind("s1", 1))
assert.True(t, a.KeepLockTableBind("s1"))
})
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/lockservice/lock_table_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ func (k *lockTableKeeper) doKeepLockTableBind(ctx context.Context) {
req.Method = pb.Method_KeepLockTableBind
req.KeepLockTableBind.ServiceID = k.serviceID
req.KeepLockTableBind.Status = k.service.getStatus()
req.KeepLockTableBind.Version = k.service.tnVersion
if !k.service.isStatus(pb.Status_ServiceLockEnable) {
req.KeepLockTableBind.LockTables = k.service.topGroupTables()
req.KeepLockTableBind.TxnIDs = k.service.activeTxnHolder.getAllTxnID()
Expand All @@ -201,7 +200,6 @@ func (k *lockTableKeeper) doKeepLockTableBind(ctx context.Context) {
defer releaseResponse(resp)

if resp.KeepLockTableBind.OK {
k.service.tnVersion = resp.KeepLockTableBind.Version
switch resp.KeepLockTableBind.Status {
case pb.Status_ServiceLockEnable:
if !k.service.isStatus(pb.Status_ServiceLockEnable) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/lockservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ type service struct {
stopOnce sync.Once
fetchWhoWaitingListC chan who
logger *log.MOLogger
tnVersion uint64

remote struct {
client Client
Expand Down Expand Up @@ -97,7 +96,6 @@ func NewLockService(
stopper.WithLogger(getLogger(cfg.ServiceID).RawLogger())),
fetchWhoWaitingListC: make(chan who, 10240),
logger: getLogger(cfg.ServiceID),
tnVersion: 0,
}

for _, opt := range opts {
Expand Down
2 changes: 1 addition & 1 deletion pkg/lockservice/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ type LockTableAllocator interface {
// KeepLockTableBind once a cn is bound to a Table, a heartbeat needs to be sent
// periodically to keep the binding in place. If no heartbeat is sent for a long
// period of time to maintain the binding, the binding will become invalid.
KeepLockTableBind(serviceID string, version uint64) bool
KeepLockTableBind(serviceID string) bool
// Valid check for changes in the binding relationship of a specific lock-table.
Valid(serviceID string, txnID []byte, binds []pb.LockTable) ([]uint64, error)
// AddCannotCommit add cannot commit txn.
Expand Down
Loading
Loading