zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

Blame SOURCES/0035-Issue-4581-A-failed-re-indexing-leaves-the-database-.patch

3280a9
From e6536aa27bfdc27cad07f6c5cd3312f0f0710c96 Mon Sep 17 00:00:00 2001
ef1f48
From: tbordaz <tbordaz@redhat.com>
ef1f48
Date: Mon, 1 Feb 2021 09:28:25 +0100
3280a9
Subject: [PATCH 3/3] Issue 4581 - A failed re-indexing leaves the database in
ef1f48
 broken state (#4582)
ef1f48
ef1f48
Bug description:
ef1f48
	During reindex the numsubordinates attribute is not updated in parent entries.
ef1f48
	The consequence is that the internal counter job->numsubordinates==0.
ef1f48
	Later when indexing the ancestorid, the server can show the progression of this
ef1f48
	indexing with a ratio using job->numsubordinates==0.
ef1f48
	Division with 0 -> SIGFPE
ef1f48
ef1f48
Fix description:
ef1f48
	if the numsubordinates is NULL, log a message without a division.
ef1f48
ef1f48
relates: https://github.com/389ds/389-ds-base/issues/4581
ef1f48
ef1f48
Reviewed by: Pierre Rogier, Mark Reynolds, Simon Pichugin, Teko Mihinto (thanks !!)
ef1f48
ef1f48
Platforms tested: F31
ef1f48
---
ef1f48
 .../slapd/back-ldbm/db-bdb/bdb_import.c       | 72 ++++++++++++++-----
ef1f48
 1 file changed, 54 insertions(+), 18 deletions(-)
ef1f48
ef1f48
diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c
3280a9
index ba783ee59..7f484934f 100644
ef1f48
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c
ef1f48
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import.c
ef1f48
@@ -468,18 +468,30 @@ bdb_get_nonleaf_ids(backend *be, DB_TXN *txn, IDList **idl, ImportJob *job)
ef1f48
         }
ef1f48
         key_count++;
ef1f48
         if (!(key_count % PROGRESS_INTERVAL)) {
ef1f48
-            import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids",
ef1f48
-                              "Gathering ancestorid non-leaf IDs: processed %d%% (ID count %d)",
ef1f48
-                              (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            if (job->numsubordinates) {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids",
ef1f48
+                                  "Gathering ancestorid non-leaf IDs: processed %d%% (ID count %d)",
ef1f48
+                                  (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            } else {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids",
ef1f48
+                                  "Gathering ancestorid non-leaf IDs: processed %d ancestors...",
ef1f48
+                                  key_count);
ef1f48
+            }
ef1f48
             started_progress_logging = 1;
ef1f48
         }
ef1f48
     } while (ret == 0 && !(job->flags & FLAG_ABORT));
ef1f48
 
ef1f48
     if (started_progress_logging) {
ef1f48
         /* finish what we started logging */
ef1f48
-        import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids",
ef1f48
-                          "Gathering ancestorid non-leaf IDs: processed %d%% (ID count %d)",
ef1f48
-                          (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+        if (job->numsubordinates) {
ef1f48
+            import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids",
ef1f48
+                              "Gathering ancestorid non-leaf IDs: processed %d%% (ID count %d)",
ef1f48
+                              (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+        } else {
ef1f48
+            import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids",
ef1f48
+                              "Gathering ancestorid non-leaf IDs: processed %d ancestors",
ef1f48
+                              key_count);
ef1f48
+        }
ef1f48
     }
ef1f48
     import_log_notice(job, SLAPI_LOG_INFO, "bdb_get_nonleaf_ids",
ef1f48
                       "Finished gathering ancestorid non-leaf IDs.");
ef1f48
@@ -660,9 +672,15 @@ bdb_ancestorid_default_create_index(backend *be, ImportJob *job)
ef1f48
 
ef1f48
         key_count++;
ef1f48
         if (!(key_count % PROGRESS_INTERVAL)) {
ef1f48
-            import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index",
ef1f48
-                              "Creating ancestorid index: processed %d%% (ID count %d)",
ef1f48
-                              (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            if (job->numsubordinates) {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index",
ef1f48
+                                  "Creating ancestorid index: processed %d%% (ID count %d)",
ef1f48
+                                  (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            } else {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index",
ef1f48
+                                  "Creating ancestorid index: processed %d ancestors...",
ef1f48
+                                  key_count);
ef1f48
+            }
ef1f48
             started_progress_logging = 1;
ef1f48
         }
ef1f48
 
ef1f48
@@ -743,9 +761,15 @@ out:
ef1f48
     if (ret == 0) {
ef1f48
         if (started_progress_logging) {
ef1f48
             /* finish what we started logging */
ef1f48
-            import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index",
ef1f48
-                              "Creating ancestorid index: processed %d%% (ID count %d)",
ef1f48
-                              (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            if (job->numsubordinates) {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index",
ef1f48
+                                  "Creating ancestorid index: processed %d%% (ID count %d)",
ef1f48
+                                  (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            } else {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index",
ef1f48
+                                  "Creating ancestorid index: processed %d ancestors",
ef1f48
+                                  key_count);
ef1f48
+            }
ef1f48
         }
ef1f48
         import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_default_create_index",
ef1f48
                           "Created ancestorid index (old idl).");
ef1f48
@@ -869,9 +893,15 @@ bdb_ancestorid_new_idl_create_index(backend *be, ImportJob *job)
ef1f48
 
ef1f48
         key_count++;
ef1f48
         if (!(key_count % PROGRESS_INTERVAL)) {
ef1f48
-            import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index",
ef1f48
-                              "Creating ancestorid index: progress %d%% (ID count %d)",
ef1f48
-                              (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            if (job->numsubordinates) {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index",
ef1f48
+                                  "Creating ancestorid index: progress %d%% (ID count %d)",
ef1f48
+                                  (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            } else {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index",
ef1f48
+                                  "Creating ancestorid index: progress %d ancestors...",
ef1f48
+                                  key_count);
ef1f48
+            }
ef1f48
             started_progress_logging = 1;
ef1f48
         }
ef1f48
 
ef1f48
@@ -932,9 +962,15 @@ out:
ef1f48
     if (ret == 0) {
ef1f48
         if (started_progress_logging) {
ef1f48
             /* finish what we started logging */
ef1f48
-            import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index",
ef1f48
-                              "Creating ancestorid index: processed %d%% (ID count %d)",
ef1f48
-                              (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            if (job->numsubordinates) {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index",
ef1f48
+                                  "Creating ancestorid index: processed %d%% (ID count %d)",
ef1f48
+                                  (key_count * 100 / job->numsubordinates), key_count);
ef1f48
+            } else {
ef1f48
+                import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index",
ef1f48
+                                  "Creating ancestorid index: processed %d ancestors",
ef1f48
+                                  key_count);
ef1f48
+            }
ef1f48
         }
ef1f48
         import_log_notice(job, SLAPI_LOG_INFO, "bdb_ancestorid_new_idl_create_index",
ef1f48
                           "Created ancestorid index (new idl).");
ef1f48
-- 
ef1f48
2.26.2
ef1f48