René's URL Explorer Experiment


Title: Sqlite cursor garbage-collection issue with Python 3.11.0b3 · Issue #94028 · python/cpython · GitHub

Open Graph Title: Sqlite cursor garbage-collection issue with Python 3.11.0b3 · Issue #94028 · python/cpython

X Title: Sqlite cursor garbage-collection issue with Python 3.11.0b3 · Issue #94028 · python/cpython

Description: Bug report This was reported to me on coleifer/peewee#2580 and, as I've managed to reproduce the issue, was asked by @erlend-aasland to submit a ticket here. Note that this issue does not manifest on other versions of Python (2.7, 3.6, 3...

Open Graph Description: Bug report This was reported to me on coleifer/peewee#2580 and, as I've managed to reproduce the issue, was asked by @erlend-aasland to submit a ticket here. Note that this issue does not manifest ...

X Description: Bug report This was reported to me on coleifer/peewee#2580 and, as I've managed to reproduce the issue, was asked by @erlend-aasland to submit a ticket here. Note that this issue does not manif...

Opengraph URL: https://github.com/python/cpython/issues/94028

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sqlite cursor garbage-collection issue with Python 3.11.0b3","articleBody":"**Bug report**\r\n\r\nThis was reported to me on https://github.com/coleifer/peewee/issues/2580 and, as I've managed to reproduce the issue, was asked by @erlend-aasland to submit a ticket here. Note that this issue does **not** manifest on other versions of Python (2.7, 3.6, 3.9 and 3.10) -- it appears to be a new issue on 3.11.0b3\r\n\r\n**The original reporter bisected and found the following commit introduced the regression**: https://github.com/python/cpython/commit/3df0fc89bc2714f5ef03e36a926bc795dcd5e05a\r\n\r\nI believe this is a cursor garbage collection issue, though I may be mistaken. Keeping the cursors around in memory seems to cause the problem to manifest, but if you comment-out the line indicated below then the tests will pass. Note that Peewee doesn't do anything weird like keep the cursors in memory, this was just the first way I've been able to successfully reproduce the issue.\r\n\r\nThe test below does the following:\r\n\r\n* create a 1st connection to a sqlite db and put some rows into it, committing changes\r\n* create a 2nd connection to that db and verify we can see the rows, then delete them, committing changes\r\n* begin a transaction in 1st connection, inserting 2 new rows\r\n* verify the 2nd connection cannot see the uncommitted rows (this is where the failure occurs)\r\n* verify the 1st connection can see its uncommitted rows, then commit\r\n* lastly verify the 2nd connection can see the now-committed rows\r\n\r\nWhat is doubly-confusing about this error is that, when the failure occurs, the SQL being executed should definitely NOT be returning `None` from the call to `fetchone()`. If the table did not exist, we would get a different error from Sqlite. If the table does exist and we just can't see any rows, then we should be getting 0 as the test asserts. Instead, the `fetchone()` is returning `None`.\r\n\r\nReproduce:\r\n\r\n```python\r\nimport glob\r\nimport os\r\nimport sqlite3\r\n\r\nfilename = '/tmp/test.db'\r\nfor f in glob.glob(filename + '*'):\r\n    os.unlink(f)  # Cleanup anything from prev run(s).\r\n\r\nCURSORS = {}\r\n\r\ndef sql(conn, sql, *params):\r\n    curs = conn.cursor()\r\n    curs.execute(sql, params)\r\n    CURSORS[id(sql)] = curs  # COMMENT THIS OUT AND TEST WILL PASS.\r\n    return curs\r\n\r\n# Set up database w/some sample rows. Peewee sets isolation-level to None as we\r\n# want to manage all transaction state ourselves, rather than use sqlite3's\r\n# somewhat unusual semantics.\r\ndb = sqlite3.connect(filename, isolation_level=None)\r\ndb.execute('create table users (id integer not null primary key, '\r\n           'username text not null)')\r\nsql(db, 'insert into users (username) values (?), (?), (?)', 'u1', 'u2', 'u3')\r\ndb.commit()\r\n\r\n# On 2nd connection verify rows are visible, then delete them.\r\nnew_db2 = sqlite3.connect(filename, isolation_level=None)\r\nassert sql(new_db2, 'select count(*) from users').fetchone()[0] == 3\r\nassert sql(new_db2, 'delete from users').rowcount == 3\r\nnew_db2.commit()\r\n\r\n# Back in original connection, create 2 new users.\r\nsql(db, 'begin')\r\nsql(db, 'insert into users (username) values (?)', 'u4')\r\nsql(db, 'insert into users (username) values (?)', 'u5')\r\n\r\n# 2nd connection cannot see uncommitted changes.\r\n# NOTE: this is the line that fails.\r\nassert sql(new_db2, 'select count(*) from users').fetchone()[0] == 0\r\n\r\n# Original conn can see its own changes.\r\nassert sql(db, 'select count(*) from users').fetchone()[0] == 2\r\ndb.commit()\r\n\r\n# Now the 2nd conn can see the changes.\r\nassert sql(new_db2, 'select count(*) from users').fetchone()[0] == 2\r\n```\r\n\r\nOn 3.11.0b3 the above fails on the indicated line with the following exception:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/charles/tmp/py311/repro.py\", line 40, in \u003cmodule\u003e\r\n    assert sql(new_db2, 'select count(*) from users').fetchone()[0] == 0\r\n           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^\r\nTypeError: 'NoneType' object is not subscriptable\r\n```\r\n\r\n**Your environment**\r\n\r\n- CPython versions tested on: 2.7, 3.6, 3.9, 3.10 (passing), and 3.11.0b3 (**failing**)\r\n- Sqlite3 version 3.35 and 3.38\r\n- Linux / Debian stable","author":{"url":"https://github.com/coleifer","@type":"Person","name":"coleifer"},"datePublished":"2022-06-20T13:54:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/94028/cpython/issues/94028"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4a22d11e-6462-d42c-d58b-f32efb329c20
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB00E:33C049:122E0F0:18F9A6F:6969FC8A
html-safe-noncef1680373355dd672cb0ed36508e2eb54b4434f411acbc1a1b96c957fd8790abc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDBFOjMzQzA0OToxMjJFMEYwOjE4RjlBNkY6Njk2OUZDOEEiLCJ2aXNpdG9yX2lkIjoiNjA5MzQxMDcxMzI0MzA5MDA1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacdabe62fc954d67db117ca9ea7c1263acac9e3c9f0c54d4fed956abcd86617052
hovercard-subject-tagissue:1276971437
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/python/cpython/94028/issue_layout
twitter:imagehttps://opengraph.githubassets.com/206ff6572300ccbe3189b4107850132065a28b0914dd33e3d4f877617397d971/python/cpython/issues/94028
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/206ff6572300ccbe3189b4107850132065a28b0914dd33e3d4f877617397d971/python/cpython/issues/94028
og:image:altBug report This was reported to me on coleifer/peewee#2580 and, as I've managed to reproduce the issue, was asked by @erlend-aasland to submit a ticket here. Note that this issue does not manifest ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecoleifer
hostnamegithub.com
expected-hostnamegithub.com
None7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
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
releasebdde15ad1b403e23b08bbd89b53fbe6bdf688cad
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/94028#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F94028
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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%2Fpython%2Fcpython%2Fissues%2F94028
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=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/94028
Reloadhttps://github.com/python/cpython/issues/94028
Reloadhttps://github.com/python/cpython/issues/94028
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/94028
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/94028
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/94028
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/94028
#94042https://github.com/python/cpython/pull/94042
Sqlite cursor garbage-collection issue with Python 3.11.0b3https://github.com/python/cpython/issues/94028#top
#94042https://github.com/python/cpython/pull/94042
https://github.com/erlend-aasland
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
release-blockerhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22release-blocker%22
topic-sqlite3https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-sqlite3%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/coleifer
https://github.com/coleifer
coleiferhttps://github.com/coleifer
on Jun 20, 2022https://github.com/python/cpython/issues/94028#issue-1276971437
coleifer/peewee#2580https://github.com/coleifer/peewee/issues/2580
@erlend-aaslandhttps://github.com/erlend-aasland
3df0fc8https://github.com/python/cpython/commit/3df0fc89bc2714f5ef03e36a926bc795dcd5e05a
erlend-aaslandhttps://github.com/erlend-aasland
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
release-blockerhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22release-blocker%22
topic-sqlite3https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-sqlite3%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
sqlite3 issueshttps://github.com/orgs/python/projects/23
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.