Skip to content

Commit 939d570

Browse files
luttershiyasmohd
authored andcommitted
store: Take ownership of self in CopyConnection.copy_data
This ensures that `copy_data` can't be called more than once on any instance; when copying encounters an error, it might leave the CopyConnection in an inconsistent state and should therefore not be reused Also make `copy_data_internal` private; it should never be called from the outside
1 parent 82863e9 commit 939d570

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

store/postgres/src/copy.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,7 @@ impl Connection {
997997
}
998998
}
999999

1000-
pub async fn copy_data_internal(
1001-
&mut self,
1002-
index_list: IndexList,
1003-
) -> Result<Status, StoreError> {
1000+
async fn copy_data_internal(&mut self, index_list: IndexList) -> Result<Status, StoreError> {
10041001
let src = self.src.clone();
10051002
let dst = self.dst.clone();
10061003
let target_block = self.target_block.clone();
@@ -1142,7 +1139,7 @@ impl Connection {
11421139
/// lower(v1.block_range) => v2.vid > v1.vid` and we can therefore stop
11431140
/// the copying of each table as soon as we hit `max_vid = max { v.vid |
11441141
/// lower(v.block_range) <= target_block.number }`.
1145-
pub async fn copy_data(&mut self, index_list: IndexList) -> Result<Status, StoreError> {
1142+
pub async fn copy_data(mut self, index_list: IndexList) -> Result<Status, StoreError> {
11461143
// We require sole access to the destination site, and that we get a
11471144
// consistent view of what has been copied so far. In general, that
11481145
// is always true. It can happen though that this function runs when

store/postgres/src/deployment_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ impl DeploymentStore {
15191519
// as adding new tables in `self`; we only need to check that tables
15201520
// that actually need to be copied from the source are compatible
15211521
// with the corresponding tables in `self`
1522-
let mut copy_conn = crate::copy::Connection::new(
1522+
let copy_conn = crate::copy::Connection::new(
15231523
logger,
15241524
self.pool.clone(),
15251525
src.clone(),

0 commit comments

Comments
 (0)