Skip to content

Commit 90aea99

Browse files
committed
fix: tpcc segfault caused by bump-backed executor drop order
1 parent 8827abc commit 90aea99

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/execution/dql/join/hash_join.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use std::mem::transmute;
3939
use std::sync::Arc;
4040

4141
pub struct HashJoin {
42+
state: HashJoinState,
4243
ty: JoinType,
4344
on_left_keys: Vec<ScalarExpression>,
4445
on_right_keys: Vec<ScalarExpression>,
@@ -51,7 +52,6 @@ pub struct HashJoin {
5152
left_input: ExecId,
5253
right_input: ExecId,
5354
bump: Box<Bump>,
54-
state: HashJoinState,
5555
init_error: Option<DatabaseError>,
5656
}
5757

@@ -109,6 +109,7 @@ impl From<(JoinOperator, LogicalPlan, LogicalPlan)> for HashJoin {
109109
let right_schema_len = full_schema_ref.len() - left_schema_len;
110110

111111
HashJoin {
112+
state: HashJoinState::Build,
112113
ty: join_type,
113114
on_left_keys,
114115
on_right_keys,
@@ -124,7 +125,6 @@ impl From<(JoinOperator, LogicalPlan, LogicalPlan)> for HashJoin {
124125
left_input: 0,
125126
right_input: 0,
126127
bump: Box::<Bump>::default(),
127-
state: HashJoinState::Build,
128128
init_error,
129129
}
130130
}

src/execution/dql/top_k.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ fn top_sort<'a>(
8989
}
9090

9191
pub struct TopK {
92+
output: Option<std::iter::Skip<BTreeSetIntoIter<CmpItem<'static>>>>,
9293
arena: Box<Bump>,
9394
sort_fields: Vec<SortField>,
9495
limit: usize,
9596
offset: Option<usize>,
9697
input_schema: SchemaRef,
9798
input_plan: Option<LogicalPlan>,
9899
input: ExecId,
99-
output: Option<std::iter::Skip<BTreeSetIntoIter<CmpItem<'static>>>>,
100100
}
101101

102102
impl From<(TopKOperator, LogicalPlan)> for TopK {
@@ -111,14 +111,14 @@ impl From<(TopKOperator, LogicalPlan)> for TopK {
111111
): (TopKOperator, LogicalPlan),
112112
) -> Self {
113113
TopK {
114+
output: None,
114115
arena: Box::<Bump>::default(),
115116
sort_fields,
116117
limit,
117118
offset,
118119
input_schema: input.output_schema().clone(),
119120
input_plan: Some(input),
120121
input: 0,
121-
output: None,
122122
}
123123
}
124124
}

src/orm/dql.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ impl<'a, S: Storage> DBTransaction<'a, S> {
152152
}
153153

154154
/// Fetches all rows for a model inside the current transaction.
155-
pub fn fetch<M: Model>(&mut self) -> Result<OrmIter<TransactionIter<'_>, M>, DatabaseError> {
155+
pub fn fetch<M: Model>(
156+
&mut self,
157+
) -> Result<OrmIter<TransactionIter<'_, S::TransactionType<'a>>, M>, DatabaseError> {
156158
orm_list::<_, M>(self)
157159
}
158160

@@ -164,7 +166,8 @@ impl<'a, S: Storage> DBTransaction<'a, S> {
164166
/// Lists all table names inside the current transaction.
165167
pub fn show_tables(
166168
&mut self,
167-
) -> Result<ProjectValueIter<TransactionIter<'_>, String>, DatabaseError> {
169+
) -> Result<ProjectValueIter<TransactionIter<'_, S::TransactionType<'a>>, String>, DatabaseError>
170+
{
168171
Ok(ProjectValueIter::new(
169172
self.execute(&orm_show_tables_statement(), &[])?,
170173
))
@@ -173,7 +176,8 @@ impl<'a, S: Storage> DBTransaction<'a, S> {
173176
/// Lists all view names inside the current transaction.
174177
pub fn show_views(
175178
&mut self,
176-
) -> Result<ProjectValueIter<TransactionIter<'_>, String>, DatabaseError> {
179+
) -> Result<ProjectValueIter<TransactionIter<'_, S::TransactionType<'a>>, String>, DatabaseError>
180+
{
177181
Ok(ProjectValueIter::new(
178182
self.execute(&orm_show_views_statement(), &[])?,
179183
))
@@ -182,7 +186,8 @@ impl<'a, S: Storage> DBTransaction<'a, S> {
182186
/// Describes the schema of the model table inside the current transaction.
183187
pub fn describe<M: Model>(
184188
&mut self,
185-
) -> Result<OrmIter<TransactionIter<'_>, DescribeColumn>, DatabaseError> {
189+
) -> Result<OrmIter<TransactionIter<'_, S::TransactionType<'a>>, DescribeColumn>, DatabaseError>
190+
{
186191
Ok(self
187192
.execute(&orm_describe_statement(M::table_name()), &[])?
188193
.orm::<DescribeColumn>())

src/orm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ impl<'a, S: Storage> StatementSource for &'a Database<S> {
13651365
}
13661366

13671367
impl<'a, 'tx, S: Storage> StatementSource for &'a mut DBTransaction<'tx, S> {
1368-
type Iter = TransactionIter<'a>;
1368+
type Iter = TransactionIter<'a, S::TransactionType<'tx>>;
13691369

13701370
fn execute_statement<A: AsRef<[(&'static str, DataValue)]>>(
13711371
self,

0 commit comments

Comments
 (0)