From 2699a676c41551b48095611f6e8bc5062b676328 Mon Sep 17 00:00:00 2001 From: aniketfuryrocks Date: Sat, 15 Apr 2023 02:40:25 +0530 Subject: [PATCH 1/2] postgres migration and test script fix --- migrations/create.sql | 4 ++-- tests/postgres.bash | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/migrations/create.sql b/migrations/create.sql index 2e33f472..08dceec0 100644 --- a/migrations/create.sql +++ b/migrations/create.sql @@ -16,9 +16,9 @@ CREATE TABLE lite_rpc.Txs ( CREATE TABLE lite_rpc.Blocks ( slot BIGINT NOT NULL PRIMARY KEY, leader_id BIGINT NOT NULL, - parent_slot BIGINT NOT NULL + parent_slot BIGINT NOT NULL, cluster_time TIMESTAMP WITH TIME ZONE NOT NULL, - local_time TIMESTAMP WITH TIME ZONE, + local_time TIMESTAMP WITH TIME ZONE ); CREATE TABLE lite_rpc.AccountAddrs ( diff --git a/tests/postgres.bash b/tests/postgres.bash index bd2f1067..c5ae97a5 100755 --- a/tests/postgres.bash +++ b/tests/postgres.bash @@ -1,5 +1,8 @@ #!/bin/sh +# kill background jobs on exit/failure +trap 'kill $(jobs -pr)' SIGINT SIGTERM EXIT + # env variables export PGPASSWORD="password" export PG_CONFIG="host=localhost dbname=postgres user=postgres password=password sslmode=disable" @@ -16,6 +19,12 @@ docker start test-postgres echo "Clearing database" pg_run -f ../migrations/rm.sql pg_run -f ../migrations/create.sql + +echo "Starting the test validator" +solana-test-validator > /dev/null & + +echo "Waiting 8 seconds for solana-test-validator to start" +sleep 8 echo "Starting lite-rpc" cargo run --release -- -p & From 5711203d48b5b2c60599aef45207f23cd1956c0d Mon Sep 17 00:00:00 2001 From: aniketfuryrocks Date: Sat, 15 Apr 2023 02:56:20 +0530 Subject: [PATCH 2/2] log batch size on failure --- src/workers/postgres.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/workers/postgres.rs b/src/workers/postgres.rs index c939946b..8e8b4d75 100644 --- a/src/workers/postgres.rs +++ b/src/workers/postgres.rs @@ -92,7 +92,6 @@ impl PostgresSession { let ca_pem = BinaryEncoding::Base64 .decode(ca_pem_b64) .context("ca pem decode")?; - let client_pks = BinaryEncoding::Base64 .decode(client_pks_b64) .context("client pks decode")?; @@ -346,13 +345,13 @@ impl Postgres { ); if let Err(err) = res_txs { - warn!("Error sending tx batch to postgres {err:?}"); + warn!("Error sending tx batch ({:?}) to postgres {err:?}", tx_que.len()); } else { tx_que.clear(); } if let Err(err) = res_block { - warn!("Error sending block batch to postgres {err:?}"); + warn!("Error sending block batch ({:?}) to postgres {err:?}", block_que.len()); } else { block_que.clear(); }