3535import  java .util .concurrent .ConcurrentMap ;
3636import  java .util .concurrent .CountDownLatch ;
3737import  java .util .concurrent .TimeUnit ;
38+ import  java .util .function .Supplier ;
3839import  java .util .stream .Collectors ;
3940import  java .util .stream .Stream ;
4041import  javax .cache .configuration .FactoryBuilder ;
@@ -239,6 +240,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
239240    private  static  final  String  ENCRYPT_MISMATCH_MESSAGE  = "Failed to join node to the cluster "  +
240241        "(encryption settings are different for cache '%s' : local=%s, remote=%s.)" ;
241242
243+     /** */ 
244+     private  static  final  String  CACHE_NAME_AND_OPERATION_FORMAT  = "[cacheName=%s, operation=%s]" ;
245+ 
246+     /** */ 
247+     private  static  final  String  CACHE_NAMES_AND_OPERATION_FORMAT  = "[cacheNames=%s, operation=%s]" ;
248+ 
242249    /** */ 
243250    private  final  boolean  startClientCaches  =
244251        IgniteSystemProperties .getBoolean (IgniteSystemProperties .IGNITE_START_CACHES_ON_JOIN , false );
@@ -4052,8 +4059,10 @@ public IgniteInternalFuture<Boolean> dynamicStartCache(
40524059    ) {
40534060        assert  cacheName  != null ;
40544061
4055-         if  (checkThreadTx )
4056-             checkEmptyTransactions ();
4062+         if  (checkThreadTx ) {
4063+             checkEmptyTransactionsEx (() -> String .format (CACHE_NAME_AND_OPERATION_FORMAT , cacheName ,
4064+                 "dynamicStartCache" ));
4065+         }
40574066
40584067        GridPlainClosure <Collection <byte []>, IgniteInternalFuture <Boolean >> startCacheClsr  = (grpKeys ) -> {
40594068            assert  ccfg  == null  || !ccfg .isEncryptionEnabled () || !grpKeys .isEmpty ();
@@ -4202,8 +4211,16 @@ public IgniteInternalFuture<Boolean> dynamicStartCachesByStoredConf(
42024211        boolean  disabledAfterStart ,
42034212        IgniteUuid  restartId 
42044213    ) {
4205-         if  (checkThreadTx )
4206-             checkEmptyTransactions ();
4214+         if  (checkThreadTx ) {
4215+             checkEmptyTransactionsEx (() -> {
4216+                 List <String > cacheNames  = storedCacheDataList .stream ()
4217+                     .map (StoredCacheData ::config )
4218+                     .map (CacheConfiguration ::getName )
4219+                     .collect (Collectors .toList ());
4220+ 
4221+                 return  String .format (CACHE_NAMES_AND_OPERATION_FORMAT , cacheNames , "dynamicStartCachesByStoredConf" );
4222+             });
4223+         }
42074224
42084225        GridPlainClosure <Collection <byte []>, IgniteInternalFuture <Boolean >> startCacheClsr  = (grpKeys ) -> {
42094226            List <DynamicCacheChangeRequest > srvReqs  = null ;
@@ -4305,8 +4322,10 @@ public IgniteInternalFuture<Boolean> dynamicDestroyCache(
43054322    ) {
43064323        assert  cacheName  != null ;
43074324
4308-         if  (checkThreadTx )
4309-             checkEmptyTransactions ();
4325+         if  (checkThreadTx ) {
4326+             checkEmptyTransactionsEx (() -> String .format (CACHE_NAME_AND_OPERATION_FORMAT , cacheName ,
4327+                 "dynamicDestroyCache" ));
4328+         }
43104329
43114330        DynamicCacheChangeRequest  req  = DynamicCacheChangeRequest .stopRequest (ctx , cacheName , sql , true );
43124331
@@ -4338,8 +4357,10 @@ public IgniteInternalFuture<?> dynamicDestroyCaches(
43384357        boolean  checkThreadTx ,
43394358        boolean  destroy 
43404359    ) {
4341-         if  (checkThreadTx )
4342-             checkEmptyTransactions ();
4360+         if  (checkThreadTx ) {
4361+             checkEmptyTransactionsEx (() -> String .format (CACHE_NAMES_AND_OPERATION_FORMAT , cacheNames ,
4362+                 "dynamicDestroyCaches" ));
4363+         }
43434364
43444365        List <DynamicCacheChangeRequest > reqs  = new  ArrayList <>(cacheNames .size ());
43454366
@@ -4425,7 +4446,7 @@ IgniteInternalFuture<?> dynamicCloseCache(String cacheName) {
44254446        if  (proxy  == null  || proxy .isProxyClosed ())
44264447            return  new  GridFinishedFuture <>(); // No-op. 
44274448
4428-         checkEmptyTransactions ( );
4449+         checkEmptyTransactionsEx (() ->  String . format ( CACHE_NAME_AND_OPERATION_FORMAT ,  cacheName ,  "dynamicCloseCache" ) );
44294450
44304451        if  (proxy .context ().isLocal ())
44314452            return  dynamicDestroyCache (cacheName , false , true , false , null );
@@ -4440,11 +4461,14 @@ IgniteInternalFuture<?> dynamicCloseCache(String cacheName) {
44404461     * @return Future that will be completed when state is changed for all caches. 
44414462     */ 
44424463    public  IgniteInternalFuture <?> resetCacheState (Collection <String > cacheNames ) {
4443-         checkEmptyTransactions ();
4444- 
44454464        if  (F .isEmpty (cacheNames ))
44464465            cacheNames  = cachesInfo .registeredCaches ().keySet ();
44474466
4467+         Collection <String > forCheckCacheNames  = cacheNames ;
4468+ 
4469+         checkEmptyTransactionsEx (() -> String .format (CACHE_NAME_AND_OPERATION_FORMAT , forCheckCacheNames ,
4470+             "resetCacheState" ));
4471+ 
44484472        Collection <DynamicCacheChangeRequest > reqs  = new  ArrayList <>(cacheNames .size ());
44494473
44504474        for  (String  cacheName  : cacheNames ) {
@@ -5639,6 +5663,23 @@ public void checkEmptyTransactions() throws IgniteException {
56395663            throw  new  IgniteException ("Cannot start/stop cache within lock or transaction." );
56405664    }
56415665
5666+     /** 
5667+      * Method invoke {@link #checkEmptyTransactions()} and add message in case exception. 
5668+      * 
5669+      * @param eMsgSupplier supplier additional text message 
5670+      * @throws IgniteException If {@link #checkEmptyTransactions()} throw {@link IgniteException} 
5671+      * */ 
5672+     private  void  checkEmptyTransactionsEx (final  Supplier <String > eMsgSupplier ) throws  IgniteException  {
5673+         assert  eMsgSupplier  != null ;
5674+ 
5675+         try  {
5676+             checkEmptyTransactions ();
5677+         }
5678+         catch  (IgniteException  e ) {
5679+             throw  new  IgniteException (e .getMessage () + ' '  + eMsgSupplier .get (), e );
5680+         }
5681+     }
5682+ 
56425683    /** 
56435684     * @param val Object to check. 
56445685     * @return Configuration copy. 
0 commit comments