Files
zapdb/y/error.go
Manish R Jain fad98504c0 Refactor compaction logic, improve logging.
Refactor compaction logic to be in-line with how RocksDB does things.
This refactoring now allows multiple compactions to happen
simultaneously, even at the same level; ensuring that the ranges being
compacted are not overlapping.

We no longer ask for verbosity of output, because all logging has now
been switched over to trace package. We use trace.Trace for compactions,
and trace.EventLog for KV and ValueLog.

The following is a log of all the individual commits.

commit 746c5118a3463483ccb41126d34a7bf35a19c686
Author: Manish R Jain <[email protected]>
Date:   Tue Jun 6 15:43:07 2017 +1000

    Address comments

commit 3957d6b5d2b39b93fcd901b45ae09c5d2d04752c
Author: Manish R Jain <[email protected]>
Date:   Tue Jun 6 15:29:01 2017 +1000

    Keep more events per compaction

commit e79c87f0502a6bd2ad0ba48c162d47a71e05e9e3
Author: Manish R Jain <[email protected]>
Date:   Tue Jun 6 15:22:11 2017 +1000

    Remove y.Printf entirely, along with verbose mode. All logging is done via event log and tracing.

commit b0452d8c1bdd511a7bb088489637a7da035acfaa
Author: Manish R Jain <[email protected]>
Date:   Tue Jun 6 15:04:47 2017 +1000

    Move compaction logs entirely to tracer

commit 28bb7cfeec1fbf59301428845cb9aa14d15cb94e
Author: Manish R Jain <[email protected]>
Date:   Tue Jun 6 04:53:26 2017 +0000

    Use tracers for each compaction.

commit 71462ceaa433b9d96bab267101f4df560afa7ef5
Author: Manish R Jain <[email protected]>
Date:   Tue Jun 6 11:08:17 2017 +1000

    Switch compactions to trace.Trace

commit c982b4ec81710b7ab1cbc389800a379a59ceb92b
Author: Manish R Jain <[email protected]>
Date:   Mon Jun 5 09:58:52 2017 +0000

    Move stuff to elog

commit f1883fc5594e979803cb4b9639d20bb698ad2fae
Author: Manish R Jain <[email protected]>
Date:   Fri Jun 2 19:31:41 2017 +1000

    Move compaction logs to event log

commit e86865802929e6fc996fb04f3bb8a9995a6b85fe
Author: Manish R Jain <[email protected]>
Date:   Fri Jun 2 16:21:12 2017 +1000

    Double check in compareandadd if we really need a compactino.

commit a4cf25515249188c5a16b60648b909a2cc61629c
Author: Manish R Jain <[email protected]>
Date:   Fri Jun 2 16:09:09 2017 +1000

    Try other levels if can't run compaction.

commit 3f34dca250f612557d8e17337bf5efec73c4214f
Author: Manish R Jain <[email protected]>
Date:   Thu Jun 1 18:40:38 2017 +1000

    Keep track of tables being currently compacted.

commit e9c895a64a7e942aef53300b2f605bfd91c859b9
Author: Manish R Jain <[email protected]>
Date:   Thu Jun 1 18:23:22 2017 +1000

    Run 3 compactors simultaneously

commit 9e3dfc101ac9dfb644b36d13a026062d178effe5
Author: Manish R Jain <[email protected]>
Date:   Thu Jun 1 13:52:53 2017 +1000

    Kinda works with compaction using key ranges to determine overlap.

commit c767a55ab9b30c55c0eda10e6606460bf5bac317
Author: Manish R Jain <[email protected]>
Date:   Wed May 31 19:47:09 2017 +1000

    Allow multiple compactions to happen concurrently.
2017-06-06 15:56:25 +10:00

84 lines
2.4 KiB
Go

/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* 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 y
// This file contains some functions for error handling. Note that we are moving
// towards using x.Trace, i.e., rpc tracing using net/tracer. But for now, these
// functions are useful for simple checks logged on one machine.
// Some common use cases are:
// (1) You receive an error from external lib, and would like to check/log fatal.
// For this, use x.Check, x.Checkf. These will check for err != nil, which is
// more common in Go. If you want to check for boolean being true, use
// x.Assert, x.Assertf.
// (2) You receive an error from external lib, and would like to pass on with some
// stack trace information. In this case, use x.Wrap or x.Wrapf.
// (3) You want to generate a new error with stack trace info. Use x.Errorf.
import (
"fmt"
"log"
"github.com/pkg/errors"
)
var debugMode = true
// Check logs fatal if err != nil.
func Check(err error) {
if err != nil {
log.Fatalf("%+v", Wrap(err))
}
}
// Check2 acts as convenience wrapper around Check, using the 2nd argument as error.
func Check2(_ interface{}, err error) {
Check(err)
}
// AssertTrue asserts that b is true. Otherwise, it would log fatal.
func AssertTrue(b bool) {
if !b {
log.Fatalf("%+v", errors.Errorf("Assert failed"))
}
}
// AssertTruef is AssertTrue with extra info.
func AssertTruef(b bool, format string, args ...interface{}) {
if !b {
log.Fatalf("%+v", errors.Errorf(format, args...))
}
}
// Wrap wraps errors from external lib.
func Wrap(err error) error {
if !debugMode {
return err
}
return errors.Wrap(err, "")
}
// Wrapf is Wrap with extra info.
func Wrapf(err error, format string, args ...interface{}) error {
if !debugMode {
if err == nil {
return nil
}
return fmt.Errorf(format+" error: %+v", append(args, err)...)
}
return errors.Wrapf(err, format, args...)
}