hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iw...@apache.org
Subject [1/3] incubator-hawq git commit: HAWQ-284. Add a udf for new metadata flush strategy testing.
Date Mon, 04 Jan 2016 04:23:54 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master af6cfe880 -> fde3b4fc9


HAWQ-284. Add a udf for new metadata flush strategy testing.


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

Branch: refs/heads/master
Commit: 56159c324a0549d476cd5280d4626aff18440c7e
Parents: 2ba5a19
Author: stanlyxiang <stanly.sxiang@gmail.com>
Authored: Wed Dec 30 16:58:04 2015 +0800
Committer: stanlyxiang <stanly.sxiang@gmail.com>
Committed: Wed Dec 30 16:58:04 2015 +0800

----------------------------------------------------------------------
 src/backend/cdb/cdbmetadatacache.c           | 53 +++++++++++++++++++++++
 src/include/catalog/pg_proc.h                |  4 ++
 src/include/catalog/pg_proc.sql              |  2 +
 src/include/utils/builtins.h                 |  1 +
 src/test/regress/data/upgrade20/pg_proc.data |  1 +
 5 files changed, 61 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56159c32/src/backend/cdb/cdbmetadatacache.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbmetadatacache.c b/src/backend/cdb/cdbmetadatacache.c
index f4c2369..fedcfbd 100644
--- a/src/backend/cdb/cdbmetadatacache.c
+++ b/src/backend/cdb/cdbmetadatacache.c
@@ -1400,3 +1400,56 @@ extern Datum gp_metadata_cache_info(PG_FUNCTION_ARGS)
     PG_RETURN_TEXT_P(cstring_to_text(message));    
 }
 
+/*
+ *  Metadata Cache UDF
+ *
+ *  Get entry info in the metadata cache
+ */
+extern Datum gp_metadata_cache_putentry_fortest(PG_FUNCTION_ARGS)
+{
+    Oid tablespace_oid = PG_GETARG_OID(0);
+    Oid database_oid = PG_GETARG_OID(1);
+    Oid relation_oid = PG_GETARG_OID(2);
+    int4 start = PG_GETARG_INT32(3);
+    int4 end = PG_GETARG_INT32(4);
+
+    LWLockAcquire(MetadataCacheLock, LW_EXCLUSIVE);
+
+    int i;
+    int4 stop = (start -end) / 10;
+    int4 current = 0;
+    int4 success = 0;
+    for(i=start;i<end;i++)
+    {
+    	MetadataCacheKey key;
+    	key.tablespace_oid = tablespace_oid;
+    	key.database_oid = database_oid;
+    	key.relation_oid = relation_oid;
+    	key.segno = i;
+
+    	bool found;
+    	MetadataCacheEntry *entry = (MetadataCacheEntry *)hash_search(MetadataCache, (void *)&key,
HASH_ENTER_NULL, &found);
+        entry->file_size = 134217728;
+        entry->block_num = 1;
+
+        AllocMetadataBlock(entry->block_num, &entry->first_block_id, &entry->last_block_id);
+
+    	if(entry != NULL)
+    	{
+    		current++;
+    		success++;
+    	}
+    	if(current == stop)
+    	{
+    		current = 0;
+    		LWLockRelease(MetadataCacheLock);
+    		pg_usleep(1 * USECS_PER_SEC);
+    	    LWLockAcquire(MetadataCacheLock, LW_EXCLUSIVE);
+    	}
+    }
+    LWLockRelease(MetadataCacheLock);
+
+    char message[1024] = {0};
+    snprintf(message, 1024, "Metadata cache successed putting %d entries. Failed putting
%d entries.", success, end - start - success);
+    PG_RETURN_TEXT_P(cstring_to_text(message));
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56159c32/src/include/catalog/pg_proc.h
----------------------------------------------------------------------
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 64b7661..2170041 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -10399,6 +10399,10 @@ DESCR("Get metadata cache current entry number");
 DATA(insert OID = 8084 ( gp_metadata_cache_current_block_num  PGNSP PGUID 12 f f t f s 0
20 f "" _null_ _null_ _null_ gp_metadata_cache_current_block_num - _null_ n ));
 DESCR("Get metadata cache current block number");
 
+/* gp_metadata_cache_putentry_fortest => text */
+DATA(insert OID = 8085 ( gp_metadata_cache_putentry_fortest  PGNSP PGUID 12 f f t f s 5 25
f "26 26 26 23 23" _null_ _null_ _null_ gp_metadata_cache_putentry_fortest - _null_ n ));
+DESCR("Put entries into metadata cache");
+
 /* gp_metadata_cache_exists => bool*/ 
 DATA(insert OID = 8082 ( gp_metadata_cache_exists  PGNSP PGUID 12 f f t f s 4 16 f "26 26
26 23" _null_ _null_ _null_ gp_metadata_cache_exists - _null_ n ));
 DESCR("Check whether metadata cache key exists");

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56159c32/src/include/catalog/pg_proc.sql
----------------------------------------------------------------------
diff --git a/src/include/catalog/pg_proc.sql b/src/include/catalog/pg_proc.sql
index d0fa636..dc871a8 100644
--- a/src/include/catalog/pg_proc.sql
+++ b/src/include/catalog/pg_proc.sql
@@ -5512,4 +5512,6 @@
 
  CREATE FUNCTION gp_metadata_cache_info(tablespace_oid, database_oid, relation_oid, segno)
RETURNS text LANGUAGE internal STABLE STRICT AS 'gp_metadata_cache_info' WITH (OID=8083, DESCRIPTION="Get
metadata cache info for specific key");
  
+ CREATE FUNCTION gp_metadata_cache_putentry_fortest(tablespace_oid, database_oid, relation_oid,
segno) RETURNS text LANGUAGE internal STABLE STRICT AS 'gp_metadata_cache_putentry_fortest'
WITH (OID=8085, DESCRIPTION="Put entries into metadata cache for test");
+ 
  CREATE FUNCTION dump_resource_manager_status(info_type) RETURNS text LANGUAGE internal STABLE
STRICT AS 'dump_resource_manager_status' WITH (OID=6450, DESCRIPTION="Dump resource manager
status for testing");

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56159c32/src/include/utils/builtins.h
----------------------------------------------------------------------
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 75742d3..e9f60cd 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -1200,5 +1200,6 @@ extern Datum gp_metadata_cache_current_num(PG_FUNCTION_ARGS);
 extern Datum gp_metadata_cache_current_block_num(PG_FUNCTION_ARGS);
 extern Datum gp_metadata_cache_exists(PG_FUNCTION_ARGS);
 extern Datum gp_metadata_cache_info(PG_FUNCTION_ARGS);
+extern Datum gp_metadata_cache_putentry_fortest(PG_FUNCTION_ARGS);
 
 #endif   /* BUILTINS_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56159c32/src/test/regress/data/upgrade20/pg_proc.data
----------------------------------------------------------------------
diff --git a/src/test/regress/data/upgrade20/pg_proc.data b/src/test/regress/data/upgrade20/pg_proc.data
index c39642c..2a19a7d 100644
--- a/src/test/regress/data/upgrade20/pg_proc.data
+++ b/src/test/regress/data/upgrade20/pg_proc.data
@@ -7,3 +7,4 @@
 8082,gp_metadata_cache_exists,11,10,12,f,f,t,f,s,4,16,f,"26 26 26 23",,,,gp_metadata_cache_exists,-,,n
 8083,gp_metadata_cache_info,11,10,12,f,f,t,f,s,4,25,f,"26 26 26 23",,,,gp_metadata_cache_info,-,,n
 8084,gp_metadata_cache_current_block_num,11,10,12,f,f,t,f,s,0,20,f,"",,,,gp_metadata_cache_current_block_num,-,,n
+8085,gp_metadata_cache_putentry_fortest,11,10,12,f,f,t,f,s,5,25,f,"26 26 26 23 23",,,,gp_metadata_cache_putentry_fortest,-,,n


Mime
View raw message