Skip to content

Commit 8ca6d9c

Browse files
a.pervushinadanolivo
authored andcommitted
Bugfix. Detach DSM segment earlier, before cleaning of memory context.
Bugfix. Small mistake during calculation of DSM segment size.
1 parent bd638da commit 8ca6d9c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

aqo_shared.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ get_dsm_all(uint32 *size)
5050
seg = dsm_attach(aqo_state->dsm_handler);
5151
Assert(seg);
5252
dsm_pin_mapping(seg);
53-
on_shmem_exit(aqo_detach_shmem, (Datum) &aqo_state->dsm_handler);
53+
before_shmem_exit(aqo_detach_shmem, (Datum) &aqo_state->dsm_handler);
5454
}
5555

5656
hdr = (dsm_seg_hdr *) dsm_segment_address(seg);
@@ -102,7 +102,7 @@ get_cache_address(void)
102102
/* Another process created the segment yet. Just attach to. */
103103
seg = dsm_attach(aqo_state->dsm_handler);
104104
dsm_pin_mapping(seg);
105-
on_shmem_exit(aqo_detach_shmem, (Datum) &aqo_state->dsm_handler);
105+
before_shmem_exit(aqo_detach_shmem, (Datum) &aqo_state->dsm_handler);
106106
}
107107

108108
hdr = (dsm_seg_hdr *) dsm_segment_address(seg);
@@ -118,7 +118,7 @@ get_cache_address(void)
118118
dsm_pin_mapping(seg);
119119
dsm_pin_segment(seg);
120120
aqo_state->dsm_handler = dsm_segment_handle(seg);
121-
on_shmem_exit(aqo_detach_shmem, (Datum) &aqo_state->dsm_handler);
121+
before_shmem_exit(aqo_detach_shmem, (Datum) &aqo_state->dsm_handler);
122122

123123
hdr = (dsm_seg_hdr *) dsm_segment_address(seg);
124124
hdr->magic = AQO_SHARED_MAGIC;
@@ -189,7 +189,6 @@ aqo_init_shmem(void)
189189
HASH_ELEM | HASH_BLOBS);
190190

191191
LWLockRelease(AddinShmemInitLock);
192-
193192
LWLockRegisterTranche(aqo_state->lock.tranche, "aqo");
194193
}
195194

learn_cache.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,11 @@ init_with_dsm(OkNNrdata *data, dsm_block_hdr *hdr, List **relnames)
252252
*relnames = lappend(*relnames, s);
253253
ptr += len;
254254
}
255+
return calculate_size(hdr->cols, *relnames);
255256
}
256257

257-
return calculate_size(hdr->cols, *relnames);
258+
/* It is just read operation. No any interest in size calculation. */
259+
return 0;
258260
}
259261

260262
void
@@ -275,10 +277,11 @@ lc_flush_data(void)
275277
{
276278
dsm_block_hdr *hdr = (dsm_block_hdr *) ptr;
277279
OkNNrdata data;
278-
List *relnames;
280+
List *relnames = NIL;
279281
uint32 delta = 0;
280282

281283
delta = init_with_dsm(&data, hdr, &relnames);
284+
Assert(delta > 0);
282285
ptr += delta;
283286
size -= delta;
284287
update_fss(hdr->key.fs, hdr->key.fss, &data, relnames);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy