Skip to content

Commit 1388bba

Browse files
authored
Merge pull request #9783 from neondatabase/rc/2024-11-18
Storage & Compute release 2024-11-18
2 parents 6dba1a3 + b6154b0 commit 1388bba

37 files changed

+1079
-266
lines changed

Diff for: Cargo.lock

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+7-18
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ sync_wrapper = "0.1.2"
168168
tar = "0.4"
169169
test-context = "0.3"
170170
thiserror = "1.0"
171-
tikv-jemallocator = "0.5"
172-
tikv-jemalloc-ctl = "0.5"
171+
tikv-jemallocator = { version = "0.6", features = ["stats"] }
172+
tikv-jemalloc-ctl = { version = "0.6", features = ["stats"] }
173173
tokio = { version = "1.17", features = ["macros"] }
174174
tokio-epoll-uring = { git = "https://github.com/neondatabase/tokio-epoll-uring.git" , branch = "main" }
175175
tokio-io-timeout = "1.2.0"
@@ -203,21 +203,10 @@ env_logger = "0.10"
203203
log = "0.4"
204204

205205
## Libraries from neondatabase/ git forks, ideally with changes to be upstreamed
206-
207-
# We want to use the 'neon' branch for these, but there's currently one
208-
# incompatible change on the branch. See:
209-
#
210-
# - PR #8076 which contained changes that depended on the new changes in
211-
# the rust-postgres crate, and
212-
# - PR #8654 which reverted those changes and made the code in proxy incompatible
213-
# with the tip of the 'neon' branch again.
214-
#
215-
# When those proxy changes are re-applied (see PR #8747), we can switch using
216-
# the tip of the 'neon' branch again.
217-
postgres = { git = "https://github.com/neondatabase/rust-postgres.git", rev = "20031d7a9ee1addeae6e0968e3899ae6bf01cee2" }
218-
postgres-protocol = { git = "https://github.com/neondatabase/rust-postgres.git", rev = "20031d7a9ee1addeae6e0968e3899ae6bf01cee2" }
219-
postgres-types = { git = "https://github.com/neondatabase/rust-postgres.git", rev = "20031d7a9ee1addeae6e0968e3899ae6bf01cee2" }
220-
tokio-postgres = { git = "https://github.com/neondatabase/rust-postgres.git", rev = "20031d7a9ee1addeae6e0968e3899ae6bf01cee2" }
206+
postgres = { git = "https://github.com/neondatabase/rust-postgres.git", branch = "neon" }
207+
postgres-protocol = { git = "https://github.com/neondatabase/rust-postgres.git", branch = "neon" }
208+
postgres-types = { git = "https://github.com/neondatabase/rust-postgres.git", branch = "neon" }
209+
tokio-postgres = { git = "https://github.com/neondatabase/rust-postgres.git", branch = "neon" }
221210

222211
## Local libraries
223212
compute_api = { version = "0.1", path = "./libs/compute_api/" }
@@ -255,7 +244,7 @@ tonic-build = "0.12"
255244
[patch.crates-io]
256245

257246
# Needed to get `tokio-postgres-rustls` to depend on our fork.
258-
tokio-postgres = { git = "https://github.com/neondatabase/rust-postgres.git", rev = "20031d7a9ee1addeae6e0968e3899ae6bf01cee2" }
247+
tokio-postgres = { git = "https://github.com/neondatabase/rust-postgres.git", branch = "neon" }
259248

260249
################# Binary contents sections
261250

Diff for: compute/etc/neon_collector.jsonnet

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import 'sql_exporter/compute_backpressure_throttling_seconds.libsonnet',
77
import 'sql_exporter/compute_current_lsn.libsonnet',
88
import 'sql_exporter/compute_logical_snapshot_files.libsonnet',
9+
import 'sql_exporter/compute_max_connections.libsonnet',
910
import 'sql_exporter/compute_receive_lsn.libsonnet',
1011
import 'sql_exporter/compute_subscriptions_count.libsonnet',
1112
import 'sql_exporter/connection_counts.libsonnet',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
metric_name: 'compute_max_connections',
3+
type: 'gauge',
4+
help: 'Max connections allowed for Postgres',
5+
key_labels: null,
6+
values: [
7+
'max_connections',
8+
],
9+
query: importstr 'sql_exporter/compute_max_connections.sql',
10+
}

Diff for: compute/etc/sql_exporter/compute_max_connections.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT current_setting('max_connections') as max_connections;

Diff for: deny.toml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ allow = [
3737
"BSD-2-Clause",
3838
"BSD-3-Clause",
3939
"CC0-1.0",
40+
"CDDL-1.0",
4041
"ISC",
4142
"MIT",
4243
"MPL-2.0",

Diff for: libs/pageserver_api/src/key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct Key {
2424

2525
/// When working with large numbers of Keys in-memory, it is more efficient to handle them as i128 than as
2626
/// a struct of fields.
27-
#[derive(Clone, Copy, Hash, PartialEq, Eq, Ord, PartialOrd)]
27+
#[derive(Clone, Copy, Hash, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize)]
2828
pub struct CompactKey(i128);
2929

3030
/// The storage key size.

Diff for: libs/pageserver_api/src/record.rs

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ pub enum NeonWalRecord {
4141
file_path: String,
4242
content: Option<Bytes>,
4343
},
44+
// Truncate visibility map page
45+
TruncateVisibilityMap {
46+
trunc_byte: usize,
47+
trunc_offs: usize,
48+
},
4449

4550
/// A testing record for unit testing purposes. It supports append data to an existing image, or clear it.
4651
#[cfg(feature = "testing")]

Diff for: libs/pageserver_api/src/reltag.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use postgres_ffi::Oid;
2424
// FIXME: should move 'forknum' as last field to keep this consistent with Postgres.
2525
// Then we could replace the custom Ord and PartialOrd implementations below with
2626
// deriving them. This will require changes in walredoproc.c.
27-
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize)]
27+
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize)]
2828
pub struct RelTag {
2929
pub forknum: u8,
3030
pub spcnode: Oid,

Diff for: libs/postgres_ffi/src/pg_constants.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,11 @@ const FSM_LEAF_NODES_PER_PAGE: usize = FSM_NODES_PER_PAGE - FSM_NON_LEAF_NODES_P
243243
pub const SLOTS_PER_FSM_PAGE: u32 = FSM_LEAF_NODES_PER_PAGE as u32;
244244

245245
/* From visibilitymap.c */
246-
pub const VM_HEAPBLOCKS_PER_PAGE: u32 =
247-
(BLCKSZ as usize - SIZEOF_PAGE_HEADER_DATA) as u32 * (8 / 2); // MAPSIZE * (BITS_PER_BYTE / BITS_PER_HEAPBLOCK)
246+
247+
pub const VM_MAPSIZE: usize = BLCKSZ as usize - MAXALIGN_SIZE_OF_PAGE_HEADER_DATA;
248+
pub const VM_BITS_PER_HEAPBLOCK: usize = 2;
249+
pub const VM_HEAPBLOCKS_PER_BYTE: usize = 8 / VM_BITS_PER_HEAPBLOCK;
250+
pub const VM_HEAPBLOCKS_PER_PAGE: usize = VM_MAPSIZE * VM_HEAPBLOCKS_PER_BYTE;
248251

249252
/* From origin.c */
250253
pub const REPLICATION_STATE_MAGIC: u32 = 0x1257DADE;

Diff for: libs/postgres_ffi/src/walrecord.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use utils::bin_ser::DeserializeError;
1616
use utils::lsn::Lsn;
1717

1818
#[repr(C)]
19-
#[derive(Debug)]
19+
#[derive(Debug, Serialize, Deserialize)]
2020
pub struct XlMultiXactCreate {
2121
pub mid: MultiXactId,
2222
/* new MultiXact's ID */
@@ -46,7 +46,7 @@ impl XlMultiXactCreate {
4646
}
4747

4848
#[repr(C)]
49-
#[derive(Debug)]
49+
#[derive(Debug, Serialize, Deserialize)]
5050
pub struct XlMultiXactTruncate {
5151
pub oldest_multi_db: Oid,
5252
/* to-be-truncated range of multixact offsets */
@@ -72,7 +72,7 @@ impl XlMultiXactTruncate {
7272
}
7373

7474
#[repr(C)]
75-
#[derive(Debug)]
75+
#[derive(Debug, Serialize, Deserialize)]
7676
pub struct XlRelmapUpdate {
7777
pub dbid: Oid, /* database ID, or 0 for shared map */
7878
pub tsid: Oid, /* database's tablespace, or pg_global */
@@ -90,7 +90,7 @@ impl XlRelmapUpdate {
9090
}
9191

9292
#[repr(C)]
93-
#[derive(Debug)]
93+
#[derive(Debug, Serialize, Deserialize)]
9494
pub struct XlReploriginDrop {
9595
pub node_id: RepOriginId,
9696
}
@@ -104,7 +104,7 @@ impl XlReploriginDrop {
104104
}
105105

106106
#[repr(C)]
107-
#[derive(Debug)]
107+
#[derive(Debug, Serialize, Deserialize)]
108108
pub struct XlReploriginSet {
109109
pub remote_lsn: Lsn,
110110
pub node_id: RepOriginId,
@@ -120,7 +120,7 @@ impl XlReploriginSet {
120120
}
121121

122122
#[repr(C)]
123-
#[derive(Debug, Clone, Copy)]
123+
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
124124
pub struct RelFileNode {
125125
pub spcnode: Oid, /* tablespace */
126126
pub dbnode: Oid, /* database */
@@ -911,7 +911,7 @@ impl XlSmgrCreate {
911911
}
912912

913913
#[repr(C)]
914-
#[derive(Debug)]
914+
#[derive(Debug, Serialize, Deserialize)]
915915
pub struct XlSmgrTruncate {
916916
pub blkno: BlockNumber,
917917
pub rnode: RelFileNode,
@@ -984,7 +984,7 @@ impl XlDropDatabase {
984984
/// xl_xact_parsed_abort structs in PostgreSQL, but we use the same
985985
/// struct for commits and aborts.
986986
///
987-
#[derive(Debug)]
987+
#[derive(Debug, Serialize, Deserialize)]
988988
pub struct XlXactParsedRecord {
989989
pub xid: TransactionId,
990990
pub info: u8,

Diff for: libs/remote_storage/src/error.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ pub enum DownloadError {
1515
///
1616
/// Concurrency control is not timed within timeout.
1717
Timeout,
18+
/// Some integrity/consistency check failed during download. This is used during
19+
/// timeline loads to cancel the load of a tenant if some timeline detects fatal corruption.
20+
Fatal(String),
1821
/// The file was found in the remote storage, but the download failed.
1922
Other(anyhow::Error),
2023
}
@@ -29,6 +32,7 @@ impl std::fmt::Display for DownloadError {
2932
DownloadError::Unmodified => write!(f, "File was not modified"),
3033
DownloadError::Cancelled => write!(f, "Cancelled, shutting down"),
3134
DownloadError::Timeout => write!(f, "timeout"),
35+
DownloadError::Fatal(why) => write!(f, "Fatal read error: {why}"),
3236
DownloadError::Other(e) => write!(f, "Failed to download a remote file: {e:?}"),
3337
}
3438
}
@@ -41,7 +45,7 @@ impl DownloadError {
4145
pub fn is_permanent(&self) -> bool {
4246
use DownloadError::*;
4347
match self {
44-
BadInput(_) | NotFound | Unmodified | Cancelled => true,
48+
BadInput(_) | NotFound | Unmodified | Fatal(_) | Cancelled => true,
4549
Timeout | Other(_) => false,
4650
}
4751
}

Diff for: libs/wal_decoder/src/decoder.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl InterpretedWalRecord {
1919
pub fn from_bytes_filtered(
2020
buf: Bytes,
2121
shard: &ShardIdentity,
22-
record_end_lsn: Lsn,
22+
next_record_lsn: Lsn,
2323
pg_version: u32,
2424
) -> anyhow::Result<InterpretedWalRecord> {
2525
let mut decoded = DecodedWALRecord::default();
@@ -32,18 +32,18 @@ impl InterpretedWalRecord {
3232
FlushUncommittedRecords::No
3333
};
3434

35-
let metadata_record = MetadataRecord::from_decoded(&decoded, record_end_lsn, pg_version)?;
35+
let metadata_record = MetadataRecord::from_decoded(&decoded, next_record_lsn, pg_version)?;
3636
let batch = SerializedValueBatch::from_decoded_filtered(
3737
decoded,
3838
shard,
39-
record_end_lsn,
39+
next_record_lsn,
4040
pg_version,
4141
)?;
4242

4343
Ok(InterpretedWalRecord {
4444
metadata_record,
4545
batch,
46-
end_lsn: record_end_lsn,
46+
next_record_lsn,
4747
flush_uncommitted,
4848
xid,
4949
})
@@ -53,7 +53,7 @@ impl InterpretedWalRecord {
5353
impl MetadataRecord {
5454
fn from_decoded(
5555
decoded: &DecodedWALRecord,
56-
record_end_lsn: Lsn,
56+
next_record_lsn: Lsn,
5757
pg_version: u32,
5858
) -> anyhow::Result<Option<MetadataRecord>> {
5959
// Note: this doesn't actually copy the bytes since
@@ -74,7 +74,9 @@ impl MetadataRecord {
7474
Ok(None)
7575
}
7676
pg_constants::RM_CLOG_ID => Self::decode_clog_record(&mut buf, decoded, pg_version),
77-
pg_constants::RM_XACT_ID => Self::decode_xact_record(&mut buf, decoded, record_end_lsn),
77+
pg_constants::RM_XACT_ID => {
78+
Self::decode_xact_record(&mut buf, decoded, next_record_lsn)
79+
}
7880
pg_constants::RM_MULTIXACT_ID => {
7981
Self::decode_multixact_record(&mut buf, decoded, pg_version)
8082
}
@@ -86,7 +88,9 @@ impl MetadataRecord {
8688
//
8789
// Alternatively, one can make the checkpoint part of the subscription protocol
8890
// to the pageserver. This should work fine, but can be done at a later point.
89-
pg_constants::RM_XLOG_ID => Self::decode_xlog_record(&mut buf, decoded, record_end_lsn),
91+
pg_constants::RM_XLOG_ID => {
92+
Self::decode_xlog_record(&mut buf, decoded, next_record_lsn)
93+
}
9094
pg_constants::RM_LOGICALMSG_ID => {
9195
Self::decode_logical_message_record(&mut buf, decoded)
9296
}

0 commit comments

Comments
 (0)