mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-09-26 07:05:34 +00:00
revert(prom): keep the remote write v1 decode buffer until the write finishes
This reverts commit 8232c5b3bb.
The v1 decoder fabricates `&'static [u8]` pointing into its own decode buffer
(prom_remote_write/types.rs), so the compiler checks nothing about that
buffer's lifetime. Holding the builder until the handler returns is what keeps
the decoder safe by construction; releasing it early made that safety depend on
every consumer copying out of the buffer, which holds today but nothing
enforces.
Document the requirement at the binding instead.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
This commit is contained in:
@@ -175,17 +175,15 @@ async fn remote_write_v1(
|
||||
processor.set_pipeline(pipeline_handler, query_ctx.clone(), pipeline_def);
|
||||
}
|
||||
|
||||
let mut decoded =
|
||||
decode_remote_write_request(is_zstd, body, prom_validation_mode, &mut processor)?;
|
||||
// Hold `req` until the write finishes. The v1 decoder fabricates
|
||||
// `&'static [u8]` into its own decode buffer, so nothing about that
|
||||
// buffer's lifetime is checked by the compiler.
|
||||
let mut req = decode_remote_write_request(is_zstd, body, prom_validation_mode, &mut processor)?;
|
||||
|
||||
// Rows and pipeline values own their data; the decode buffer need not span downstream awaits.
|
||||
let req = if processor.use_pipeline {
|
||||
drop(decoded);
|
||||
processor.exec_pipeline().await?
|
||||
} else {
|
||||
let req = decoded.as_insert_requests();
|
||||
drop(decoded);
|
||||
req
|
||||
req.as_insert_requests()
|
||||
};
|
||||
let batches = into_prom_write_batches(req, query_ctx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user