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

cdc: avoid deadlock on error in pubsub sink #88289

Merged
merged 1 commit into from
Sep 27, 2022

Conversation

HonoreDB
Copy link
Contributor

#88130 introduced a deadlock when an attempt to create a
topic fails -- the goroutine tries to acquire a lock in order to record the error, but it already has it in order to write to the map. This PR releases the lock while creating the topic, which should also help with performance a bit on startup.

Fixes #85374

Release note (bug fix): Fixed a bug preventing pubsub changefeeds from retrying.

@HonoreDB HonoreDB requested a review from a team as a code owner September 20, 2022 20:01
@HonoreDB HonoreDB requested review from shermanCRL and removed request for a team September 20, 2022 20:01
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@HonoreDB HonoreDB requested a review from miretskiy September 20, 2022 20:02
Copy link
Contributor

@miretskiy miretskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @HonoreDB and @shermanCRL)


pkg/ccl/changefeedccl/sink_pubsub.go line 362 at r1 (raw file):

	}
	p.mu.Unlock() // openTopic may need the lock to record an error
	topic, err := p.openTopic(name)

openTopic seems to only be called from this function and record error is only called from openTopic; why not just rename openTopic to openTopicLocked (and possible recordError to recordErrorLocked)?

@HonoreDB HonoreDB force-pushed the fix_deadlock_on_autocreate_error branch from c46a9d0 to 4a3f357 Compare September 21, 2022 14:45
cockroachdb#88130
introduced a deadlock when an attempt to create a
topic fails -- the goroutine tries to acquire a lock
in order to record the error, but it already has it
in order to write to the map. This PR releases the lock
while creating the topic, which should also help with
performance a bit on startup.

Release note (bug fix): Fixed a bug preventing pubsub changefeeds from retrying.
@HonoreDB HonoreDB force-pushed the fix_deadlock_on_autocreate_error branch from 4a3f357 to 00a4abe Compare September 21, 2022 20:54
Copy link
Contributor Author

@HonoreDB HonoreDB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @miretskiy and @shermanCRL)


pkg/ccl/changefeedccl/sink_pubsub.go line 362 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

openTopic seems to only be called from this function and record error is only called from openTopic; why not just rename openTopic to openTopicLocked (and possible recordError to recordErrorLocked)?

Done.

@HonoreDB
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 27, 2022

Build succeeded:

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

Successfully merging this pull request may close these issues.

roachtest: cdc/pubsub-sink/assume-role failed
3 participants