Fix truncateLsn bug

This commit is contained in:
Arthur Petukhovsky
2023-08-29 09:03:22 +00:00
parent 41b9750e81
commit 13e94bf687
4 changed files with 16 additions and 3 deletions

View File

@@ -16,7 +16,7 @@ use safekeeper::{
timeline::TimelineError,
SafeKeeperConf,
};
use tracing::debug;
use tracing::{debug, info_span};
use utils::{
id::{NodeId, TenantId, TenantTimelineId, TimelineId},
lsn::Lsn,
@@ -147,7 +147,8 @@ impl GlobalMap {
}
pub fn run_server(os: NodeOs, disk: Arc<Disk>) -> Result<()> {
debug!("started server {}", os.id());
let _enter = info_span!("safekeeper", id = os.id()).entered();
debug!("started server");
let conf = SafeKeeperConf {
workdir: PathBuf::from("."),
my_id: NodeId(os.id() as u64),

View File

@@ -191,7 +191,7 @@ fn test_one_schedule() -> anyhow::Result<()> {
// test.run_schedule(&schedule)?;
// test.world.stop_all();
let seed = 14035854184686918762;
let seed = 16600359418126807633;
let test = config.start(seed);
warn!("Running test with seed {}", seed);

View File

@@ -81,6 +81,7 @@ void MyContextInit() {
exit(1);
log_min_messages = FATAL;
// log_min_messages = LOG;
Log_line_prefix = "[%p] ";
InitializeMaxBackends();

View File

@@ -1505,6 +1505,17 @@ DetermineEpochStartLsn(void)
walprop_log(LOG, "bumped epochStartLsn to the first record %X/%X", LSN_FORMAT_ARGS(propEpochStartLsn));
}
if (truncateLsn == InvalidXLogRecPtr && timelineStartLsn == propEpochStartLsn)
{
/*
* If truncateLsn is 0 everywhere, we are bootstrapping -- nothing was
* committed yet. But if timelineStartLsn is not 0, we already know
* the first record location, so we can bump truncateLsn to it.
*/
truncateLsn = timelineStartLsn;
walprop_log(LOG, "bumped truncateLsn to timelineStartLsn %X/%X", LSN_FORMAT_ARGS(truncateLsn));
}
/*
* If propEpochStartLsn is not 0, at least one msg with WAL was sent to
* some connected safekeeper; it must have carried truncateLsn pointing to