-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move eventlogs to an http endpoint #1382
Conversation
w.WriteHeader(200) | ||
wnf, errs := newWriteErrNotifier(w) | ||
eventlog.WriterGroup.AddWriter(wnf) | ||
<-errs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these block after the client closes the request? if you get a write error to a closed HTTP connection you also don't see the error. Also, the MirrorWriter
drops them as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cryptix that was intended. I assume that the only error we will encounter is the http connection being closed. The first error encountered will drop the connection from the mirrorwriter, and then this will exit. I could add a default case to the send on the write notifier to ensure that misuse of the code doesnt cause a hang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see. Wasn't sure if there are are other errors. Sorry but I still don't see where the Writer is removed from the mirror.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the MirrorWriter loops over all writes on each write call, any writer that throws an error gets dropped from the list of writers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or rather, any writer that doesnt throw an error is kept around for another write
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaah.. there it is! Glancing over it, I assumed to pushes to messages to the filter but it recreates the writer slice every time.. that seems wasteful to be honest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... the alternative was to keep an array of the items to be removed, wait til the write portion of the call was done, then rebuild the slice sans the dead writers. which was really ugly. I chose <32 bytes worth of wasted memory (on average) per write over ugly code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if worried about perf (which we may be, given that this is per event (and there are lots...), another option is:
// in Write()
// write to all writers, and nil out the broken ones.
for i, w := range mw.writers {
_, err := w.Write(b)
if err != nil {
mw.writers[i] = nil
}
}
// consolidate the slice
for i := 0; i < len(mw.writers); i++ {
if mw.writers[i] != nil {
continue
}
j := len(mw.writers)
for ; j > i; j-- {
if mw.writers[j] != nil {
mw.writers[i], mw.writers[j] = mw.writers[j], nil // swap
break
}
}
mw.writers = mw.writers[:j]
}
seem to work: http://play.golang.org/p/AV9UeZphgq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that works. still a bit more complicated, but it may help.
@whyrusleeping this LGTM. it should have a sharness test case though to make sure it gets mounted correctly and we don't break it. |
@jbenet a test just to make sure theres an endpoint there? It would be rather hard to 'connect for two seconds' in a test, or something like that |
MaxAgeDays: c.Log.MaxAgeDays, | ||
} | ||
eventlog.Configure(eventlog.OutputRotatingLogFile(rotateConf)) | ||
eventlog.Configure(eventlog.Output(eventlog.WriterGroup)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Log config code should be removed then, now or soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. I'll pull that out
for _, w := range mw.writers { | ||
_, err := w.Write(b) | ||
if err == nil { | ||
filter = append(filter, w) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invert if, log and continue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really want to log these errors, worst case, a client connection drops.
@jbenet whats with the swarm and notifications failures happening more often? I don't remember them popping up this much in the past. |
Yeah. if we dont test these things we're bound to have regressions. we have to test everything. Maybe can use the pollEndpoint binary that's already there. or maybe even
not sure, will take a look. IIRC, its timing related. so overloaded machines will fail more often. |
@jbenet this is an odd failure: https://travis-ci.org/ipfs/go-ipfs/jobs/67385491 |
b4d1f6f
to
96e98a8
Compare
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
@whyrusleeping yeah wat. it's totally nil. having hard time repro-ing it... looks like somewhere in the dialing both the conn and err are nil, so the flow doesn't go down. we can guard against it with: multiformats/go-multiaddr-net@b9c1a08 but we should probably get to the bottom of it someday. |
@whyrusleeping thanks LGTM |
move eventlogs to an http endpoint
move eventlogs to an http endpoint This commit was moved from ipfs/kubo@370df8f
This PR makes eventlogs not get written to disk, instead, they are thrown away unless a client is connected to the API endpoint at
/logs
License: MIT
Signed-off-by: Jeromy jeromyj@gmail.com