bdr: mergme: Stat module improvements around increasing the number of nodes
authorAndres Freund <andres@anarazel.de>
Tue, 28 May 2013 02:44:46 +0000 (04:44 +0200)
committerAndres Freund <andres@anarazel.de>
Tue, 28 May 2013 02:44:46 +0000 (04:44 +0200)
contrib/bdr/bdr_count.c

index 4b16732b52bc12bffd2e884b7edf0913c92b5560..4cd29be73615b587c9f069c9adea1ddda68f9e78 100644 (file)
@@ -480,9 +480,11 @@ bdr_count_unserialize(void)
    read_size = sizeof(serial);
    if (read(fd, &serial, read_size) != read_size)
    {
+       int saved_errno = errno;
        LWLockRelease(BdrCountCtl->lock);
        CloseTransientFile(fd);
-       ereport(ERROR,
+       errno = saved_errno;
+       ereport(PANIC,
                (errcode_for_file_access(),
                 errmsg("could not read bdr stat file data \"%s\": %m",
                        path)));
@@ -510,10 +512,12 @@ bdr_count_unserialize(void)
    }
 
    /* read actual data, directly into shmem */
-   read_size = sizeof(BdrCountSlot) * bdr_count_nnodes;
+   read_size = sizeof(BdrCountSlot) * serial.nr_slots;
    if (read(fd, &BdrCountCtl->slots, read_size) != read_size)
    {
+       int saved_errno = errno;
        CloseTransientFile(fd);
+       errno = saved_errno;
        ereport(ERROR,
                (errcode_for_file_access(),
                 errmsg("could not read bdr stat file data \"%s\": %m",