All,
Please see attached test program. It is modified based on chpt_demo.
Thanks.
Ted
-----Original Message-----
From: Ingvar Bergström [mailto:[email protected]]
Sent: Tuesday, May 12, 2015 1:04 PM
To: Yao Cheng LIANG; [email protected]
Subject: RE: ckptnd memory leak(very serious)
Hi,
I can create an OpenSAF ticket as a place holder for your findings.
To make things easier for any person who want to dig into this:
-Can you attach source code to the ckperf binary so it is possible to see the
use case?
also
-Can you attach the source code for "I created 500,0000 sections first and then
overwrite it with some data" use case, which I assume was the test case for
the attached valgrind reports (or is this the ckperf binary used on two
controllers started with "ckperf 1" and "ckperf 0"??)
BR
Ingvar
-----Original Message-----
From: Yao Cheng LIANG [mailto:[email protected]]
Sent: den 12 maj 2015 03:43
To: Yao Cheng LIANG; [email protected]
Subject: Re: [users] ckptnd memory leak(very serious)
The issue is very easy to reproduce. I am running 4.6 with two controllers on
RHEL 6.5 x86_64, and if you run the attached app on one node with command line
"ckperf 1" on one node and "ckperf 0" on another. You will observe ckptnd
memory increased very rapidly with cmd "top -p pid_of_ckptnd".
BTW, I am running with TIPC.
Ted
-----Original Message-----
From: Yao Cheng LIANG [mailto:[email protected]]
Sent: Tuesday, May 12, 2015 5:47 AM
To: [email protected]
Subject: [users] Fwd: ckptnd memory leak(very serious)
Resend
Sent from Samsung Mobile
-------- Original message --------
From: Yao Cheng LIANG
Date:2015/05/11 5:48 PM (GMT+08:00)
To: [email protected]
Cc: Yao Cheng LIANG
Subject: ckptnd memory leak(very serious)
All,
I did some tests recently on ckptnd. I created 500,0000 sections first and then
overwrite it with some data. And found serious memory leak. Please see attached
file for valgrind report.
Thanks.
Ted
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
* under the GNU Lesser General Public License Version 2.1, February 1999.
* The complete license can be accessed from the following location:
* http://opensource.org/licenses/lgpl-license.php
* See the Copying file included with the OpenSAF distribution for full
* licensing terms.
*
* Author(s): Emerson Network Power
*/
#include <stdio.h>
#include <stdlib.h>
extern void cpsv_test_sync_app_process(void *info);
int main(int argc, char *argv[])
{
unsigned int temp_var;
if (argc != 2)
{
printf("\nWrong Arguments USAGE: <ckpt_demo><1(Writer)/0(Reader)>\n");
return -1;
}
temp_var = atoi(argv[1]);
/* initiliase the Environment */
/* ncs_agents_startup(0, 0); */
/* start the application */
cpsv_test_sync_app_process((void *)(long)temp_var);
return 0;
}
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
* under the GNU Lesser General Public License Version 2.1, February 1999.
* The complete license can be accessed from the following location:
* http://opensource.org/licenses/lgpl-license.php
* See the Copying file included with the OpenSAF distribution for full
* licensing terms.
*
* Author(s): Emerson Network Power
*/
/*****************************************************************************
..............................................................................
MODULE NAME: cpsv_test_app.c (CPSv Test Functions)
.............................................................................
DESCRIPTION:
CPSv routines required for Demo Applications.
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <saCkpt.h>
#include <cpsv_papi.h>
#define DEMO_CKPT_NAME "safCkpt=PerfAsyncCkpt,safApp=safCkptService"
#define CHECKPOINT_OPEN_INVOCATION 0X1234
int ckpt_para = 0;
SaCkptCheckpointHandleT checkpointHandle;
SaCkptHandleT ckptHandle;
int ckpt_opened = 0;
void AppCkptOpenCallback(SaInvocationT invocation, SaCkptCheckpointHandleT
checkpointHandle, SaAisErrorT error);
void AppCkptSyncCallback(SaInvocationT invocation, SaAisErrorT error);
void cpsv_test_sync_app_process(void *info);
unsigned char ckpt_data[4000];
long long data_arrv = 0;
void CkptDataCallback (const SaCkptCheckpointHandleT checkpointHandle,
SaCkptIOVectorElementT *ioVector,
SaUint32T numberOfElements)
{
SaAisErrorT rc;
SaUint32T erroneousVectorIndex;
int i;
data_arrv++;
if (0 == data_arrv % 5000)
printf("CkptDataCallback interval 5000 total %ld\n", data_arrv);
return;
for (i = 0; i < numberOfElements; i++)
{
ioVector[i].dataBuffer = ckpt_data;
rc = saCkptCheckpointRead(checkpointHandle, &ioVector[i], 1,
&erroneousVectorIndex);
printf ("saCkptCheckpointRead rc %d\n", rc);
}
}
void AppCkptOpenCallback(SaInvocationT invocation, SaCkptCheckpointHandleT
cb_checkpointHandle, SaAisErrorT error)
{
SaAisErrorT rc;
printf("AppCkptOpenCallback invoc %lx\n", invocation);
if (invocation == CHECKPOINT_OPEN_INVOCATION)
{
checkpointHandle = cb_checkpointHandle;
ckpt_opened = 1;
rc = ncsCkptRegisterCkptArrivalCallback(ckptHandle,
CkptDataCallback);
printf("ncsCkptRegisterCkptArrivalCallback rc %d\n", rc);
if (rc != SA_AIS_OK)
return;
if (ckpt_para)
{
rc = saCkptActiveReplicaSet(checkpointHandle);
printf("saCkptActiveReplicaSet rc %d\n", rc);
if (rc != SA_AIS_OK)
return;
}
}
}
void AppCkptSyncCallback(SaInvocationT invocation, SaAisErrorT error)
{
if (error != SA_AIS_OK)
{
printf("Checkpoint Sync Callback unsuccessful\n");
return;
}
else
{
printf("Checkpoint Sync Callback success\n");
return;
}
}
/****************************************************************************
* Name : cpsv_test_sync_app_process
*
* Description : This is the function which is given as the input to the
* Application task.
*
* Arguments : info - This is the information which is passed during
* spawing Application task.
*
* Return Values : None.
*
* Notes : None.
*****************************************************************************/
void cpsv_test_sync_app_process(void *info)
{
SaCkptCallbacksT callbk;
SaVersionT version;
SaNameT ckptName;
SaAisErrorT rc;
SaCkptCheckpointCreationAttributesT ckptCreateAttr;
SaCkptCheckpointOpenFlagsT ckptOpenFlags;
SaCkptSectionCreationAttributesT sectionCreationAttributes;
SaCkptIOVectorElementT writeVector, readVector;
SaUint32T erroneousVectorIndex;
char initialData[1024] = "initialData1111";
unsigned char read_buff[100] = {0};
SaTimeT timeout = 1000000000;
unsigned int temp_var = (unsigned int)(long)info;
long num = 1, count = 0;
int i, batch = 0;
char num_str[64];
memset(&ckptName, 0, 255);
ckptName.length = strlen(DEMO_CKPT_NAME);
memcpy(ckptName.value,DEMO_CKPT_NAME,strlen(DEMO_CKPT_NAME));
callbk.saCkptCheckpointOpenCallback = AppCkptOpenCallback;
callbk.saCkptCheckpointSynchronizeCallback = AppCkptSyncCallback;
version.releaseCode= 'B';
version.majorVersion = 2;
version.minorVersion = 2;
printf("*******************************************************************\n");
printf("Demonstrating Checkpoint Service Usage with a collocated Checkpoint
\n");
printf("*******************************************************************\n");
sleep(2);
printf("Initialising With Checkpoint Service....\n");
rc = saCkptInitialize(&ckptHandle,&callbk,&version);
if(rc == SA_AIS_OK)
printf("PASSED \n");
else
printf("Failed \n");
ckptCreateAttr.creationFlags =
SA_CKPT_CHECKPOINT_COLLOCATED|SA_CKPT_WR_ACTIVE_REPLICA;
ckptCreateAttr.checkpointSize = 1024<<20; /* 1G */
ckptCreateAttr.retentionDuration= 100000;
ckptCreateAttr.maxSections= 5 * (1 << 18); /* 250k */
ckptCreateAttr.maxSectionSize = 4 * (1 << 10); /* 4K */
ckptCreateAttr.maxSectionIdSize = 64;
ckptOpenFlags =
SA_CKPT_CHECKPOINT_CREATE|SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE;
printf("Opening Collocated Async Checkpoint = %s with create
flags....\n",ckptName.value);
rc = saCkptCheckpointOpenAsync(ckptHandle, CHECKPOINT_OPEN_INVOCATION,
&ckptName, &ckptCreateAttr, ckptOpenFlags);
if(rc == SA_AIS_OK)
printf("PASSED \n");
else
printf("Failed \n");
ckpt_para = temp_var;
while (0 == ckpt_opened)
{
usleep(10000);
saCkptDispatch(ckptHandle, SA_DISPATCH_ALL);
}
printf("saCkptCheckpointOpenAsync Finished, start to test. \n");
if(temp_var == 1)
{
#if 0
printf("Setting the Active Replica for my checkpoint ....\t");
rc = saCkptActiveReplicaSet(checkpointHandle);
if(rc == SA_AIS_OK)
printf("PASSED \n");
else
printf("Failed \n");
#endif
printf("Start to create checkpoint section ....\n");
num = 1;
count = 0;
//batch++;
while (++count <= 10) {
time_t cur;
time(&cur);
long ms; // Milliseconds
time_t s; // Seconds
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
s = spec.tv_sec;
ms = (spec.tv_nsec / 1000000); // Convert nanoseconds to
milliseconds
for(i=0; i<5000;i++) {
//create data to checkpoint
sectionCreationAttributes.sectionId =
(SaCkptSectionIdT*) malloc(sizeof(SaCkptSectionIdT));
sprintf(num_str, "%s%d%d", "Index", num++, batch);
sectionCreationAttributes.sectionId->id = (unsigned
char *)num_str;
sectionCreationAttributes.sectionId->idLen =
strlen(num_str);
sectionCreationAttributes.expirationTime =
3600000000000ll; /* One Hour */
rc =
saCkptSectionCreate(checkpointHandle,§ionCreationAttributes,initialData,sizeof(initialData));
if (rc != SA_AIS_OK){
printf("Failed num %ld\n", num);
exit(0);
}
}
time_t cur1;
time(&cur1);
long ms1; // Milliseconds
time_t s1; // Seconds
struct timespec spec1;
clock_gettime(CLOCK_REALTIME, &spec1);
s1 = spec1.tv_sec;
ms1 = (spec1.tv_nsec / 1000000); // Convert nanoseconds to
milliseconds
printf("#%d - 5000 writes - %f seconds\n", count, (float)(s1 -
s) + ((float)(ms1-ms))/1000);
}
//sleep(1);
//printf("Press <Enter> key to continue...\n");
//getchar();
printf("Start to overwrite checkpoint section ....\n");
repeat:
num = 1;
count = 0;
while (++count <= 10) {
time_t cur;
time(&cur);
long ms; // Milliseconds
time_t s; // Seconds
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
s = spec.tv_sec;
ms = (spec.tv_nsec / 1000000); // Convert nanoseconds to
milliseconds
for(i=0; i<5000;i++) {
//create data to checkpoint
SaCkptIOVectorElementT writeVector;
sprintf(num_str, "%s%d%d", "Index", num++, batch);
writeVector.sectionId.id = (unsigned char *)num_str;
writeVector.sectionId.idLen = strlen(num_str);
writeVector.dataBuffer = initialData;
writeVector.dataSize = sizeof(initialData);
writeVector.dataOffset = 0;
writeVector.readSize = 0;
rc = saCkptSectionOverwrite(checkpointHandle,
&writeVector.sectionId, writeVector.dataBuffer, writeVector.dataSize);
#if 0
sectionCreationAttributes.sectionId =
(SaCkptSectionIdT*) malloc(sizeof(SaCkptSectionIdT));
sprintf(num_str, "%s%d%d", "Index", num++, batch);
sectionCreationAttributes.sectionId->id = (unsigned
char *)num_str;
sectionCreationAttributes.sectionId->idLen =
strlen(num_str);
sectionCreationAttributes.expirationTime =
3600000000000ll; /* One Hour */
rc =
saCkptSectionOverwrite(checkpointHandle,sectionCreationAttributes.sectionId,initialData,sizeof(initialData));
//rc = saCkptSectionDelete(checkpointHandle,
sectionCreationAttributes.sectionId);
#endif
if (rc != SA_AIS_OK){
printf("Failed num %ld\n", num);
exit(0);
}
}
time_t cur1;
time(&cur1);
long ms1; // Milliseconds
time_t s1; // Seconds
struct timespec spec1;
clock_gettime(CLOCK_REALTIME, &spec1);
s1 = spec1.tv_sec;
ms1 = (spec1.tv_nsec / 1000000); // Convert nanoseconds to
milliseconds
printf("#%d - 5000 overwrite - %f seconds\n", count, (float)(s1
- s) + ((float)(ms1-ms))/1000);
}
goto repeat;
sleep(1);
printf("Press <Enter> key to continue...\n");
getchar();
}
else
{
while (1) {
usleep(10000);
saCkptDispatch(ckptHandle, SA_DISPATCH_ALL);
}
}
sleep(2);
return;
}
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensaf-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-users