-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
safekeeper: use protobuf for sending compressed records to pageserver (…
…#9821) ## Problem #9746 lifted decoding and interpretation of WAL to the safekeeper. This reduced the ingested amount on the pageservers by around 10x for a tenant with 8 shards, but doubled the ingested amount for single sharded tenants. Also, #9746 uses bincode which doesn't support schema evolution. Technically the schema can be evolved, but it's very cumbersome. ## Summary of changes This patch set addresses both problems by adding protobuf support for the interpreted wal records and adding compression support. Compressed protobuf reduced the ingested amount by 100x on the 32 shards `test_sharded_ingest` case (compared to non-interpreted proto). For the 1 shard case the reduction is 5x. Sister change to `rust-postgres` is [here](neondatabase/rust-postgres#33). ## Links Related: #9336 Epic: #9329
- Loading branch information
Showing
21 changed files
with
702 additions
and
106 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// Generate rust code from .proto protobuf. | ||
// | ||
// Note: we previously tried to use deterministic location at proto/ for | ||
// easy location, but apparently interference with cachepot sometimes fails | ||
// the build then. Anyway, per cargo docs build script shouldn't output to | ||
// anywhere but $OUT_DIR. | ||
tonic_build::compile_protos("proto/interpreted_wal.proto") | ||
.unwrap_or_else(|e| panic!("failed to compile protos {:?}", e)); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
syntax = "proto3"; | ||
|
||
package interpreted_wal; | ||
|
||
message InterpretedWalRecords { | ||
repeated InterpretedWalRecord records = 1; | ||
optional uint64 next_record_lsn = 2; | ||
} | ||
|
||
message InterpretedWalRecord { | ||
optional bytes metadata_record = 1; | ||
SerializedValueBatch batch = 2; | ||
uint64 next_record_lsn = 3; | ||
bool flush_uncommitted = 4; | ||
uint32 xid = 5; | ||
} | ||
|
||
message SerializedValueBatch { | ||
bytes raw = 1; | ||
repeated ValueMeta metadata = 2; | ||
uint64 max_lsn = 3; | ||
uint64 len = 4; | ||
} | ||
|
||
enum ValueMetaType { | ||
Serialized = 0; | ||
Observed = 1; | ||
} | ||
|
||
message ValueMeta { | ||
ValueMetaType type = 1; | ||
CompactKey key = 2; | ||
uint64 lsn = 3; | ||
optional uint64 batch_offset = 4; | ||
optional uint64 len = 5; | ||
optional bool will_init = 6; | ||
} | ||
|
||
message CompactKey { | ||
int64 high = 1; | ||
int64 low = 2; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod decoder; | ||
pub mod models; | ||
pub mod serialized_batch; | ||
pub mod wire_format; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
9e0148d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7053 tests run: 6718 passed, 2 failed, 333 skipped (full report)
Failures on Postgres 16
test_sharded_ingest[github-actions-selfhosted-vanilla-1]
: release-x86-64test_storage_controller_many_tenants[github-actions-selfhosted]
: release-x86-64Flaky tests (3)
Postgres 17
test_subscriber_synchronous_commit
: release-arm64test_cli_start_stop
: release-arm64Postgres 14
test_pageserver_compaction_smoke[interpreted]
: release-arm64Code coverage* (full report)
functions
:30.7% (7977 of 26014 functions)
lines
:48.6% (63326 of 130404 lines)
* collected from Rust tests only
9e0148d at 2024-11-27T14:33:01.962Z :recycle: