mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-21 07:00:38 +00:00
WIP
This commit is contained in:
@@ -61,7 +61,7 @@ impl ResponseErrorMessageExt for Response {
|
||||
let url = self.url().to_owned();
|
||||
Err(PageserverHttpError::Response(
|
||||
match self.json::<HttpErrorBody>() {
|
||||
Ok(err_body) => format!("Error: {}", err_body.msg),
|
||||
Ok(err_body) => format!("Response error: {}", err_body.msg),
|
||||
Err(_) => format!("Http error ({}) at {}.", status.as_u16(), url),
|
||||
},
|
||||
))
|
||||
@@ -181,14 +181,15 @@ impl PageServerNode {
|
||||
new_timeline_id: Option<TimelineId>,
|
||||
pg_version: u32,
|
||||
) -> anyhow::Result<TimelineId> {
|
||||
let initial_tenant_id = self.tenant_create(new_tenant_id, HashMap::new())?;
|
||||
let initial_tenant_id = self.tenant_create(new_tenant_id, HashMap::new())
|
||||
.context("Failed to create tenant")?;
|
||||
let initial_timeline_info = self.timeline_create(
|
||||
initial_tenant_id,
|
||||
new_timeline_id,
|
||||
None,
|
||||
None,
|
||||
Some(pg_version),
|
||||
)?;
|
||||
).context("Failed to create timeline")?;
|
||||
Ok(initial_timeline_info.timeline_id)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ pub mod tenant;
|
||||
pub mod tenant_config;
|
||||
pub mod tenant_mgr;
|
||||
pub mod tenant_tasks;
|
||||
pub mod timelines;
|
||||
// pub mod timelines;
|
||||
pub mod trace;
|
||||
pub mod virtual_file;
|
||||
pub mod walingest;
|
||||
|
||||
@@ -272,7 +272,8 @@ typedef struct
|
||||
|
||||
// Points directly to a NeonResponse. We can't just own the
|
||||
// NeonResponse because it's a "supertype", so it's not Sized.
|
||||
StringInfo response;
|
||||
char* response;
|
||||
int len;
|
||||
} NeonRequestResponse;
|
||||
|
||||
NeonRequestResponse page_cache[20];
|
||||
@@ -285,13 +286,16 @@ pageserver_call(NeonRequest * request)
|
||||
// Compute hash
|
||||
char hash = 0;
|
||||
StringInfoData req_buff;
|
||||
req_buff = zm_pack_request(request);
|
||||
req_buff = nm_pack_request(request);
|
||||
for (int i = 0; i < req_buff.len; i++) {
|
||||
hash ^= req_buff.data[i];
|
||||
}
|
||||
pfree(req_buff.data);
|
||||
|
||||
// If result is cached, memcpy and return
|
||||
// HACK keeping this commented out until I see why updating the
|
||||
// cache causes segfault.
|
||||
//
|
||||
// for (int i = 0; i < page_cache_size; i++) {
|
||||
// if (page_cache[i].request_hash == hash) {
|
||||
// int len = page_cache[0].response->len;
|
||||
@@ -318,15 +322,17 @@ pageserver_call(NeonRequest * request)
|
||||
}
|
||||
|
||||
// Cache result
|
||||
// page_cache[page_cache_head].request_hash = hash;
|
||||
// page_cache[page_cache_head].response->len = len;
|
||||
// // TODO free old result
|
||||
// page_cache[page_cache_head].response->data = palloc0(len);
|
||||
// memcpy(page_cache[page_cache_head].response->data, resp, len);
|
||||
// page_cache_head = (page_cache_head + 1) % 20;
|
||||
// if (page_cache_size < 20) {
|
||||
// page_cache_size += 1;
|
||||
// }
|
||||
page_cache[page_cache_head].request_hash = hash;
|
||||
if (page_cache_head < page_cache_size) {
|
||||
pfree(page_cache[page_cache_head].response);
|
||||
}
|
||||
page_cache[page_cache_head].len = len;
|
||||
page_cache[page_cache_head].response = palloc(len);
|
||||
memcpy(page_cache[page_cache_head].response, resp, len);
|
||||
page_cache_head = (page_cache_head + 1) % 20;
|
||||
if (page_cache_size < 20) {
|
||||
page_cache_size += 1;
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
@@ -124,10 +124,10 @@ class NeonCompare(PgCompare):
|
||||
return self._pg_bin
|
||||
|
||||
def flush(self):
|
||||
self.pageserver_http_client.timeline_gc(self.env.initial_tenant, self.timeline, 0)
|
||||
self.pageserver_http_client.timeline_gc(self.tenant, self.timeline, 0)
|
||||
|
||||
def compact(self):
|
||||
self.pageserver_http_client.timeline_compact(self.env.initial_tenant, self.timeline)
|
||||
self.pageserver_http_client.timeline_compact(self.tenant, self.timeline)
|
||||
|
||||
def report_peak_memory_use(self) -> None:
|
||||
self.zenbenchmark.record(
|
||||
|
||||
Reference in New Issue
Block a user