File tree 2 files changed +23
-14
lines changed
2 files changed +23
-14
lines changed Original file line number Diff line number Diff line change
1
+ Check for aws extensions before querying aurora_version()
Original file line number Diff line number Diff line change 27
27
class VersionUtils (object ):
28
28
def __init__ (self ):
29
29
self .log = get_check_logger ()
30
- self ._seen_aurora_exception = False
30
+ self ._is_aurora = None
31
31
32
32
@staticmethod
33
33
def get_raw_version (db ):
@@ -38,21 +38,29 @@ def get_raw_version(db):
38
38
return raw_version
39
39
40
40
def is_aurora (self , db ):
41
- if self ._seen_aurora_exception :
42
- return False
41
+ if self ._is_aurora is not None :
42
+ return self . _is_aurora
43
43
with db as conn :
44
44
with conn .cursor (cursor_factory = CommenterCursor ) as cursor :
45
- # This query will pollute PG logs in non aurora versions,
46
- # but is the only reliable way to detect aurora
47
- try :
48
- cursor .execute ('select AURORA_VERSION();' )
49
- return True
50
- except Exception as e :
51
- self .log .debug (
52
- "Captured exception %s while determining if the DB is aurora. Assuming is not" , str (e )
53
- )
54
- self ._seen_aurora_exception = True
55
- return False
45
+ cursor .execute (
46
+ "SELECT 1 FROM pg_available_extension_versions "
47
+ "WHERE name ILIKE '%aurora%' OR comment ILIKE '%aurora%' "
48
+ "LIMIT 1;"
49
+ )
50
+ if cursor .fetchone ():
51
+ # This query will pollute PG logs in non aurora versions,
52
+ # but is the only reliable way to detect aurora.
53
+ # Since we found aurora extensions, this should exist.
54
+ try :
55
+ cursor .execute ('select AURORA_VERSION();' )
56
+ self ._is_aurora = True
57
+ return self ._is_aurora
58
+ except Exception as e :
59
+ self .log .debug (
60
+ "Captured exception %s while determining if the DB is aurora. Assuming is not" , str (e )
61
+ )
62
+ self ._is_aurora = False
63
+ return self ._is_aurora
56
64
57
65
@staticmethod
58
66
def parse_version (raw_version ):
You can’t perform that action at this time.
0 commit comments