fix(backend): give each report file a name of its own (closes #61)
check / check (push) Successful in 13s
check / check (push) Successful in 13s
Report files were named by a millisecond timestamp and created with O_EXCL, so two flushes in the same millisecond, such as a flush for size and the final flush at shutdown, got the same name and the second failed, losing its reports. Each name now carries a number after the timestamp that goes up by one for each file the server starts to write, so names still sort by time and never repeat within a run. A failed write uses up its number, leaving a gap if the file could not be created and otherwise a file under that number that may be incomplete. Model: opus-5-5
This commit was merged in pull request #66.
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
package reportbuf
|
||||
|
||||
import "time"
|
||||
|
||||
// Flush writes the buffered reports to a file now, as the periodic
|
||||
// flush does, so tests need not wait a minute for it.
|
||||
func (b *Buffer) Flush() error {
|
||||
return b.flushLocked()
|
||||
}
|
||||
|
||||
// StopClock makes every report file the buffer writes from now on
|
||||
// carry the timestamp at, as if all were written in one millisecond.
|
||||
func (b *Buffer) StopClock(at time.Time) {
|
||||
b.now = func() time.Time { return at }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user