You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by jg...@apache.org on 2022/04/19 20:43:45 UTC

[incubator-age] branch master updated: Fix global graph hashtable insert messaging

This is an automated email from the ASF dual-hosted git repository.

jgemignani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-age.git


The following commit(s) were added to refs/heads/master by this push:
     new 7340abb  Fix global graph hashtable insert messaging
7340abb is described below

commit 7340abbb76357b3a3e9d0950b26a177ae47a6d0f
Author: John Gemignani <jr...@gmail.com>
AuthorDate: Tue Apr 19 13:41:23 2022 -0700

    Fix global graph hashtable insert messaging
    
    Fixed the global graph hashtable routines to error out, instead of
    crashing due to an assert, for duplicate ids.
---
 src/backend/utils/adt/age_global_graph.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/backend/utils/adt/age_global_graph.c b/src/backend/utils/adt/age_global_graph.c
index 9615ba8..a1b1f30 100644
--- a/src/backend/utils/adt/age_global_graph.c
+++ b/src/backend/utils/adt/age_global_graph.c
@@ -258,7 +258,7 @@ static bool insert_edge(GRAPH_global_context *ggctx, graphid edge_id,
 
 /*
  * Helper function to insert an entire vertex into the current GRAPH global
- * vertex hashtable.
+ * vertex hashtable. It will return false if there is a duplicate.
  */
 static bool insert_vertex_entry(GRAPH_global_context *ggctx, graphid vertex_id,
                                 Oid vertex_label_table_oid,
@@ -270,8 +270,12 @@ static bool insert_vertex_entry(GRAPH_global_context *ggctx, graphid vertex_id,
     /* search for the vertex */
     ve = (vertex_entry *)hash_search(ggctx->vertex_hashtable,
                                      (void *)&vertex_id, HASH_ENTER, &found);
-    /* we should never have duplicates */
-    Assert(!found);
+
+    /* we should never have duplicates, return false */
+    if (found)
+    {
+        return false;
+    }
 
     /* again, MemSet may not be needed here */
     MemSet(ve, 0, sizeof(vertex_entry));
@@ -417,10 +421,11 @@ static void load_vertex_hashtable(GRAPH_global_context *ggctx)
             inserted = insert_vertex_entry(ggctx, vertex_id,
                                            vertex_label_table_oid,
                                            vertex_properties);
-            /* this insert must not fail */
+
+            /* this insert must not fail, it means there is a duplicate */
             if (!inserted)
             {
-                 elog(ERROR, "insert_vertex_entry: failed to insert");
+                 elog(ERROR, "insert_vertex_entry: failed due to duplicate");
             }
         }
 
@@ -528,6 +533,7 @@ static void load_edge_hashtable(GRAPH_global_context *ggctx)
             inserted = insert_edge(ggctx, edge_id, edge_properties,
                                    edge_vertex_start_id, edge_vertex_end_id,
                                    edge_label_table_oid);
+
             /* this insert must not fail */
             if (!inserted)
             {