[Commits] b1ec35b9030: Add assertions when key rotation list is used.

jan jan.lindstrom at mariadb.com
Thu Mar 16 17:30:29 EET 2017


revision-id: b1ec35b90303446d2f1a5810455bcafbc091f928 (mariadb-10.1.22-7-gb1ec35b9030)
parent(s): c333cae652491998c34526ab0b5bfc3ecb2fe474
author: Jan Lindström
committer: Jan Lindström
timestamp: 2017-03-16 17:30:13 +0200
message:

Add assertions when key rotation list is used.

---
 storage/innobase/fil/fil0fil.cc | 6 ++++--
 storage/xtradb/fil/fil0fil.cc   | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 74a33b4e4ff..627a63aaae0 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -1602,8 +1602,8 @@ fil_space_create(
 		/* Key rotation is not enabled, need to inform background
 		encryption threads. */
 		UT_LIST_ADD_LAST(rotation_list, fil_system->rotation_list, space);
-		mutex_exit(&fil_system->mutex);
 		space->is_in_rotation_list = true;
+		mutex_exit(&fil_system->mutex);
 		mutex_enter(&fil_crypt_threads_mutex);
 		os_event_set(fil_crypt_threads_event);
 		mutex_exit(&fil_crypt_threads_mutex);
@@ -1725,6 +1725,7 @@ fil_space_free(
 
 	if (space->is_in_rotation_list) {
 		space->is_in_rotation_list = false;
+		ut_a(UT_LIST_GET_LEN(fil_system->rotation_list) > 0);
 		UT_LIST_REMOVE(rotation_list, fil_system->rotation_list, space);
 	}
 
@@ -7401,8 +7402,9 @@ fil_space_remove_from_keyrotation(
 	ut_ad(mutex_own(&fil_system->mutex));
 	ut_ad(space);
 
-	if (space->n_pending_ops == 0) {
+	if (space->n_pending_ops == 0 && space->is_in_rotation_list) {
 		space->is_in_rotation_list = false;
+		ut_a(UT_LIST_GET_LEN(fil_system->rotation_list) > 0);
 		UT_LIST_REMOVE(rotation_list, fil_system->rotation_list, space);
 	}
 }
diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc
index 36900839160..a116bfad99d 100644
--- a/storage/xtradb/fil/fil0fil.cc
+++ b/storage/xtradb/fil/fil0fil.cc
@@ -1640,8 +1640,8 @@ fil_space_create(
 		/* Key rotation is not enabled, need to inform background
 		encryption threads. */
 		UT_LIST_ADD_LAST(rotation_list, fil_system->rotation_list, space);
-		mutex_exit(&fil_system->mutex);
 		space->is_in_rotation_list = true;
+		mutex_exit(&fil_system->mutex);
 		mutex_enter(&fil_crypt_threads_mutex);
 		os_event_set(fil_crypt_threads_event);
 		mutex_exit(&fil_crypt_threads_mutex);
@@ -1763,6 +1763,7 @@ fil_space_free(
 
 	if (space->is_in_rotation_list) {
 		space->is_in_rotation_list = false;
+		ut_a(UT_LIST_GET_LEN(fil_system->rotation_list) > 0);
 		UT_LIST_REMOVE(rotation_list, fil_system->rotation_list, space);
 	}
 
@@ -7514,8 +7515,9 @@ fil_space_remove_from_keyrotation(
 	ut_ad(mutex_own(&fil_system->mutex));
 	ut_ad(space);
 
-	if (space->n_pending_ops == 0) {
+	if (space->n_pending_ops == 0 && space->is_in_rotation_list) {
 		space->is_in_rotation_list = false;
+		ut_a(UT_LIST_GET_LEN(fil_system->rotation_list) > 0);
 		UT_LIST_REMOVE(rotation_list, fil_system->rotation_list, space);
 	}
 }


More information about the commits mailing list