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

client: fix panic caused by too large channel size in pkg/varlog.subscribedLogEntriesQueue #653

Open
Tracked by #461
ijsong opened this issue Dec 5, 2023 · 0 comments

Comments

@ijsong
Copy link
Member

ijsong commented Dec 5, 2023

Subscribe API creates a queue to keep log entries received from each log stream. The queue, subscribedLogEntriesQueue, uses a buffered channel as an MPSC queue. Since its buffer size is as large as the subscribe span length, it can panic if the span is too broad. For example, users can subscribe to log entries without stopping by passing MaxGLSN as an end position of range to the Subscribe API. However, it makes the channel size too large, so panic occurs.

func newSubscribedLogEntiresQueue(begin, end types.GLSN, closer SubscribeCloser, logger *zap.Logger) *subscribedLogEntriesQueue {
q := &subscribedLogEntriesQueue{
c: make(chan client.SubscribeResult, end-begin),
wanted: begin,
end: end,
closer: closer,
logger: logger.Named("subscribed_log_entries_queue"),
}
return q
}

It is essential to ensure that the queue length is not too large, regardless of the subscription range. The queue size should be small enough to avoid wasting memory but not so small that it requires frequent calls to the Subscribe API. We may need to refactor the overall architecture to address this issue.

@ijsong ijsong changed the title fix panic caused by too large channel size in pkg/varlog.subscribedLogEntriesQueue client: fix panic caused by too large channel size in pkg/varlog.subscribedLogEntriesQueue Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant