-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implement WriteAheadLog #640
Conversation
@masih @Stebalien I would appriciate a light review of the WAL itself, integration is incoming after I fix some issues in it. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #640 +/- ##
=======================================
Coverage ? 79.25%
=======================================
Files ? 54
Lines ? 4878
Branches ? 0
=======================================
Hits ? 3866
Misses ? 635
Partials ? 377
|
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Co-authored-by: Masih H. Derkani <m@derkani.org> Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
internal/writeaheadlog/wal.go
Outdated
|
||
err := wal.hydrate() | ||
if err != nil { | ||
return nil, fmt.Errorf("reading the WAL: %v", err) |
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.
Might as well wrap error?
return nil, fmt.Errorf("reading the WAL: %v", err) | |
return nil, fmt.Errorf("reading the WAL: %w", err) |
internal/writeaheadlog/wal.go
Outdated
} | ||
|
||
type logStat struct { | ||
logname string |
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.
Either name
or logName
?
logname string | |
logName string |
internal/writeaheadlog/wal.go
Outdated
return nil | ||
} | ||
|
||
const walExtension = ".wal.cbor" |
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.
Subjective: Would be easier to read if all constants are grouped at the top.
internal/writeaheadlog/wal.go
Outdated
return nil | ||
} | ||
|
||
const roatateAt = 1 << 20 // 1MiB |
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.
const roatateAt = 1 << 20 // 1MiB | |
const rotateAt = 1 << 20 // 1MiB |
internal/writeaheadlog/wal.go
Outdated
} | ||
|
||
// Purge removes files containing entries only older than keepEpoch | ||
// It is not guarnateed to remove all entries older than keepEpoch as it will keep the current |
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.
// It is not guarnateed to remove all entries older than keepEpoch as it will keep the current | |
// It is not guaranteed to remove all entries older than keepEpoch as it will keep the current |
internal/writeaheadlog/wal.go
Outdated
|
||
switch { | ||
case err == nil: | ||
// the EOF case is expected, this is slightly unexpected by still handle it |
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 EOF case is expected, this is slightly unexpected by still handle it | |
// the EOF case is expected, this is slightly unexpected but still handle it |
internal/writeaheadlog/wal.go
Outdated
func (wal *WriteAheadLog[T, PT]) readLogFile(logname string, keepVaues bool) (logStat, []T, error) { | ||
var res logStat | ||
if len(logname) == 0 { | ||
return res, nil, fmt.Errorf("empty logname") |
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.
return res, nil, fmt.Errorf("empty logname") | |
return res, nil, errors.New("empty logname") |
@@ -0,0 +1,177 @@ | |||
package writeaheadlog |
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.
Would be sweet to have a concurrency stress test.
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Pushing the first commit with complete implementation of WAL for peliminary review.
Integration in progress.