Skip to content

Commit 3165935

Browse files
authored
chore: log more info on jwks refresh (#18803)
* chore: log more info on jwks refresh * z
1 parent 2a6c686 commit 3165935

File tree

2 files changed

+53
-26
lines changed

2 files changed

+53
-26
lines changed

src/query/users/src/jwt/jwk.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl JwkKeyStore {
272272
reason.as_str().to_string(),
273273
err.code(),
274274
);
275-
warn!("Failed to load JWKS from {}: {}", self.url, err);
275+
warn!("failed to load JWKS from {}: {}", self.url, err);
276276
if !old_keys.is_empty() {
277277
return Ok(());
278278
}
@@ -290,7 +290,21 @@ impl JwkKeyStore {
290290
if new_keys.keys().eq(old_keys.keys()) {
291291
return Ok(());
292292
}
293-
info!("JWKS keys from {} changed.", self.url);
293+
info!(
294+
"JWKS keys changed on refresh: url={}, reason={}, old={}, new={}",
295+
self.url,
296+
reason.as_str(),
297+
old_keys
298+
.keys()
299+
.map(|k| k.as_str())
300+
.collect::<Vec<_>>()
301+
.join(","),
302+
new_keys
303+
.keys()
304+
.map(|k| k.as_str())
305+
.collect::<Vec<_>>()
306+
.join(",")
307+
);
294308

295309
// append the new keys to the end of recent_cached_maps
296310
{
@@ -341,8 +355,8 @@ impl JwkKeyStore {
341355
};
342356
if need_retry {
343357
warn!(
344-
"key id {} not found in jwk store, try to peek the latest keys",
345-
key_id
358+
"key id not found in jwk store, try to peek the latest keys: key={}, url={}",
359+
key_id, self.url
346360
);
347361
self.maybe_refresh_cached_keys(true).await?;
348362
*self.last_retry_time.write() = Some(Instant::now());

tests/suites/1_stateful/02_query/02_0012_temp_table_external_session_cleanup.py

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,96 +13,109 @@
1313
from native_client import NativeClient
1414
from native_client import prompt
1515

16+
1617
def cleanup_test_directory(test_dir):
1718
"""Clean up test directory"""
1819
if os.path.exists(test_dir):
1920
shutil.rmtree(test_dir)
2021

22+
2123
def count_files_in_directory(test_dir, pattern="*"):
2224
"""Count files matching pattern in directory"""
2325
if not os.path.exists(test_dir):
2426
return 0, []
2527
files = glob.glob(os.path.join(test_dir, "**", pattern), recursive=True)
2628
# Filter out directories and verification files
27-
files = [f for f in files if os.path.isfile(f) and not os.path.basename(f).startswith("_v_d77aa11285c22e0e1d4593a035c98c0d")]
29+
files = [
30+
f
31+
for f in files
32+
if os.path.isfile(f)
33+
and not os.path.basename(f).startswith("_v_d77aa11285c22e0e1d4593a035c98c0d")
34+
]
2835
return len(files), files
2936

37+
3038
def test_external_temp_table_cleanup():
3139
"""Test cleanup of external location temp tables when session ends"""
32-
40+
3341
# Test directory
3442
test_dir = "/tmp/databend_test_session_cleanup"
35-
43+
3644
print("====== Testing External Temp Table Session Cleanup ======")
37-
45+
3846
try:
3947
# Clean up any existing test directory
4048
cleanup_test_directory(test_dir)
41-
49+
4250
# Create test directory
4351
os.makedirs(test_dir, exist_ok=True)
44-
52+
4553
# Create temp table in session and verify cleanup
4654
print("-- Create external temp table")
47-
55+
4856
# Session: Create temp table with external location
4957
session_db = mysql.connector.connect(
5058
host="127.0.0.1", user="root", passwd="root", port="3307"
5159
)
5260
session_cursor = session_db.cursor()
53-
61+
5462
# Create temp table with external location
55-
session_cursor.execute(f"CREATE OR REPLACE TEMP TABLE temp_external (id INT, data STRING) 'fs://{test_dir}/';")
63+
session_cursor.execute(
64+
f"CREATE OR REPLACE TEMP TABLE temp_external (id INT, data STRING) 'fs://{test_dir}/';"
65+
)
5666
session_cursor.fetchall()
57-
67+
5868
# Insert some data
59-
session_cursor.execute("INSERT INTO temp_external VALUES (1, 'session'), (2, 'test');")
69+
session_cursor.execute(
70+
"INSERT INTO temp_external VALUES (1, 'session'), (2, 'test');"
71+
)
6072
session_cursor.fetchall()
61-
73+
6274
# Verify data exists
6375
session_cursor.execute("SELECT COUNT(*) FROM temp_external;")
6476
result = session_cursor.fetchone()
6577
print(f"Records in temp_external: {result[0]}")
66-
78+
6779
# Check that files were created in external location
6880
files_before_count, files_before_list = count_files_in_directory(test_dir)
6981
print(f"Files created in external location: {files_before_count}")
70-
82+
7183
# Close session to trigger cleanup
7284
session_cursor.close()
7385
session_db.close()
74-
86+
7587
# Wait for potential cleanup
7688
time.sleep(2)
77-
89+
7890
# Check if files were cleaned up
7991
files_after_count, files_after_list = count_files_in_directory(test_dir)
8092
print(f"Files after session ended: {files_after_count}")
81-
93+
8294
# If files still exist after cleanup, print their names
8395
if files_after_count > 0:
8496
print("Files remaining after cleanup:")
8597
for file_path in files_after_list:
8698
print(f" {file_path}")
87-
99+
88100
# Test result
89101
test_passed = files_before_count > 0 and files_after_count == 0
90-
102+
91103
if test_passed:
92104
print("✓ External temp table cleanup test PASSED")
93105
return True
94106
else:
95107
print("✗ External temp table cleanup test FAILED")
96108
return False
97-
109+
98110
except Exception as e:
99111
print(f"✗ Test failed with exception: {e}")
100112
return False
101-
113+
102114
finally:
103115
# Clean up test directory
104116
cleanup_test_directory(test_dir)
105117

118+
106119
if __name__ == "__main__":
107120
success = test_external_temp_table_cleanup()
108-
sys.exit(0 if success else 1)
121+
sys.exit(0 if success else 1)

0 commit comments

Comments
 (0)