René's URL Explorer Experiment


Title: Bigtable: read_rows: no deadline causing stuck clients; no way to change it · Issue #6 · googleapis/python-bigtable · GitHub

Open Graph Title: Bigtable: read_rows: no deadline causing stuck clients; no way to change it · Issue #6 · googleapis/python-bigtable

X Title: Bigtable: read_rows: no deadline causing stuck clients; no way to change it · Issue #6 · googleapis/python-bigtable

Description: Table.read_rows does not set any deadline, so it can hang forever if the Bigtable server connection hangs. We see this happening once every week or two when running inside GCP, which causes our server to get stuck indefinitely. There app...

Open Graph Description: Table.read_rows does not set any deadline, so it can hang forever if the Bigtable server connection hangs. We see this happening once every week or two when running inside GCP, which causes our ser...

X Description: Table.read_rows does not set any deadline, so it can hang forever if the Bigtable server connection hangs. We see this happening once every week or two when running inside GCP, which causes our ser...

Opengraph URL: https://github.com/googleapis/python-bigtable/issues/6

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bigtable: read_rows: no deadline causing stuck clients; no way to change it","articleBody":"`Table.read_rows` does not set any deadline, so it can hang forever if the Bigtable server connection hangs. We see this happening once every week or two when running inside GCP, which causes our server to get stuck indefinitely. There appears to be no way in the API to set a deadline, even though [the documentation](https://googleapis.github.io/google-cloud-python/latest/bigtable/table.html#google.cloud.bigtable.table.Table.read_rows) says that the `retry` parameter should do this. Due to a bug, it does not.\r\n\r\n### Details:\r\n\r\nWe are calling `Table.read_rows` to read ~2 rows from BigTable. Using pyflame on a stuck process, both worker threads were waiting on Bigtable, with the stack trace below. I believe the bug is the following:\r\n\r\n1. Call `Table.read_rows`. [This calls `PartialRowsData`](https://github.com/googleapis/google-cloud-python/blob/master/bigtable/google/cloud/bigtable/table.py#L436), passing the `retry` argument which defaults to `DEFAULT_RETRY_READ_ROWS`. The default misleadingly sets `deadline=60.0`. ; It also passes `read_method=self._instance._client.table_data_client.transport.read_rows` to `PartialRowsData`, which is a method on `BigtableGrpcTransport`.\r\n2. [`PartialRowsData.__init__` calls `read_method()`](https://github.com/googleapis/google-cloud-python/blob/master/bigtable/google/cloud/bigtable/row_data.py#L398); this is actually raw gRPC `_UnaryStreamMultiCallable`, *not* the gapic `BigtableClient.read_rows`, which AFAICS, is never called. Hence, this gRPC streaming call is started with any deadline. \r\n3. `PartialRowsData.__iter__` calls `self._read_next_response`, which [calls `return self.retry(self._read_next, on_error=self._on_error)()`](https://github.com/googleapis/google-cloud-python/blob/master/bigtable/google/cloud/bigtable/row_data.py#L454). This gives the impression that `retry` is used, but if I understand gRPC streams correctly, I'm not sure that even makes sense. I think even if the gRPC stream return some error, calling `next` won't actually retry the gRPC, it will just immediately raise the same exception. To retry, I believe you need to actually restart it by calling `read_rows` again.\r\n4. If the Bigtable server now \"hangs\", the client hangs forever.\r\n\r\n### Possible fix:\r\n\r\nChange `Table.read_rows` call the gapic `BigtableClient.read_rows` with the `retry` parameter., and change `PartialRowsData.__init__` to take this response iterator, and not take a `retry` parameter at all. This would at least allow setting the gRPC streaming call deadline, although I don't think it will make retrying work (since I *think* the gRPC streaming client will just immediately returns an iterator without actually waiting for a response from the server?)\r\n\r\nI haven't actually tried implementing this to see if it works. For now, we will probably just make a raw gRPC read_rows call so we can set an appropriate timeout. \r\n\r\n\r\n#### Environment details\r\n\r\n*OS*: Linux, ContainerOS (GKE), Container is Debian9 (using distroless)\r\n*Python*: 3.5.3\r\n*API*: google-cloud-bigtable 0.33.0\r\n\r\n\r\n#### Steps to reproduce\r\n\r\nThis program loads the Bigtable emulator with 1000 rows, calls `read_rows(retry=DEFAULT.with_deadline(5.0))`, then sends `SIGSTOP` to pause the emulator. This SHOULD cause a `DeadlineExceeded` exception to be raised after 5 seconds. Instead, it hangs forever.\r\n\r\n1. Start the Bigtable emulator: `gcloud beta emulators bigtable start`\r\n2. Find the PID: `ps ax | grep cbtemulator`\r\n3. Run the following program with `BIGTABLE_EMULATOR_HOST=localhost:8086 python3 bug.py $PID`\r\n\r\n```python\r\nfrom google.api_core import exceptions\r\nfrom google.cloud import bigtable\r\nfrom google.rpc import code_pb2\r\nfrom google.rpc import status_pb2\r\nimport os\r\nimport signal\r\nimport sys\r\n\r\nCOLUMN_FAMILY_ID = 'column_family_id'\r\n\r\ndef main():\r\n    emulator_pid = int(sys.argv[1])\r\n    client = bigtable.Client(project=\"testing\", admin=True)\r\n    instance = client.instance(\"emulator\")\r\n\r\n    # create/open a table\r\n    table = instance.table(\"emulator_table\")\r\n    column_family = table.column_family(COLUMN_FAMILY_ID)\r\n    try:\r\n        table.create()\r\n        column_family.create()\r\n    except exceptions.AlreadyExists:\r\n        print('table exists')\r\n\r\n    # write a bunch of data\r\n    for i in range(1000):\r\n        k = 'some_key_{:04d}'.format(i)\r\n        print(k)\r\n        row = table.row(k)\r\n        row.set_cell(COLUMN_FAMILY_ID, 'column', 'some_value{:d}'.format(i) * 1000)\r\n        result = table.mutate_rows([row])\r\n        assert len(result) == 1 and result[0].code == code_pb2.OK\r\n        assert table.read_row(k) is not None\r\n\r\n    print('starting read')\r\n    rows = table.read_rows(retry=bigtable.table.DEFAULT_RETRY_READ_ROWS.with_deadline(5.0))\r\n    rows_iter = iter(rows)\r\n    r1 = next(rows_iter)\r\n    print('read', r1)\r\n    os.kill(emulator_pid, signal.SIGSTOP)\r\n    print('sent sigstop')\r\n    for r in rows_iter:\r\n        print(r)\r\n    print('done')\r\n\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n```\r\n\r\n#### Stack trace of hung server (using slightly older version of the google-cloud-bigtable library\r\n\r\n```\r\n/usr/local/lib/python2.7/threading.py:wait:340\r\n/usr/local/lib/python2.7/site-packages/grpc/_channel.py:_next:348\r\n/usr/local/lib/python2.7/site-packages/grpc/_channel.py:next:366\r\n/usr/local/lib/python2.7/site-packages/google/cloud/bigtable/row_data.py:_read_next:426\r\n/usr/local/lib/python2.7/site-packages/google/api_core/retry.py:retry_target:179\r\n/usr/local/lib/python2.7/site-packages/google/api_core/retry.py:retry_wrapped_func:270\r\n/usr/local/lib/python2.7/site-packages/google/cloud/bigtable/row_data.py:_read_next_response:430\r\n/usr/local/lib/python2.7/site-packages/google/cloud/bigtable/row_data.py:__iter__:441\r\n```\r\n","author":{"url":"https://github.com/evanj","@type":"Person","name":"evanj"},"datePublished":"2019-05-29T00:22:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/6/python-bigtable/issues/6"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f1c6188c-1489-ac4d-c652-a856a189abe5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9DCA:3B16A6:2CD6CB4:3E1E3FA:6A4F0A53
html-safe-noncedcad8fa1126ec0a6f193c164f647f78d309180161d26fc653d3441bed945b212
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RENBOjNCMTZBNjoyQ0Q2Q0I0OjNFMUUzRkE6NkE0RjBBNTMiLCJ2aXNpdG9yX2lkIjoiNTYwMTAzNDMxMzgyNDkzMDM4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaceabc1527add357606cdbdc5b455bbaf7d9d9e61a0dfb8af11b8deb7e063d37d0
hovercard-subject-tagissue:558431526
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/python-bigtable/6/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f64f3d656b90e21eb6950ca6feec392c650e85a61578e5215c9aa19513641591/googleapis/python-bigtable/issues/6
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f64f3d656b90e21eb6950ca6feec392c650e85a61578e5215c9aa19513641591/googleapis/python-bigtable/issues/6
og:image:altTable.read_rows does not set any deadline, so it can hang forever if the Bigtable server connection hangs. We see this happening once every week or two when running inside GCP, which causes our ser...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameevanj
hostnamegithub.com
expected-hostnamegithub.com
Noneb92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9
turbo-cache-controlno-preview
go-importgithub.com/googleapis/python-bigtable git https://github.com/googleapis/python-bigtable.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id226992487
octolytics-dimension-repository_nwogoogleapis/python-bigtable
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id226992487
octolytics-dimension-repository_network_root_nwogoogleapis/python-bigtable
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
release2b8f23afb982271f1b22258a94aede67a6b77760
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/python-bigtable/issues/6#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-bigtable%2Fissues%2F6
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/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/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/enterprise/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%2Fpython-bigtable%2Fissues%2F6
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%2Fpython-bigtable
Reloadhttps://github.com/googleapis/python-bigtable/issues/6
Reloadhttps://github.com/googleapis/python-bigtable/issues/6
Reloadhttps://github.com/googleapis/python-bigtable/issues/6
Please reload this pagehttps://github.com/googleapis/python-bigtable/issues/6
googleapis https://github.com/googleapis
python-bigtablehttps://github.com/googleapis/python-bigtable
Notifications https://github.com/login?return_to=%2Fgoogleapis%2Fpython-bigtable
Fork 65 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-bigtable
Star 75 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-bigtable
Code https://github.com/googleapis/python-bigtable
Issues 0 https://github.com/googleapis/python-bigtable/issues
Pull requests 0 https://github.com/googleapis/python-bigtable/pulls
Actions https://github.com/googleapis/python-bigtable/actions
Projects https://github.com/googleapis/python-bigtable/projects
Security and quality 0 https://github.com/googleapis/python-bigtable/security
Insights https://github.com/googleapis/python-bigtable/pulse
Code https://github.com/googleapis/python-bigtable
Issues https://github.com/googleapis/python-bigtable/issues
Pull requests https://github.com/googleapis/python-bigtable/pulls
Actions https://github.com/googleapis/python-bigtable/actions
Projects https://github.com/googleapis/python-bigtable/projects
Security and quality https://github.com/googleapis/python-bigtable/security
Insights https://github.com/googleapis/python-bigtable/pulse
#16https://github.com/googleapis/python-bigtable/pull/16
googleapis/python-api-core#20https://github.com/googleapis/python-api-core/pull/20
Bigtable: read_rows: no deadline causing stuck clients; no way to change ithttps://github.com/googleapis/python-bigtable/issues/6#top
#16https://github.com/googleapis/python-bigtable/pull/16
googleapis/python-api-core#20https://github.com/googleapis/python-api-core/pull/20
https://github.com/mf2199
🚨This issue needs some love.https://github.com/googleapis/python-bigtable/issues?q=state%3Aopen%20label%3A%22%3Arotating_light%3A%22
api: bigtableIssues related to the googleapis/python-bigtable API.https://github.com/googleapis/python-bigtable/issues?q=state%3Aopen%20label%3A%22api%3A%20bigtable%22
priority: p2Moderately-important priority. Fix may not be included in next release.https://github.com/googleapis/python-bigtable/issues?q=state%3Aopen%20label%3A%22priority%3A%20p2%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/python-bigtable/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
https://github.com/evanj
evanjhttps://github.com/evanj
on May 29, 2019https://github.com/googleapis/python-bigtable/issues/6#issue-558431526
the documentationhttps://googleapis.github.io/google-cloud-python/latest/bigtable/table.html#google.cloud.bigtable.table.Table.read_rows
This calls PartialRowsDatahttps://github.com/googleapis/google-cloud-python/blob/master/bigtable/google/cloud/bigtable/table.py#L436
PartialRowsData.__init__ calls read_method()https://github.com/googleapis/google-cloud-python/blob/master/bigtable/google/cloud/bigtable/row_data.py#L398
calls return self.retry(self._read_next, on_error=self._on_error)()https://github.com/googleapis/google-cloud-python/blob/master/bigtable/google/cloud/bigtable/row_data.py#L454
mf2199https://github.com/mf2199
🚨This issue needs some love.https://github.com/googleapis/python-bigtable/issues?q=state%3Aopen%20label%3A%22%3Arotating_light%3A%22
api: bigtableIssues related to the googleapis/python-bigtable API.https://github.com/googleapis/python-bigtable/issues?q=state%3Aopen%20label%3A%22api%3A%20bigtable%22
priority: p2Moderately-important priority. Fix may not be included in next release.https://github.com/googleapis/python-bigtable/issues?q=state%3Aopen%20label%3A%22priority%3A%20p2%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/python-bigtable/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%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.