Skip to content

Commit

Permalink
fix race condition during WriteStop
Browse files Browse the repository at this point in the history
  • Loading branch information
hangxie committed Sep 17, 2023
1 parent 3307673 commit d4e7281
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ func (pw *ParquetWriter) flushObjs() error {
defer func() {
wg.Done()
if r := recover(); r != nil {
lock.Lock()
switch x := r.(type) {
case string:
errs[index] = errors.New(x)
Expand All @@ -298,6 +299,7 @@ func (pw *ParquetWriter) flushObjs() error {
default:
errs[index] = errors.New("unknown error")
}
lock.Unlock()
}
}()

Expand Down Expand Up @@ -338,12 +340,14 @@ func (pw *ParquetWriter) flushObjs() error {

wg.Wait()

lock.Lock()
for _, err2 := range errs {
if err2 != nil {
err = err2
break
}
}
lock.Unlock()

for _, pagesMap := range pagesMapList {
for name, pages := range pagesMap {
Expand Down

0 comments on commit d4e7281

Please sign in to comment.