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 ...@@ -379,7 +379,7 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (data []byte, serial zo
c.node.StateMu.RUnlock() c.node.StateMu.RUnlock()
if len(storv) == 0 { 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) 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 ...@@ -347,6 +347,7 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
// FIXME hack - better it be separate command and handled cleanly // FIXME hack - better it be separate command and handled cleanly
if nodeInfo.State == DOWN { if nodeInfo.State == DOWN {
log.Info(ctx, "master told us to shutdown") log.Info(ctx, "master told us to shutdown")
log.Flush()
os.Exit(1) os.Exit(1)
} }
} }
......
...@@ -241,7 +241,7 @@ bench1() { ...@@ -241,7 +241,7 @@ bench1() {
echo "(skipping zsha1.go on ZEO -- Cgo does not support zeo:// protocol)" echo "(skipping zsha1.go on ZEO -- Cgo does not support zeo:// protocol)"
return return
fi fi
go run zsha1.go $url go run zsha1.go --log_dir=$log $url
# TODO zsha1.go -prefetch=1 # TODO zsha1.go -prefetch=1
} }
......
...@@ -6,12 +6,15 @@ package main ...@@ -6,12 +6,15 @@ package main
import ( import (
"context" "context"
"crypto/sha1" "crypto/sha1"
"log"
"flag" "flag"
"fmt" "fmt"
//"os" //"os"
"time" "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"
_ "lab.nexedi.com/kirr/neo/go/zodb/wks" _ "lab.nexedi.com/kirr/neo/go/zodb/wks"
...@@ -19,18 +22,32 @@ import ( ...@@ -19,18 +22,32 @@ import (
) )
func main() { func main() {
defer log.Flush()
flag.Parse() flag.Parse()
url := flag.Args()[0] // XXX dirty url := flag.Args()[0] // XXX dirty
bg := context.Background() ctx := context.Background()
stor, err := zodb.OpenStorageURL(bg, url) err := zsha1(ctx, url)
if err != nil { 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 { 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 ? before := lastTid + 1 // XXX overflow ?
...@@ -46,14 +63,14 @@ func main() { ...@@ -46,14 +63,14 @@ func main() {
loop: loop:
for { for {
xid := zodb.Xid{Oid: oid, XTid: zodb.XTid{Tid: before, TidBefore: true}} 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) { switch err.(type) {
case nil: case nil:
// ok // ok
case *zodb.ErrOidMissing: case *zodb.ErrOidMissing:
break loop break loop
default: default:
log.Fatal(err) return err
} }
m.Write(data) m.Write(data)
...@@ -70,4 +87,6 @@ loop: ...@@ -70,4 +87,6 @@ loop:
fmt.Printf("%x ; oid=0..%d nread=%d t=%s (%s / object) x=zsha1.go\n", 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 ? 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{}) { ...@@ -74,6 +74,7 @@ func (d Depth) Warning(ctx context.Context, argv ...interface{}) {
func (d Depth) Warningf(ctx context.Context, format string, argv ...interface{}) { func (d Depth) Warningf(ctx context.Context, format string, argv ...interface{}) {
glog.WarningDepth(int(d+1), withTask(ctx, fmt.Sprintf(format, argv...))...) glog.WarningDepth(int(d+1), withTask(ctx, fmt.Sprintf(format, argv...))...)
} }
func (d Depth) Error(ctx context.Context, argv ...interface{}) { func (d Depth) Error(ctx context.Context, argv ...interface{}) {
glog.ErrorDepth(int(d+1), withTask(ctx, argv...)...) glog.ErrorDepth(int(d+1), withTask(ctx, argv...)...)
} }
...@@ -82,11 +83,19 @@ func (d Depth) Errorf(ctx context.Context, format string, argv ...interface{}) { ...@@ -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...))...) 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 Info(ctx context.Context, argv ...interface{}) { Depth(1).Info(ctx, argv...) }
func Warning(ctx context.Context, argv ...interface{}) { Depth(1).Warning(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 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{}) { func Infof(ctx context.Context, format string, argv ...interface{}) {
Depth(1).Infof(ctx, format, argv...) Depth(1).Infof(ctx, format, argv...)
...@@ -99,3 +108,9 @@ func Warningf(ctx context.Context, format string, argv ...interface{}) { ...@@ -99,3 +108,9 @@ func Warningf(ctx context.Context, format string, argv ...interface{}) {
func Errorf(ctx context.Context, format string, argv ...interface{}) { func Errorf(ctx context.Context, format string, argv ...interface{}) {
Depth(1).Errorf(ctx, format, argv...) 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 ( ...@@ -28,6 +28,8 @@ import (
"os" "os"
"runtime" "runtime"
"runtime/pprof" "runtime/pprof"
//"lab.nexedi.com/kirr/neo/go/xcommon/log"
) )
// Command describes one zodb subcommand // Command describes one zodb subcommand
...@@ -109,6 +111,7 @@ func (prog *MainProg) Main() { ...@@ -109,6 +111,7 @@ func (prog *MainProg) Main() {
defer func() { defer func() {
r := recover() r := recover()
if e, _ := r.(*programExit); e != nil { if e, _ := r.(*programExit); e != nil {
// TODO log.Flush()
os.Exit(e.code) os.Exit(e.code)
} }
if r != nil { if r != nil {
...@@ -275,4 +278,6 @@ const helpOptions = ...@@ -275,4 +278,6 @@ const helpOptions =
-cpuprofile <file> write cpu profile to <file> -cpuprofile <file> write cpu profile to <file>
-memprofile <file> write memory 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