hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject incubator-hawq git commit: HAWQ-200. Add the logic of freeing unused AO segment file status
Date Thu, 03 Dec 2015 02:38:08 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 9e151e069 -> 13e713c18


HAWQ-200. Add the logic of freeing unused AO segment file status


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/13e713c1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/13e713c1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/13e713c1

Branch: refs/heads/master
Commit: 13e713c182919a69b6f90ce87c74cae71fdb6ca5
Parents: 9e151e0
Author: Lirong Jian <jianlirong@gmail.com>
Authored: Wed Dec 2 14:08:18 2015 +0800
Committer: Lirong Jian <jianlirong@gmail.com>
Committed: Thu Dec 3 10:30:37 2015 +0800

----------------------------------------------------------------------
 .../access/appendonly/appendonlywriter.c        | 42 +++++++++++++++++++-
 1 file changed, 40 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/13e713c1/src/backend/access/appendonly/appendonlywriter.c
----------------------------------------------------------------------
diff --git a/src/backend/access/appendonly/appendonlywriter.c b/src/backend/access/appendonly/appendonlywriter.c
index b53bf83..cd5c011 100644
--- a/src/backend/access/appendonly/appendonlywriter.c
+++ b/src/backend/access/appendonly/appendonlywriter.c
@@ -1672,14 +1672,52 @@ void ValidateAppendOnlyMetaDataSnapshot(
 	// Placeholder.
 }
 
+static bool
+AORelFreeSegfileStatus()
+{
+  HASH_SEQ_STATUS status;
+  AORelHashEntryData  *hentry;
+  bool freedOne = false;
+  /*
+   * loop through all entries looking for an unused one
+   */
+  hash_seq_init(&status, AppendOnlyHash);
+
+  while ((hentry = (AORelHashEntryData *) hash_seq_search(&status)) != NULL)
+  {
+    if(hentry->txns_using_rel == 0 && InvalidTransactionId==hentry->staleTid)
+    {
+      if (Debug_appendonly_print_segfile_choice)
+      {
+        ereport(LOG, (errmsg("AppendOnlyRelHashNew: Appendonly Writer removing an "
+                   "unused entry (rel %d) to make "
+                   "room for a new one",
+                   hentry->relid)));
+      }
+
+      /* remove this unused entry */
+      /* TODO: remove the LRU entry, not just any unused one */
+      freedOne = AORelRemoveHashEntry(hentry->relid, false);
+      hash_seq_term(&status);
+      break;
+    }
+  }
+  return freedOne;
+}
+
 static int
 AORelGetSegfileStatus(void)
 {
 	int result;
 
-	if (AppendOnlyWriter->num_existing_segfilestatus + 1 > MaxAORelSegFileStatus)
+
+	while (AppendOnlyWriter->num_existing_segfilestatus + 1 > MaxAORelSegFileStatus)
 	{
-		return NEXT_END_OF_LIST;
+	  bool freedOne = AORelFreeSegfileStatus();
+	  if (!freedOne)
+	  {
+	    return NEXT_END_OF_LIST;
+	  }
 	}
 
 	result = AppendOnlyWriter->head_free_segfilestatus;


Mime
View raw message