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

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