-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
[nbs] background thread writes index records #7885
Conversation
#benchmark |
@max-hoffman DOLT
|
#benchmark |
@max-hoffman DOLT
|
@max-hoffman DOLT
|
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.
A few comments, generally looks sane but I would approach is slightly different in the details in a few places.
go/store/nbs/journal_writer.go
Outdated
@@ -94,11 +96,22 @@ func openJournalWriter(ctx context.Context, path string) (wr *journalWriter, exi | |||
return nil, true, err | |||
} | |||
|
|||
return &journalWriter{ | |||
sendEg, ctx := errgroup.WithContext(ctx) | |||
recvEg, ctx := errgroup.WithContext(ctx) |
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.
This seems like a weird lifecycle change for the ctx
that gets passed here. All of the sudden this context
needs to be valid for the entire duration of the journalWriter
, instead of just for the duration of this call...
go/store/nbs/journal_writer.go
Outdated
wr.sendEg.Go(func() error { | ||
select { | ||
case wr.indexCh <- r: | ||
} | ||
return nil | ||
}) |
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.
Sending these async with unbounded concurrency seems a step too far...what's the point of not enqueuing it onto the buffered channel directly?
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.
blocking on buffered channel is better? i wasn't really sure, the cleanup that way is definitely easier
go/store/nbs/journal_writer.go
Outdated
err = writeIndexLookup(wr.indexWriter, l) | ||
case lookupMeta: | ||
l.checkSum = wr.batchCrc | ||
wr.batchCrc = 0 |
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.
Can this become a local variable of this goroutine func? If not, where else is accessing it and why its current access from that place threadsafe?
go/store/nbs/journal_writer.go
Outdated
if err != nil { | ||
return 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.
There seems to a problem with the error handling and communication here. Before this change, an error writing the index would cause the write call to report an error. Now, this write call and future write calls will not report an error, and we will not see an error at Close() as currently written either. Which is, maybe fine, but we will also stop reading from indexChan
, and that does not seem fine, since the write path expects to be able to write to indexChan
.
You've already taken the write lock on the sender side. An easy way forward is to just set indexChan
to nil and report the error in a shared variable indexWriteErr
and make future writes return that thing? Potentially restart the goroutine on a future write if you want to get back the old semantics?
@max-hoffman DOLT
|
@max-hoffman DOLT
|
@max-hoffman DOLT
|
@max-hoffman DOLT
|
@max-hoffman DOLT
|
Additional work is required for integration with DoltgreSQL. |
Additional work is required for integration with DoltgreSQL. |
@max-hoffman DOLT
|
#benchmark |
Additional work is required for integration with DoltgreSQL. |
@max-hoffman DOLT
|
@max-hoffman DOLT
|
#benchmark |
@max-hoffman DOLT
|
@max-hoffman DOLT
|
@max-hoffman DOLT
|
This uses a buffered channel to avoid blocking on indexLookup writes. The main side effect is that lookups can be out of order.