René's URL Explorer Experiment


Title: [pubsub] Subscriber.stopAsync().awaitTerminated() doesn't wait for all acks to be sent · Issue #3065 · googleapis/google-cloud-java · GitHub

Open Graph Title: [pubsub] Subscriber.stopAsync().awaitTerminated() doesn't wait for all acks to be sent · Issue #3065 · googleapis/google-cloud-java

X Title: [pubsub] Subscriber.stopAsync().awaitTerminated() doesn't wait for all acks to be sent · Issue #3065 · googleapis/google-cloud-java

Description: In working on a gRPC emulation service for Cloud Pub/Sub, I was trying to validate correct behavior by publishing a series of messages, receiving and acknowleding the exact same set of messages, and then ensuring that no backlog existed ...

Open Graph Description: In working on a gRPC emulation service for Cloud Pub/Sub, I was trying to validate correct behavior by publishing a series of messages, receiving and acknowleding the exact same set of messages, an...

X Description: In working on a gRPC emulation service for Cloud Pub/Sub, I was trying to validate correct behavior by publishing a series of messages, receiving and acknowleding the exact same set of messages, an...

Opengraph URL: https://github.com/googleapis/google-cloud-java/issues/3065

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[pubsub] Subscriber.stopAsync().awaitTerminated() doesn't wait for all acks to be sent","articleBody":"In working on a gRPC emulation service for Cloud Pub/Sub, I was trying to validate correct behavior by publishing a series of messages, receiving and acknowleding the exact same set of messages, and then ensuring that no backlog existed for the subscription.\r\n\r\nHere's the general test pattern:\r\n```\r\nString messagePrefix = subscriptionProperties.getName() + System.currentTimeMillis() + \"-\";\r\nint messages = 5000;\r\nSet\u003cString\u003e messagesSet = new TreeSet\u003c\u003e();\r\nfor (int i = 0; i \u003c messages; i++) {\r\n  messagesSet.add(messagePrefix + i);\r\n}\r\nCountDownLatch countDownLatch = new CountDownLatch(messages);\r\nSet\u003cString\u003e publishedIds = new ConcurrentSkipListSet\u003c\u003e();\r\nMap\u003cString, Integer\u003e receivedIds = new ConcurrentHashMap\u003c\u003e();\r\nfor (String data : messagesSet) {\r\n  PubsubMessage message =\r\n      PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8(data)).build();\r\n  ApiFutures.addCallback(\r\n      publisher.publish(message),\r\n      new ApiFutureCallback\u003cString\u003e() {\r\n        @Override\r\n        public void onFailure(Throwable throwable) {\r\n          LOGGER.warning(\"Error on Publish \" + throwable.getMessage());\r\n        }\r\n\r\n        @Override\r\n        public void onSuccess(String s) {\r\n          publishedIds.add(s);\r\n        }\r\n      });\r\n}\r\npublisher.shutdown();\r\nassertEquals(messages, publishedIds.size());\r\n\r\nsubscriber =\r\n    Subscriber.newBuilder(\r\n            ProjectSubscriptionName.of(PROJECT, subscriptionProperties.getName()),\r\n            (message, consumer) -\u003e {\r\n              consumer.ack();\r\n              LOGGER.fine(\"Received and Acknowledging \" + message.getMessageId());\r\n              if (!receivedIds.containsKey(message.getMessageId())) {\r\n                receivedIds.put(message.getMessageId(), 1);\r\n              } else {\r\n                int current = receivedIds.get(message.getMessageId());\r\n                receivedIds.put(message.getMessageId(), Integer.valueOf(++current));\r\n              }\r\n              countDownLatch.countDown();\r\n            })\r\n        //.setChannelProvider(channelProvider)\r\n        //.setCredentialsProvider(credentialsProvider)\r\n        .build();\r\n\r\npublisher.shutdown();\r\nassertEquals(messages, publishedIds.size());\r\n\r\nsubscriber.startAsync();\r\nLOGGER.info(\"Publisher complete, waiting for 5,000 messages to be received by Subscriber\");\r\ncountDownLatch.await();\r\nLOGGER.info(\"Shutting down Subscriber\");\r\nsubscriber.stopAsync().awaitTerminated();\r\n```\r\n\r\nI executed this test after creating a fresh topic and subscription. My expectation was that after the CountDownLatch reached 0, the Subscriber would shut down and block until all acknowledgements were transmitted.\r\n\r\nIn the client library debug logs, I see the following ack lines, which add up to 5,000 as expected. Interestingly, the final 1,517 acks coming from a thread named *time-limited test*, which is the main thread of my integration test case.\r\n```\r\n2018-03-20 14:10:41.694 [Thread-50] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 78 acks\r\n2018-03-20 14:10:41.693 [Thread-42] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 70 acks\r\n2018-03-20 14:10:41.696 [Thread-46] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 29 acks\r\n2018-03-20 14:10:41.700 [Thread-48] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 100 acks\r\n2018-03-20 14:10:41.695 [Thread-52] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 169 acks\r\n2018-03-20 14:10:41.702 [Thread-44] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 42 acks\r\n2018-03-20 14:10:41.723 [Thread-48] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 281 acks\r\n2018-03-20 14:10:41.729 [Thread-52] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 266 acks\r\n2018-03-20 14:10:41.823 [Thread-50] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 36 acks\r\n2018-03-20 14:10:41.830 [Thread-42] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 75 acks\r\n2018-03-20 14:10:41.832 [Thread-46] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 609 acks\r\n2018-03-20 14:10:41.831 [Thread-48] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 376 acks\r\n2018-03-20 14:10:41.841 [Thread-44] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 186 acks\r\n2018-03-20 14:10:41.841 [Thread-52] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 510 acks\r\n2018-03-20 14:10:41.845 [Thread-50] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 244 acks\r\n2018-03-20 14:10:41.868 [Thread-42] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 412 acks\r\n2018-03-20 14:10:41.887 [Time-limited test] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 106 acks\r\n2018-03-20 14:10:41.888 [Time-limited test] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 496 acks\r\n2018-03-20 14:10:41.892 [Time-limited test] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 379 acks\r\n2018-03-20 14:10:41.894 [Time-limited test] DEBUG com.google.cloud.pubsub.v1.MessageDispatcher : Sending 536 acks\r\n```\r\n\r\nNow, at this point, I can confirm the existence of a backlog by re-running the test but disabling the publisher step. The subscriber should not receive any messages and the test should time out.\r\n\r\nHowever, when I grep for the *Received and Acknowledging * line in my logs, I get a total of *981* rows indicating that those acks that should have been transmitted from the previous run of receiving and acknowledging all 5,000 messages were not received by Cloud Pub/Sub. *981* happens to be the sum of the first three ack batches sent from the *Time-limited test* thread after the subscriber shutdown sequence was invoked.\r\n","author":{"url":"https://github.com/prodonjs","@type":"Person","name":"prodonjs"},"datePublished":"2018-03-20T18:18:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/3065/google-cloud-java/issues/3065"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:24e6bfaa-3763-597c-a1fe-7d988c140cbc
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB00E:2E97A2:B5BB:F5DD:6A4D0223
html-safe-nonce0f0cc7d0589f02fc2d91dcbb4841c40f67d28d4badd36370d6e9673823840643
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDBFOjJFOTdBMjpCNUJCOkY1REQ6NkE0RDAyMjMiLCJ2aXNpdG9yX2lkIjoiNTI4ODE1MjUxNzYxMTE2MDA5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacaf6026b76dcceb3b61600c61207744d803d68a1218e4b0046f7c6f713d785ec0
hovercard-subject-tagissue:306983291
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-java/3065/issue_layout
twitter:imagehttps://opengraph.githubassets.com/67b140df98003f395fe9a1997232b70691633facfa68798b9e69eca2c48218a5/googleapis/google-cloud-java/issues/3065
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/67b140df98003f395fe9a1997232b70691633facfa68798b9e69eca2c48218a5/googleapis/google-cloud-java/issues/3065
og:image:altIn working on a gRPC emulation service for Cloud Pub/Sub, I was trying to validate correct behavior by publishing a series of messages, receiving and acknowleding the exact same set of messages, an...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameprodonjs
hostnamegithub.com
expected-hostnamegithub.com
None31e4db13a9e20081f2fac78f441659a6576e582bbb15e153f9c7fb6473aa29f5
turbo-cache-controlno-preview
go-importgithub.com/googleapis/google-cloud-java git https://github.com/googleapis/google-cloud-java.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id26181278
octolytics-dimension-repository_nwogoogleapis/google-cloud-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id26181278
octolytics-dimension-repository_network_root_nwogoogleapis/google-cloud-java
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasefb70bd3c4b2bec429781b65419e912c66e2d5581
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/google-cloud-java/issues/3065#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-cloud-java%2Fissues%2F3065
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-cloud-java%2Fissues%2F3065
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=googleapis%2Fgoogle-cloud-java
Reloadhttps://github.com/googleapis/google-cloud-java/issues/3065
Reloadhttps://github.com/googleapis/google-cloud-java/issues/3065
Reloadhttps://github.com/googleapis/google-cloud-java/issues/3065
Please reload this pagehttps://github.com/googleapis/google-cloud-java/issues/3065
googleapis https://github.com/googleapis
google-cloud-javahttps://github.com/googleapis/google-cloud-java
Notifications https://github.com/login?return_to=%2Fgoogleapis%2Fgoogle-cloud-java
Fork 1.1k https://github.com/login?return_to=%2Fgoogleapis%2Fgoogle-cloud-java
Star 2.1k https://github.com/login?return_to=%2Fgoogleapis%2Fgoogle-cloud-java
Code https://github.com/googleapis/google-cloud-java
Issues 651 https://github.com/googleapis/google-cloud-java/issues
Pull requests 103 https://github.com/googleapis/google-cloud-java/pulls
Actions https://github.com/googleapis/google-cloud-java/actions
Security and quality 0 https://github.com/googleapis/google-cloud-java/security
Insights https://github.com/googleapis/google-cloud-java/pulse
Code https://github.com/googleapis/google-cloud-java
Issues https://github.com/googleapis/google-cloud-java/issues
Pull requests https://github.com/googleapis/google-cloud-java/pulls
Actions https://github.com/googleapis/google-cloud-java/actions
Security and quality https://github.com/googleapis/google-cloud-java/security
Insights https://github.com/googleapis/google-cloud-java/pulse
[pubsub] Subscriber.stopAsync().awaitTerminated() doesn't wait for all acks to be senthttps://github.com/googleapis/google-cloud-java/issues/3065#top
https://github.com/pongad
api: pubsubIssues related to the Pub/Sub API.https://github.com/googleapis/google-cloud-java/issues?q=state%3Aopen%20label%3A%22api%3A%20pubsub%22
priority: p2Moderately-important priority. Fix may not be included in next release.https://github.com/googleapis/google-cloud-java/issues?q=state%3Aopen%20label%3A%22priority%3A%20p2%22
type: questionRequest for information or clarification. Not an issue.https://github.com/googleapis/google-cloud-java/issues?q=state%3Aopen%20label%3A%22type%3A%20question%22
https://github.com/prodonjs
prodonjshttps://github.com/prodonjs
on Mar 20, 2018https://github.com/googleapis/google-cloud-java/issues/3065#issue-306983291
pongadhttps://github.com/pongad
api: pubsubIssues related to the Pub/Sub API.https://github.com/googleapis/google-cloud-java/issues?q=state%3Aopen%20label%3A%22api%3A%20pubsub%22
priority: p2Moderately-important priority. Fix may not be included in next release.https://github.com/googleapis/google-cloud-java/issues?q=state%3Aopen%20label%3A%22priority%3A%20p2%22
type: questionRequest for information or clarification. Not an issue.https://github.com/googleapis/google-cloud-java/issues?q=state%3Aopen%20label%3A%22type%3A%20question%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.