Skip to content

Commit d05f8a2

Browse files
authored
Merge pull request #16 from zhanghaitao3/master
Fix deadlock when handling invalid cached plan errors
2 parents b5f87f8 + 8fbfce2 commit d05f8a2

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

async_gaussdb/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
import typing
1616

17-
__version__: typing.Final = '0.30.0'
17+
__version__: typing.Final = '0.30.1'

async_gaussdb/protocol/protocol.pyx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,14 @@ cdef class BaseProtocol(CoreProtocol):
895895

896896
if self.result_type == RESULT_FAILED:
897897
if isinstance(self.result, dict):
898-
exc = apg_exc_base.GaussDBError.new(
899-
self.result, query=self.last_query)
898+
sql_state = self.result.get('C')
899+
if sql_state and sql_state=='29P06':
900+
exc = apg_exc.InvalidCachedStatementError(
901+
'cached statement plan is invalid'
902+
)
903+
else:
904+
exc = apg_exc_base.GaussDBError.new(
905+
self.result, query=self.last_query)
900906
else:
901907
exc = self.result
902908
waiter.set_exception(exc)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies = [
3131
]
3232

3333
[project.urls]
34-
github = "https://github.com/MagicStack/async_gaussdb"
34+
github = "https://github.com/HuaweiCloudDeveloper/gaussdb-python-async"
3535

3636
[project.optional-dependencies]
3737
gssauth = [

tests/test_cache_invalidation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def _check_statements_are_closed(self, statements):
2727
self.assertGreater(len(statements), 0)
2828
self.assertTrue(all(s.closed for s in statements))
2929

30-
@unittest.skip('cached plan must not change result type')
3130
async def test_prepare_cache_invalidation_silent(self):
3231
await self.con.execute('CREATE TABLE tab1(a int, b int)')
3332

@@ -49,7 +48,6 @@ async def test_prepare_cache_invalidation_silent(self):
4948
finally:
5049
await self.con.execute('DROP TABLE tab1')
5150

52-
@unittest.skip('cached plan must not change result type')
5351
async def test_prepare_cache_invalidation_in_transaction(self):
5452
await self.con.execute('CREATE TABLE tab1(a int, b int)')
5553

@@ -311,7 +309,7 @@ async def test_type_cache_invalidation_on_change_attr(self):
311309

312310
@unittest.skip('UNLISTEN statement is not yet supported.')
313311
async def test_type_cache_invalidation_in_pool(self):
314-
await self.con.execute('CREATE DATABASE IF NOT EXISTS testdb')
312+
await self.con.execute('CREATE DATABASE testdb')
315313
pool = await self.create_pool(database='postgres',
316314
min_size=2, max_size=2)
317315

0 commit comments

Comments
 (0)