Skip to content

[Go] Data race of calling GetToTimeFunc of fixed timestamp data type #38795

Closed

Description

@7phs

Describe the bug, including details regarding any error messages, version, and platform.

Hello,

I found a data race in databricks-sql-go. A root cause of data race is timestamp fields of arrow.FixedWidthTypes and the function GetToTimeFunc() of arrow.TimestampType.

A test to reproduce a data race:

import (
	"sync"
	"testing"

	"github.com/apache/arrow/go/v15/arrow"
)

func TestArrowDataRace(t *testing.T) {
	var (
		wg         sync.WaitGroup
		w          = make(chan bool)
		routineNum = 10
	)

	wg.Add(routineNum)
	for i := 0; i < routineNum; i++ {
		go func() {
			defer wg.Done()

			<-w

			_, _ = arrow.FixedWidthTypes.Timestamp_s.(*arrow.TimestampType).GetToTimeFunc()
		}()
	}

	close(w)

	wg.Wait()
}

A command to run this test with data race detector:

go test -race -run TestArrowDataRace .

A go version is 1.21.

The same issue is in Apache Arrow Go v12.

A root cause of data race is not initialised field loc of arrow.TimestampType. It initialised in the first call of function arrow.TimestampType :: GetZone().

Component(s)

Go

Activity

  1. changed the title [-]Data race of calling `GetToTimeFunc` of fixed timestamp data type[/-] [+][Go] Data race of calling `GetToTimeFunc` of fixed timestamp data type[/+] on Nov 20, 2023
  2. added a commit that references this issue on Nov 20, 2023
  3. added a commit that references this issue on Nov 27, 2023
  4. added this to the 15.0.0 milestone on Nov 27, 2023
  5. added a commit that references this issue on Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions