Skip to content

Commit

Permalink
Add logging of installed_extensions (#9438)
Browse files Browse the repository at this point in the history
Simple PR to log installed_extensions statistics.

in the following format:
```
2024-10-17T13:53:02.860595Z  INFO [NEON_EXT_STAT] {"extensions":[{"extname":"plpgsql","versions":["1.0"],"n_databases":2},{"extname":"neon","versions":["1.5"],"n_databases":1}]}
```
  • Loading branch information
lubennikovaav authored Oct 17, 2024
1 parent 299cde8 commit 858867c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
28 changes: 6 additions & 22 deletions compute_tools/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use nix::sys::signal::{kill, Signal};
use remote_storage::{DownloadError, RemotePath};

use crate::checker::create_availability_check_data;
use crate::installed_extensions::get_installed_extensions_sync;
use crate::local_proxy;
use crate::logger::inlinify;
use crate::pg_helpers::*;
Expand Down Expand Up @@ -1121,6 +1122,11 @@ impl ComputeNode {
self.pg_reload_conf()?;
}
self.post_apply_config()?;

let connstr = self.connstr.clone();
thread::spawn(move || {
get_installed_extensions_sync(connstr).context("get_installed_extensions")
});
}

let startup_end_time = Utc::now();
Expand Down Expand Up @@ -1484,28 +1490,6 @@ LIMIT 100",
info!("Pageserver config changed");
}
}

// Gather info about installed extensions
pub fn get_installed_extensions(&self) -> Result<()> {
let connstr = self.connstr.clone();

let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed to create runtime");
let result = rt
.block_on(crate::installed_extensions::get_installed_extensions(
connstr,
))
.expect("failed to get installed extensions");

info!(
"{}",
serde_json::to_string(&result).expect("failed to serialize extensions list")
);

Ok(())
}
}

pub fn forward_termination_signal() {
Expand Down
21 changes: 21 additions & 0 deletions compute_tools/src/installed_extensions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use compute_api::responses::{InstalledExtension, InstalledExtensions};
use std::collections::HashMap;
use std::collections::HashSet;
use tracing::info;
use url::Url;

use anyhow::Result;
Expand Down Expand Up @@ -79,3 +80,23 @@ pub async fn get_installed_extensions(connstr: Url) -> Result<InstalledExtension
})
.await?
}

// Gather info about installed extensions
pub fn get_installed_extensions_sync(connstr: Url) -> Result<()> {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed to create runtime");
let result = rt
.block_on(crate::installed_extensions::get_installed_extensions(
connstr,
))
.expect("failed to get installed extensions");

info!(
"[NEON_EXT_STAT] {}",
serde_json::to_string(&result).expect("failed to serialize extensions list")
);

Ok(())
}

1 comment on commit 858867c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5211 tests run: 5003 passed, 1 failed, 207 skipped (full report)


Failures on Postgres 17

# Run all failed tests locally:
scripts/pytest -vv -n $(nproc) -k "test_scrubber_physical_gc[debug-pg17-None]"

Test coverage report is not available

The comment gets automatically updated with the latest test results
858867c at 2024-10-17T16:38:34.655Z :recycle:

Please sign in to comment.