Skip to content

Commit

Permalink
add tx.ID() in log. Change the position of log. If we call tx.ID() be…
Browse files Browse the repository at this point in the history
…fore testing the nullity of tx.db, it may panic.

Signed-off-by: caojiamingalan <[email protected]>
  • Loading branch information
CaojiamingAlan authored and Elbehery committed Nov 27, 2023
1 parent 7d93161 commit 5ce15f0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
17 changes: 0 additions & 17 deletions logger.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5ce15f0

Please sign in to comment.