Commit b58a6bc1 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ae6f3414
......@@ -379,7 +379,7 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (data []byte, serial zo
c.node.StateMu.RUnlock()
if len(storv) == 0 {
// XXX recheck it adds traceback to log
// XXX recheck it adds traceback to log -> XXX it does not -> add our Bugf which always forces +v on such error print
return nil, 0, errors.Errorf("internal inconsistency: cluster is operational, but no storages alive for oid %v", xid.Oid)
}
......
......@@ -347,6 +347,7 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
// FIXME hack - better it be separate command and handled cleanly
if nodeInfo.State == DOWN {
log.Info(ctx, "master told us to shutdown")
log.Flush()
os.Exit(1)
}
}
......
......@@ -241,7 +241,7 @@ bench1() {
echo "(skipping zsha1.go on ZEO -- Cgo does not support zeo:// protocol)"
return
fi
go run zsha1.go $url
go run zsha1.go --log_dir=$log $url
# TODO zsha1.go -prefetch=1
}
......
......@@ -6,12 +6,15 @@ package main
import (
"context"
"crypto/sha1"
"log"
"flag"
"fmt"
//"os"
"time"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/xcommon/log"
"lab.nexedi.com/kirr/neo/go/xcommon/task"
"lab.nexedi.com/kirr/neo/go/zodb"
_ "lab.nexedi.com/kirr/neo/go/zodb/wks"
......@@ -19,18 +22,32 @@ import (
)
func main() {
defer log.Flush()
flag.Parse()
url := flag.Args()[0] // XXX dirty
bg := context.Background()
stor, err := zodb.OpenStorageURL(bg, url)
ctx := context.Background()
err := zsha1(ctx, url)
if err != nil {
log.Fatal(err)
log.Fatal(ctx, err)
}
}
lastTid, err := stor.LastTid(bg)
func zsha1(ctx context.Context, url string) (err error) {
defer task.Running(&ctx, "zsha1")(&err)
stor, err := zodb.OpenStorageURL(ctx, url)
if err != nil {
log.Fatal(err)
return err
}
defer func() {
err2 := stor.Close()
err = xerr.First(err, err2)
}()
lastTid, err := stor.LastTid(ctx)
if err != nil {
return err
}
before := lastTid + 1 // XXX overflow ?
......@@ -46,14 +63,14 @@ func main() {
loop:
for {
xid := zodb.Xid{Oid: oid, XTid: zodb.XTid{Tid: before, TidBefore: true}}
data, _, err := stor.Load(bg, xid)
data, _, err := stor.Load(ctx, xid)
switch err.(type) {
case nil:
// ok
case *zodb.ErrOidMissing:
break loop
default:
log.Fatal(err)
return err
}
m.Write(data)
......@@ -70,4 +87,6 @@ loop:
fmt.Printf("%x ; oid=0..%d nread=%d t=%s (%s / object) x=zsha1.go\n",
m.Sum(nil), oid-1, nread, δt, δt / time.Duration(oid)) // XXX /oid cast ?
return nil
}
......@@ -74,6 +74,7 @@ func (d Depth) Warning(ctx context.Context, argv ...interface{}) {
func (d Depth) Warningf(ctx context.Context, format string, argv ...interface{}) {
glog.WarningDepth(int(d+1), withTask(ctx, fmt.Sprintf(format, argv...))...)
}
func (d Depth) Error(ctx context.Context, argv ...interface{}) {
glog.ErrorDepth(int(d+1), withTask(ctx, argv...)...)
}
......@@ -82,11 +83,19 @@ func (d Depth) Errorf(ctx context.Context, format string, argv ...interface{}) {
glog.ErrorDepth(int(d+1), withTask(ctx, fmt.Sprintf(format, argv...))...)
}
func (d Depth) Fatal(ctx context.Context, argv ...interface{}) {
glog.FatalDepth(int(d+1), withTask(ctx, argv...)...)
}
func (d Depth) Fatalf(ctx context.Context, format string, argv ...interface{}) {
glog.FatalDepth(int(d+1), withTask(ctx, fmt.Sprintf(format, argv...))...)
}
func Info(ctx context.Context, argv ...interface{}) { Depth(1).Info(ctx, argv...) }
func Warning(ctx context.Context, argv ...interface{}) { Depth(1).Warning(ctx, argv...) }
func Error(ctx context.Context, argv ...interface{}) { Depth(1).Error(ctx, argv...) }
func Fatal(ctx context.Context, argv ...interface{}) { Depth(1).Fatal(ctx, argv...) }
func Infof(ctx context.Context, format string, argv ...interface{}) {
Depth(1).Infof(ctx, format, argv...)
......@@ -99,3 +108,9 @@ func Warningf(ctx context.Context, format string, argv ...interface{}) {
func Errorf(ctx context.Context, format string, argv ...interface{}) {
Depth(1).Errorf(ctx, format, argv...)
}
func Fatalf(ctx context.Context, format string, argv ...interface{}) {
Depth(1).Fatalf(ctx, format, argv...)
}
func Flush() { glog.Flush() }
......@@ -28,6 +28,8 @@ import (
"os"
"runtime"
"runtime/pprof"
//"lab.nexedi.com/kirr/neo/go/xcommon/log"
)
// Command describes one zodb subcommand
......@@ -109,6 +111,7 @@ func (prog *MainProg) Main() {
defer func() {
r := recover()
if e, _ := r.(*programExit); e != nil {
// TODO log.Flush()
os.Exit(e.code)
}
if r != nil {
......@@ -275,4 +278,6 @@ const helpOptions =
-cpuprofile <file> write cpu profile to <file>
-memprofile <file> write memory profile to <file>
TODO also document glog options
`
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment