Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The last segment data block could not be read. #2840

Closed
ahaglory opened this issue Dec 6, 2024 · 1 comment
Closed

The last segment data block could not be read. #2840

ahaglory opened this issue Dec 6, 2024 · 1 comment
Assignees
Labels
core Relates to the core libraries and scripts question

Comments

@ahaglory
Copy link

ahaglory commented Dec 6, 2024

The last segment data block could not be read.

Affiliation
KFE - KSTAR

Version(s) Affected
Server Version : stable 7-142-81
Client #1 Version : 6.1-84 & stable-7-142-81
Client #2 Version : stable 7-142-81

Platform(s)
Server : Rocky Linux 8.5
Client #1: CentOS 5.11 (2.6.18-348.el5)
Client #2 : Rocky Linux 8.5

Installation Method(s)
compiled from source, kits downloaded from GitHub Release

Describe the bug
We recently upgraded our systems to the latest MDSplus, so now we have two versions of MDSplus systems.
In Version 6.1.84, we started saving Segment data from 2018. As shown below, we saved data using only 'BeginSegment'. At this time, there was no problem reading and writing data.

########################(This is the segment method I used in version 6.1.84.)#######
for(segIdx = 0, count = 1; segIdx < segmentCnt; segIdx++) {
printf("Building segment %d / %d \n", segIdx, dataCount);

	for(i = 0; i < dataCount; i++) {
		buf[i] = count++;
	}

	segIdxS		= (double) segIdx*dataCount*delta;
	segIdxE		= (double) (((segIdx+1)*dataCount)-1)*delta;
	startTime	= descr (&dtype_Double, &segIdxS, &null);
	endTime		= descr (&dtype_Double, &segIdxE, &null);
	timeRate	= descr (&dtype_Double, &delta  , &null);
	valueDesc	= descr (&dtype_Double, buf     , &dataCount, &null);
	valueAllDesc	= descr (&dtype_Double, bufAll  , &dataCountAll, &null);
	statDesc	= descr (&dtype_long  , &tstat  , &null);
	sprintf (tdiSegbuf, "BeginSegment(%s,$1,$2,MAKE_DIM(*,MAKE_RANGE($1,$2,$3)),$4,%d)", TAG_NAME, -1);
	status = MdsValue (tdiSegbuf, &startTime, &endTime, &timeRate, &valueDesc, &statDesc, &null, &len);
	// in 6-1-84 ver, we just use only beginSegment function for segment archive data.
	// There is no issue about return data of segment data, but new version of mdsplus can't return last segment data.
	if ( !((status) & 1) ) {
		printf("Error: during BeginSegment archive \n");
	}

}
##########################

When I changed the MDSplus version (7-132-0 & 7-142-81) to the latest version, I saved the data as segments, but I couldn't read the last segment data block when saving it using the same method as before, only using BeginSegment.
So in the latest version, the last block data (7-142-81) was saved by adding putSegment, and there was no problem reading the data in the latest version.

*****************************(This is the segment method I used in version 7.142.81.)
for(segIdx = 0, count = 1; segIdx < segmentCnt; segIdx++) {
printf("Building segment %d / %d \n", segIdx, dataCount);

	for(i = 0; i < dataCount; i++) {
		buf[i] = count++;
	}

	segIdxS		= (double) segIdx*dataCount*delta;
	segIdxE		= (double) (((segIdx+1)*dataCount)-1)*delta;
	startTime	= descr (&dtype_Double, &segIdxS, &null);
	endTime		= descr (&dtype_Double, &segIdxE, &null);
	timeRate	= descr (&dtype_Double, &delta  , &null);
	valueDesc	= descr (&dtype_Double, buf     , &dataCount, &null);
	valueAllDesc	= descr (&dtype_Double, bufAll  , &dataCountAll, &null);
	statDesc	= descr (&dtype_long  , &tstat  , &null);
	sprintf (tdiSegbuf, "BeginSegment(%s,$1,$2,MAKE_DIM(*,MAKE_RANGE($1,$2,$3)),$4,%d)", TAG_NAME, -1);
	status = MdsValue (tdiSegbuf, &startTime, &endTime, &timeRate, &valueDesc, &statDesc, &null, &len);
	// in 6-1-84 ver, we just use only beginSegment function for segment archive data.
	// There is no issue about return data of segment data, but new version of mdsplus can't return last segment data.
	if ( !((status) & 1) ) {
		printf("Error: during BeginSegment archive \n");
	}

#if 1
// 7-142-81 ver : we use this function for segment archive data from new mdsplus version
if(segIdx == (segmentCnt-1)){
printf("PutSegment last index segment re-injection same data %d / %d \n", segIdx, dataCount);
sprintf (tdiSegbuf, "PutSegment(%s,%d,$1)", TAG_NAME, -1);
// status = MdsValue (tdiSegbuf, &statDesc, &null, &len);
status = MdsValue (tdiSegbuf, &valueDesc, &statDesc, &null, &len);
if ( !((status) & 1) ) {
printf("Error: during putSegment archive \n");
}
}
#endif
}


Question
The problem is that when reading data previously saved using only BeginSegment in the latest MDSplus version (7-142-81), the last segment data block cannot be read.

Please give me advice on how I can solve this problem.

The solutions I think are as follows:

1st: Can you modify and distribute the MDSplus source code so that data saved using only BeginSegment and data saved using BeginSegment & putSegment can be read at the same time in the latest version of MDSplus?
2nd: Read the last block of previously saved data and execute putSegment to save it. (I don't know if this is a good way.)

Thank you for your help.

@mwinkel-dev mwinkel-dev added the core Relates to the core libraries and scripts label Dec 9, 2024
@WhoBrokeTheBuild WhoBrokeTheBuild self-assigned this Jan 2, 2025
@ahaglory
Copy link
Author

I tested the second method and the data worked well in the new version of MDSplus environment without any problems.
So I will recover the problem data using the second method. You don't have to worry about this issue anymore.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Relates to the core libraries and scripts question
Projects
None yet
Development

No branches or pull requests

3 participants