@@ -123,9 +123,11 @@ private static RemovalListener<Object, Object> buildCacheRemoveCallback(
123
123
@ NonNull Optional <DefaultDriverContext > context ) {
124
124
return (evt ) -> {
125
125
try {
126
+ LOG .info ("Cache removal callback triggered, cause: {}" , evt .getCause ());
126
127
CompletableFuture <PreparedStatement > future =
127
128
(CompletableFuture <PreparedStatement >) evt .getValue ();
128
129
ByteBuffer queryId = Uninterruptibles .getUninterruptibly (future ).getId ();
130
+ LOG .info ("Firing PreparedStatementRemovalEvent for queryId: {}" , queryId );
129
131
context .ifPresent (
130
132
ctx -> ctx .getEventBus ().fire (new PreparedStatementRemovalEvent (queryId )));
131
133
} catch (Exception e ) {
@@ -224,10 +226,15 @@ private void invalidationTestInner(
224
226
assertThat (getPreparedCacheSize (session )).isEqualTo (0 );
225
227
setupTestSchema .accept (session );
226
228
227
- session .prepare (preparedStmtQueryType1 );
228
- ByteBuffer queryId2 = session .prepare (preparedStmtQueryType2 ).getId ();
229
+ PreparedStatement stmt1 = session .prepare (preparedStmtQueryType1 );
230
+ PreparedStatement stmt2 = session .prepare (preparedStmtQueryType2 );
231
+ ByteBuffer queryId2 = stmt2 .getId ();
229
232
assertThat (getPreparedCacheSize (session )).isEqualTo (2 );
230
233
234
+ LOG .info ("Prepared statements in cache:" );
235
+ LOG .info (" Statement 1: {} (queryId: {})" , preparedStmtQueryType1 , stmt1 .getId ());
236
+ LOG .info (" Statement 2: {} (queryId: {})" , preparedStmtQueryType2 , stmt2 .getId ());
237
+
231
238
CountDownLatch preparedStmtCacheRemoveLatch = new CountDownLatch (1 );
232
239
CountDownLatch typeChangeEventLatch = new CountDownLatch (expectedChangedTypes .size ());
233
240
@@ -244,6 +251,8 @@ private void invalidationTestInner(
244
251
TypeChangeEvent .class ,
245
252
(e ) -> {
246
253
// expect one event per type changed and for every parent type that nests it
254
+ LOG .info ("Received TypeChangeEvent for type: {} (changeType: {})" ,
255
+ e .oldType .getName (), e .changeType );
247
256
if (Boolean .TRUE .equals (
248
257
changedTypes .putIfAbsent (e .oldType .getName ().toString (), true ))) {
249
258
// store an error if we see duplicate change event
@@ -256,16 +265,20 @@ private void invalidationTestInner(
256
265
.register (
257
266
PreparedStatementRemovalEvent .class ,
258
267
(e ) -> {
268
+ LOG .info ("Received PreparedStatementRemovalEvent for queryId: {}" , e .queryId );
259
269
if (!removedQueryIds .compareAndSet (Optional .empty (), Optional .of (e .queryId ))) {
260
270
// store an error if we see multiple cache invalidation events
261
271
// any non-empty error will fail the test so it's OK to do this multiple times
262
272
removedQueryEventError .set (
263
273
Optional .of ("Unable to set reference for PS removal event" ));
274
+ LOG .warn ("Multiple PreparedStatementRemovalEvents received, ignoring subsequent ones" );
264
275
}
265
276
preparedStmtCacheRemoveLatch .countDown ();
266
277
});
267
278
268
279
// alter test_type_caching_2 to trigger cache invalidation and above events
280
+ LOG .info ("Executing ALTER TYPE test_type_caching_2 add i blob" );
281
+ LOG .info ("Expected to invalidate statement 2 (queryId: {}) due to type change" , queryId2 );
269
282
session .execute ("ALTER TYPE test_type_caching_2 add i blob" );
270
283
271
284
// Give a small delay to allow the schema change to propagate before checking agreement
@@ -288,16 +301,20 @@ private void invalidationTestInner(
288
301
+ " - Cache removal latch success: %s (count: %d)\n "
289
302
+ " - Type change latch success: %s (count: %d)\n "
290
303
+ " - Current cache size: %d\n "
291
- + " - Changed types detected: %s\n "
292
- + " - Removed query IDs: %s\n "
304
+ + " - Expected changed types: %s\n "
305
+ + " - Actual changed types detected: %s\n "
306
+ + " - Expected removed query ID: %s\n "
307
+ + " - Actual removed query IDs: %s\n "
293
308
+ " - Type change errors: %s\n "
294
309
+ " - Removal event errors: %s" ,
295
310
cacheRemovalSuccess ,
296
311
preparedStmtCacheRemoveLatch .getCount (),
297
312
typeChangeSuccess ,
298
313
typeChangeEventLatch .getCount (),
299
314
getPreparedCacheSize (session ),
315
+ expectedChangedTypes ,
300
316
changedTypes .keySet (),
317
+ queryId2 ,
301
318
removedQueryIds .get (),
302
319
typeChangeEventError .get (),
303
320
removedQueryEventError .get ());
0 commit comments