AccountsDb plugin framework (#20047)
Summary of Changes Create a plugin mechanism in the accounts update path so that accounts data can be streamed out to external data stores (be it Kafka or Postgres). The plugin mechanism allows Data stores of connection strings/credentials to be configured, Accounts with patterns to be streamed PostgreSQL implementation of the streaming for different destination stores to be plugged in. The code comprises 4 major parts: accountsdb-plugin-intf: defines the plugin interface which concrete plugin should implement. accountsdb-plugin-manager: manages the load/unload of plugins and provide interfaces which the validator can notify of accounts update to plugins. accountsdb-plugin-postgres: the concrete plugin implementation for PostgreSQL The validator integrations: updated streamed right after snapshot restore and after account update from transaction processing or other real updates. The plugin is optionally loaded on demand by new validator CLI argument -- there is no impact if the plugin is not loaded.
This commit is contained in:
@@ -14,6 +14,7 @@ crossbeam-channel = "0.5"
|
||||
futures-util = "0.3"
|
||||
log = "0.4.11"
|
||||
prost = "0.8.0"
|
||||
solana-rpc = { path = "../rpc", version = "=1.8.0" }
|
||||
solana-runtime = { path = "../runtime", version = "=1.8.0" }
|
||||
solana-sdk = { path = "../sdk", version = "=1.8.0" }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
|
@@ -5,8 +5,8 @@ use {
|
||||
replica_confirmed_slots_server::ReplicaSlotConfirmationServerImpl,
|
||||
},
|
||||
crossbeam_channel::Receiver,
|
||||
solana_rpc::optimistically_confirmed_bank_tracker::BankNotification,
|
||||
solana_runtime::bank_forks::BankForks,
|
||||
solana_sdk::clock::Slot,
|
||||
std::sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ pub struct AccountsDbReplServerFactory {}
|
||||
impl AccountsDbReplServerFactory {
|
||||
pub fn build_accountsdb_repl_server(
|
||||
config: AccountsDbReplServiceConfig,
|
||||
confirmed_bank_receiver: Receiver<Slot>,
|
||||
confirmed_bank_receiver: Receiver<BankNotification>,
|
||||
bank_forks: Arc<RwLock<BankForks>>,
|
||||
) -> AccountsDbReplService {
|
||||
AccountsDbReplService::new(
|
||||
|
@@ -1,6 +1,7 @@
|
||||
use {
|
||||
crate::accountsdb_repl_server::{self, ReplicaSlotConfirmationServer},
|
||||
crossbeam_channel::Receiver,
|
||||
solana_rpc::optimistically_confirmed_bank_tracker::BankNotification,
|
||||
solana_sdk::{clock::Slot, commitment_config::CommitmentLevel},
|
||||
std::{
|
||||
collections::VecDeque,
|
||||
@@ -58,7 +59,7 @@ impl ReplicaSlotConfirmationServer for ReplicaSlotConfirmationServerImpl {
|
||||
const MAX_ELIGIBLE_SLOT_SET_SIZE: usize = 262144;
|
||||
|
||||
impl ReplicaSlotConfirmationServerImpl {
|
||||
pub fn new(confirmed_bank_receiver: Receiver<Slot>) -> Self {
|
||||
pub fn new(confirmed_bank_receiver: Receiver<BankNotification>) -> Self {
|
||||
let eligible_slot_set = ReplicaEligibleSlotSet::default();
|
||||
let exit_updated_slot_server = Arc::new(AtomicBool::new(false));
|
||||
|
||||
@@ -79,7 +80,7 @@ impl ReplicaSlotConfirmationServerImpl {
|
||||
}
|
||||
|
||||
fn run_confirmed_bank_receiver(
|
||||
confirmed_bank_receiver: Receiver<Slot>,
|
||||
confirmed_bank_receiver: Receiver<BankNotification>,
|
||||
eligible_slot_set: ReplicaEligibleSlotSet,
|
||||
exit: Arc<AtomicBool>,
|
||||
) -> JoinHandle<()> {
|
||||
@@ -87,7 +88,9 @@ impl ReplicaSlotConfirmationServerImpl {
|
||||
.name("confirmed_bank_receiver".to_string())
|
||||
.spawn(move || {
|
||||
while !exit.load(Ordering::Relaxed) {
|
||||
if let Ok(slot) = confirmed_bank_receiver.recv() {
|
||||
if let Ok(BankNotification::OptimisticallyConfirmed(slot)) =
|
||||
confirmed_bank_receiver.recv()
|
||||
{
|
||||
let mut slot_set = eligible_slot_set.slot_set.write().unwrap();
|
||||
slot_set.push_back((slot, CommitmentLevel::Confirmed));
|
||||
}
|
||||
|
Reference in New Issue
Block a user