Skip to content
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

bug: options for storage and log streams can be messed up #262

Closed
ijsong opened this issue Dec 10, 2022 · 0 comments · Fixed by #263 or #259
Closed

bug: options for storage and log streams can be messed up #262

ijsong opened this issue Dec 10, 2022 · 0 comments · Fixed by #263 or #259
Assignees
Labels
bug Something isn't working

Comments

@ijsong
Copy link
Member

ijsong commented Dec 10, 2022

LogStreamReplicas are initiated concurrently, like below.

g.Go(func() error {
_, err := sn.runLogStreamReplica(context.Background(), dataDir.TopicID, dataDir.LogStreamID, dataDir.String())
return err
})

When creating storage, default options that belong to the storage node are reused. However, it can be buggy when reusing a slice in different goroutines.

stg, err := storage.New(append(
sn.defaultStorageOptions,
storage.WithPath(lsPath),
storage.WithLogger(sn.logger.Named("storage").With(zap.String("path", lsPath))),
)...)

Here is a simple reproducible code:

var common []int

func init() {
	common = make([]int, 0, 5)
	common = append(common, 1)
	common = append(common, 2)
}

func main() {
	var wg sync.WaitGroup
	wg.Add(2)
	go func() {
		defer wg.Done()
		fmt.Printf("%+v", append(common, 11, 12))
	}()
	go func() {
		defer wg.Done()
		fmt.Printf("%+v", append(common, 21, 22))
	}()
	wg.Wait()
}

// [1 2 11 12][1 2 11 12]
@ijsong ijsong added the bug Something isn't working label Dec 10, 2022
@ijsong ijsong self-assigned this Dec 10, 2022
ijsong added a commit to ijsong/varlog that referenced this issue Dec 10, 2022
…ecutor

This patch fixed concurrency bugs in the storage setting and executor setting. Issue kakao#262 describes
it concretely.

Resolves kakao#262
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant