From 5ce15f0a8ac73512c5eac76a45d4d9c4a1fc192f Mon Sep 17 00:00:00 2001 From: caojiamingalan Date: Thu, 25 May 2023 21:37:14 -0500 Subject: [PATCH] add tx.ID() in log. Change the position of log. If we call tx.ID() before testing the nullity of tx.db, it may panic. Signed-off-by: caojiamingalan --- logger.go | 17 ----------------- tx.go | 2 +- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/logger.go b/logger.go index 29418aba8..d27b26081 100644 --- a/logger.go +++ b/logger.go @@ -1,17 +1,3 @@ -// Copyright 2015 The etcd Authors -// -// 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, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package bbolt import ( @@ -43,14 +29,11 @@ type Logger interface { } func getDiscardLogger() Logger { - bboltLoggerMu.Lock() - defer bboltLoggerMu.Unlock() return discardLogger } var ( discardLogger = &DefaultLogger{Logger: log.New(io.Discard, "", 0)} - bboltLoggerMu sync.Mutex ) const ( diff --git a/tx.go b/tx.go index a71dc06d4..f6cebf720 100644 --- a/tx.go +++ b/tx.go @@ -145,13 +145,13 @@ func (tx *Tx) OnCommit(fn func()) { // called on a read-only transaction. func (tx *Tx) Commit() error { common.Assert(!tx.managed, "managed tx commit not allowed") - tx.Logger.Debugf("committing tx") if tx.db == nil { return berrors.ErrTxClosed } else if !tx.writable { return berrors.ErrTxNotWritable } + tx.Logger.Infof("Committing transaction %d", tx.ID()) // TODO(benbjohnson): Use vectorized I/O to write out dirty pages. // Rebalance nodes which have had deletions.