[Openais] CKPT: bug, saCkptCheckpointOpen returns 0

Magnus Engberg Magnus.Engberg at ericsson.com
Tue Sep 19 03:11:02 PDT 2006


You are right. The return value _is_ correct. The problem is in my own 
code. Thank you for your time.

Magnus

Steven Dake wrote:
> Magnus,
> 
> comments inline
> 
> On Tue, 2006-09-19 at 08:00 +0200, Magnus Engberg wrote:
> 
>>Hi Steven!
>>
>>I am doing a reference application on top of openais to be used in our 
>>internal testing. The reference application is started as a component by 
>>the aisexec/amf. When using the checkpoint api I come across the 
>>following scenario:
>>
>>1: checkpoint initialized with saCkptInitialize.
>>2: checkpoint opened as below
>>
>>result = saCkptCheckpointOpen(	ckptHandle, &ckptName, NULL,
>>				SA_CKPT_CHECKPOINT_READ |
>>				SA_CKPT_CHECKPOINT_WRITE |
>>				SA_CKPT_CHECKPOINT_CREATE,
>>				SA_TIME_END, &checkpointHandle );
> 
> 
>>result now has the value 0, it should ofcourse be SA_AIS_OK. The 
>>checkpoint is created and a section can later be created with
>>
> 
> 
> according to ais ckpt spec B.02.01 from 2005 the above call should
> return ERR_INVALID_PARAM (see page 36 lines 1-5).  The reason is that
> create was specified without any checkpoint creation flags.
> 
> I tested trunk without the patches from Hans and it does indeed return
> INVALID_PARAM as required by the specification.  Attached is my test
> application.
> 
> Are you sure your linking to the proper library?  There really isn't any
> way for the calls to return the value 0.  Make sure you don't have extra
> libraries installed for sa forum and are linking to the proper
> libraries.
> 
> Until we resolve this issue further calls could possibly be corrupted
> for some reason.
> 
> If you can alter the attached test case to generate the results you see,
> I'd be happy to debug it further.
> 
> Also I posted some time ago a graphical test application (QT based)
> which tests AMF and CKPT failover together.  You might take a look at
> that.  If this application could be modified with your test cases it may
> be useful for all.
> 
> Regards
> -steve
> 
> 
>>3:
>>result = saCkptSectionCreate(	checkpointHandle,
>>				&sectionCreationAttributes,
>>				"Section initial data",
>>				strlen("Section initial data") + 1);
>>
>>result will again get the value 0 when the creation succeeds. The 
>>checkpoint section can now be overwritten with
>>
>>4:
>>result = saCkptSectionOverwrite(checkpointHandle, &sectionId,
>>				dataBuffer, dataSize + 1);
>>
>>Here result get get the corect value (SA_AIS_OK) on success.
>>
>>Please give me your opinion on this matter, I am running the aisexec 
>>compiled from the trunk plus two patches from Hans Feldt (one in the 
>>checkpoint service and one in the amf area).
>>
>>Regards, Magnus
>>_______________________________________________
>>Openais mailing list
>>Openais at lists.osdl.org
>>https://lists.osdl.org/mailman/listinfo/openais
>>
>>
>>------------------------------------------------------------------------
>>
>>#define _BSD_SOURCE
>>/*
>> * Copyright (c) 2006 Red Hats, Inc.
>> *
>> * All rights reserved.
>> *
>> * Author: Steven Dake (sdake at mvista.com)
>> *
>> * This software licensed under BSD license, the text of which follows:
>> * 
>> * Redistribution and use in source and binary forms, with or without
>> * modification, are permitted provided that the following conditions are met:
>> *
>> * - Redistributions of source code must retain the above copyright notice,
>> *   this list of conditions and the following disclaimer.
>> * - Redistributions in binary form must reproduce the above copyright notice,
>> *   this list of conditions and the following disclaimer in the documentation
>> *   and/or other materials provided with the distribution.
>> * - Neither the name of the MontaVista Software, Inc. nor the names of its
>> *   contributors may be used to endorse or promote products derived from this
>> *   software without specific prior written permission.
>> *
>> * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
>> * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
>> * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
>> * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>> * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
>> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
>> * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
>> * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
>> * THE POSSIBILITY OF SUCH DAMAGE.
>> */
>>
>>#include <stdio.h>
>>#include <stdlib.h>
>>#include <string.h>
>>#include <errno.h>
>>#include <unistd.h>
>>#include <sys/types.h>
>>#include <sys/socket.h>
>>#include <sys/select.h>
>>#include <sys/un.h>
>>#include <sys/time.h>
>>
>>#include "saAis.h"
>>#include "saCkpt.h"
>>#include "sa_error.h"
>>
>>#ifdef OPENAIS_SOLARIS
>>#define timersub(a, b, result)						\
>>    do {								\
>>	(result)->tv_sec = (a)->tv_sec - (b)->tv_sec;			\
>>	(result)->tv_usec = (a)->tv_usec - (b)->tv_usec;		\
>>	if ((result)->tv_usec < 0) {					\
>>	    --(result)->tv_sec;						\
>>	    (result)->tv_usec += 1000000;				\
>>	}								\
>>    } while (0)
>>#endif
>>
>>#define SECONDS_TO_EXPIRE 4
>>
>>int ckptinv;
>>SaInvocationT open_invocation = 16;
>>void printSaNameT (SaNameT *name)
>>{
>>	int i;
>>
>>	for (i = 0; i < name->length; i++) {
>>		printf ("%c", name->value[i]);
>>	}
>>}
>>
>>SaVersionT version = { 'B', 1, 1 };
>>
>>SaNameT checkpointName = { 5, "abra\0" };
>>
>>SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
>>	SA_CKPT_WR_ALL_REPLICAS,
>>	100000,
>>	5000000000LL,
>>	10,
>>	200000,
>>	10
>>};
>>
>>SaCkptSectionIdT sectionId1 = {
>>	14,
>>	(SaUint8T *) "section ID #1"
>>};
>>
>>SaCkptSectionIdT sectionId2 = {
>>	14,
>>	(SaUint8T *) "section ID #2"
>>};
>>
>>SaCkptSectionCreationAttributesT sectionCreationAttributes1 = {
>>	&sectionId1,
>>	SA_TIME_END
>>};
>>
>>SaCkptSectionCreationAttributesT sectionCreationAttributes2 = {
>>	&sectionId2,
>>	SA_TIME_END
>>};
>>
>>char readBuffer1[1025];
>>
>>char readBuffer2[1025];
>>
>>char default_read_buffer[1025];
>>
>>SaCkptIOVectorElementT ReadVectorElements[] = {
>>	{
>>		{
>>			14,
>>			(SaUint8T *) "section ID #1"
>>		},
>>		readBuffer1,
>>		sizeof (readBuffer1),
>>		0, 
>>		0
>>	},
>>	{
>>		{
>>			14,
>>			(SaUint8T *) "section ID #2"
>>		},
>>		readBuffer2,
>>		sizeof (readBuffer2),
>>		0, 
>>		0
>>	}
>>};
>>
>>SaCkptIOVectorElementT default_read_vector[] = {
>>	{
>>		SA_CKPT_DEFAULT_SECTION_ID,
>>        default_read_buffer, /*"written data #1, this should extend past end of old section data", */
>>        sizeof(default_read_buffer), /*sizeof ("data #1, this should extend past end of old section data") + 1, */
>>        0, //5,
>>        0
>>    }
>>};
>>
>>
>>#define DATASIZE 127000
>>char data1[DATASIZE];
>>char data2[DATASIZE];
>>char default_write_data[56];
>>SaCkptIOVectorElementT WriteVectorElements[] = {
>>	{
>>		{
>>			14,
>>			(SaUint8T *) "section ID #1"
>>		},
>>		data1, /*"written data #1, this should extend past end of old section data", */
>>		DATASIZE, /*sizeof ("data #1, this should extend past end of old section data") + 1, */
>>		0, //5, 
>>		0
>>	},
>>	{
>>		{
>>			14,
>>			(SaUint8T *) "section ID #2",
>>		},
>>		data2, /*"written data #2, this should extend past end of old section data" */
>>		DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */
>>		0, //3, 
>>		0
>>	}
>>};
>>
>>SaCkptIOVectorElementT default_write_vector[] = {
>>	{
>>		SA_CKPT_DEFAULT_SECTION_ID,
>>		default_write_data, /*"written data #1, this should extend past end of old section data", */	
>>		56, /*sizeof ("data #1, this should extend past end of old section data") + 1, */
>>		0, //5,
>>		0
>>	}
>>};
>>
>>SaCkptCheckpointHandleT checkpointHandle;
>>
>>void OpenCallBack (
>>    SaInvocationT invocation,
>>    const SaCkptCheckpointHandleT chckpointHandle,
>>    SaAisErrorT error) {
>>	
>> 	printf ("%s: This is a call back for open for invocation = %d\n",
>>		get_test_output (error, SA_AIS_OK), (int)invocation);	
>>
>>	checkpointHandle = chckpointHandle;
>>
>>}
>>
>>SaCkptCallbacksT callbacks = {
>> 	&OpenCallBack,
>>	0
>>};
>>
>>int main (void) {
>>	SaCkptHandleT ckptHandle;
>>	SaCkptCheckpointHandleT checkpointHandle2;
>>	SaCkptCheckpointHandleT checkpointHandleRead;
>>	SaCkptCheckpointDescriptorT checkpointStatus;
>>	SaCkptSectionIterationHandleT sectionIterator;
>>	SaCkptSectionDescriptorT sectionDescriptor;
>>	SaUint32T erroroneousVectorIndex = 0;
>>	SaAisErrorT error;
>>	struct timeval tv_start;
>>	struct timeval tv_end;
>>	struct timeval tv_elapsed;
>>	SaSelectionObjectT sel_fd;
>>	fd_set read_set;
>>	int i;
>>	
>>	error = saCkptInitialize (&ckptHandle, &callbacks, &version);
>>	printf ("%s: checkpoint initialize\n",
>>		get_test_output (error, SA_AIS_OK));
>>
>>	error = saCkptCheckpointOpen (ckptHandle,
>>		&checkpointName,
>>		NULL,
>>		SA_CKPT_CHECKPOINT_CREATE|SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
>>		SA_TIME_END,
>>		&checkpointHandle);
>>	printf ("%s: initial open of checkpoint\n",
>>		get_test_output (error, SA_AIS_OK));
>>
>>exit (1);
>>}



More information about the Openais mailing list