diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 9b1d99d3730..b19353343fb 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -4317,6 +4317,8 @@ prepare_inplace_alter_table_dict(
 	dict_add_v_col_t*	add_v = NULL;
 	ha_innobase_inplace_ctx*ctx;
 
+	ut_d(bool stats_wait = false);
+
 	DBUG_ENTER("prepare_inplace_alter_table_dict");
 
 	ctx = static_cast<ha_innobase_inplace_ctx*>
@@ -4481,6 +4483,7 @@ prepare_inplace_alter_table_dict(
 	XXX what may happen if bg stats opens the table after we
 	have unlocked data dictionary below? */
 	dict_stats_wait_bg_to_stop_using_table(user_table, ctx->trx);
+	ut_d(stats_wait = true);
 
 	online_retry_drop_indexes_low(ctx->new_table, ctx->trx);
 
@@ -5120,7 +5123,9 @@ prepare_inplace_alter_table_dict(
 		/* n_ref_count must be 1, because purge cannot
 		be executing on this very table as we are
 		holding dict_operation_lock X-latch. */
-		DBUG_ASSERT(user_table->get_ref_count() == 1 || ctx->online);
+		DBUG_ASSERT(!stats_wait
+			    || user_table->get_ref_count() == 1
+			    || ctx->online);
 
 		online_retry_drop_indexes_with_trx(user_table, ctx->trx);
 	} else {
