Skip to content

Commit 8739e88

Browse files
committed
[PGPRO-5691] reviewers comments taken into account
1 parent dbf1435 commit 8739e88

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

engine.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,25 @@ ptrackMapReadFromFile(const char *ptrack_path)
145145

146146
if (last_readed > 0)
147147
{
148-
readed += last_readed;
148+
readed += last_readed;
149149
}
150150
else if (last_readed == 0)
151151
{
152152
/*
153153
* We don't try to read more that PtrackActualSize and
154-
* file size was alreay checked in ptrackMapInit()
154+
* file size was already checked in ptrackMapInit()
155155
*/
156156
elog(ERROR, "ptrack read map: unexpected end of file while reading map file \"%s\", expected to read %zu, but read only %zu bytes",
157157
ptrack_path, PtrackActualSize, readed);
158158
}
159-
else if (last_readed < 0)
159+
else if (last_readed < 0 && errno != EINTR)
160160
{
161161
ereport(WARNING,
162162
(errcode_for_file_access(),
163163
errmsg("ptrack read map: could not read map file \"%s\": %m", ptrack_path)));
164164
close(ptrack_fd);
165165
return false;
166166
}
167-
168-
readed += last_readed;
169167
} while (readed < PtrackActualSize);
170168

171169
close(ptrack_fd);
@@ -179,12 +177,12 @@ ptrackMapReadFromFile(const char *ptrack_path)
179177
}
180178

181179
/* Check ptrack version inside old ptrack map */
182-
if (ptrack_map->version_num < PTRACK_COMPATIBLE_VERSION_NUM)
180+
if (ptrack_map->version_num != PTRACK_MAP_FILE_VERSION_NUM)
183181
{
184182
ereport(WARNING,
185183
(errcode(ERRCODE_DATA_CORRUPTED),
186-
errmsg("ptrack read map: map format version %d in the file \"%s\" is incompatible with loaded version %d",
187-
ptrack_map->version_num, ptrack_path, PTRACK_VERSION_NUM),
184+
errmsg("ptrack read map: map format version %d in the file \"%s\" is incompatible with file format of extension %d",
185+
ptrack_map->version_num, ptrack_path, PTRACK_MAP_FILE_VERSION_NUM),
188186
errdetail("Deleting file \"%s\" and reinitializing ptrack map.", ptrack_path)));
189187
return false;
190188
}
@@ -265,21 +263,13 @@ ptrackMapInit(void)
265263
}
266264
}
267265

268-
/*
269-
* Unconditionally update version
270-
* This is usefull if we have read early compatible version of map
271-
*/
272-
ptrack_map->version_num = PTRACK_VERSION_NUM;
273-
274266
/*
275267
* Initialyze memory for new map
276268
*/
277269
if (is_new_map)
278270
{
279271
memcpy(ptrack_map->magic, PTRACK_MAGIC, PTRACK_MAGIC_SIZE);
280-
/*
281-
* Weird PtrackMapHdr.init_lsn type?
282-
*/
272+
ptrack_map->version_num = PTRACK_MAP_FILE_VERSION_NUM;
283273
ptrack_map->init_lsn.value = InvalidXLogRecPtr;
284274
/*
285275
* Fill entries with InvalidXLogRecPtr

ptrack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#define PTRACK_VERSION "2.3"
2727
/* Ptrack version as a number */
2828
#define PTRACK_VERSION_NUM 230
29-
/* Ptrack version of file that we can read from disk */
30-
#define PTRACK_COMPATIBLE_VERSION_NUM 220
29+
/* Last ptrack version that changed map file format */
30+
#define PTRACK_MAP_FILE_VERSION_NUM 220
3131

3232
/*
3333
* Structure identifying block on the disk.

0 commit comments

Comments
 (0)