Skip to content

Commit

Permalink
[#23243] docdb : Followup fix for "Fix tablet bootstrap stuck when re…
Browse files Browse the repository at this point in the history
…playing truncate operation"

Summary:
Following the changes in D37152, RocksDB could be shut down before the `TransactionLoader::Executor` object is destroyed. This may cause the tserver process to crash during table truncation shutting down RocksDB, due to an unexpected reference count on the SuperVersion object. The crash is triggered by the following failed check:
```
column_family.cc:456] Check failed: is_last_reference
```
The root cause is that the `regular_iterator_` within TransactionLoader::Executor hold references to RocksDB's SuperVersion.

To resolve this issue, we propose resetting regular and intent iterators before release the RocksDB scoped pending operation counter lock. It is safe to reset the iterators since they are no longer in use later.
Jira: DB-12175

Test Plan: ./yb_build.sh --cxx-test pgwrapper_pg_single_tserver-test --gtest_filter PgSingleTServerTest.BootstrapReplayTruncate

Reviewers: rthallam, asrivastava, timur, bkolagani, sergei

Reviewed By: bkolagani, sergei

Subscribers: ybase, yql, mbautin

Differential Revision: https://phorge.dev.yugabyte.com/D38568
  • Loading branch information
yusong-yan committed Oct 3, 2024
1 parent b209e4f commit 56461a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/yb/tablet/transaction_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class TransactionLoader::Executor {
Status status;

auto se = ScopeExit([this, &status] {
regular_iterator_.Reset();
intents_iterator_.Reset();
scoped_pending_operation_.Reset();

loader_.FinishLoad(status);
Expand Down
6 changes: 6 additions & 0 deletions src/yb/yql/pgwrapper/pg_single_tserver-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ DECLARE_int32(rocksdb_level0_file_num_compaction_trigger);
DECLARE_int32(rocksdb_max_write_buffer_number);
DECLARE_int32(max_prevs_to_avoid_seek);
DECLARE_bool(TEST_skip_applying_truncate);
DECLARE_bool(ysql_yb_enable_alter_table_rewrite);

METRIC_DECLARE_histogram(handler_latency_yb_tserver_TabletServerService_Read);
METRIC_DECLARE_histogram(handler_latency_yb_tserver_TabletServerService_Write);
Expand All @@ -76,6 +77,11 @@ class PgSingleTServerTest : public PgMiniTestBase {
protected:
static constexpr const char* kDatabaseName = "testdb";

void SetUp() override {
ANNOTATE_UNPROTECTED_WRITE(FLAGS_ysql_yb_enable_alter_table_rewrite) = false;
PgMiniTestBase::SetUp();
}

size_t NumTabletServers() override {
return 1;
}
Expand Down

0 comments on commit 56461a4

Please sign in to comment.