@@ -1606,44 +1606,52 @@ impl Collection {
1606
1606
) ;
1607
1607
1608
1608
// Dedicated temporary directory for this snapshot (deleted on drop)
1609
- let snapshot_temp_dir = tempfile:: Builder :: new ( )
1610
- . prefix ( & format ! ( "{snapshot_name}-temp -" ) )
1609
+ let snapshot_temp_target_dir = tempfile:: Builder :: new ( )
1610
+ . prefix ( & format ! ( "{snapshot_name}-target -" ) )
1611
1611
. tempdir_in ( global_temp_dir) ?;
1612
- let snapshot_temp_dir_path = snapshot_temp_dir. path ( ) . to_path_buf ( ) ;
1612
+
1613
+ let snapshot_temp_target_dir_path = snapshot_temp_target_dir. path ( ) . to_path_buf ( ) ;
1613
1614
// Create snapshot of each shard
1614
1615
{
1616
+ let snapshot_temp_temp_dir = tempfile:: Builder :: new ( )
1617
+ . prefix ( & format ! ( "{snapshot_name}-temp-" ) )
1618
+ . tempdir_in ( global_temp_dir) ?;
1615
1619
let shards_holder = self . shards_holder . read ( ) . await ;
1616
1620
// Create snapshot of each shard
1617
1621
for ( shard_id, replica_set) in shards_holder. get_shards ( ) {
1618
1622
let shard_snapshot_path =
1619
- versioned_shard_path ( & snapshot_temp_dir_path , * shard_id, 0 ) ;
1623
+ versioned_shard_path ( & snapshot_temp_target_dir_path , * shard_id, 0 ) ;
1620
1624
create_dir_all ( & shard_snapshot_path) . await ?;
1621
1625
// If node is listener, we can save whatever currently is in the storage
1622
1626
let save_wal = self . shared_storage_config . node_type != NodeType :: Listener ;
1623
1627
replica_set
1624
- . create_snapshot ( & snapshot_temp_dir_path, & shard_snapshot_path, save_wal)
1628
+ . create_snapshot (
1629
+ snapshot_temp_temp_dir. path ( ) ,
1630
+ & shard_snapshot_path,
1631
+ save_wal,
1632
+ )
1625
1633
. await ?;
1626
1634
}
1627
1635
}
1628
1636
1629
1637
// Save collection config and version
1630
- CollectionVersion :: save ( & snapshot_temp_dir_path ) ?;
1638
+ CollectionVersion :: save ( & snapshot_temp_target_dir_path ) ?;
1631
1639
self . collection_config
1632
1640
. read ( )
1633
1641
. await
1634
- . save ( & snapshot_temp_dir_path ) ?;
1642
+ . save ( & snapshot_temp_target_dir_path ) ?;
1635
1643
1636
1644
// Dedicated temporary file for archiving this snapshot (deleted on drop)
1637
1645
let mut snapshot_temp_arc_file = tempfile:: Builder :: new ( )
1638
1646
. prefix ( & format ! ( "{snapshot_name}-arc-" ) )
1639
1647
. tempfile_in ( global_temp_dir) ?;
1640
1648
1641
1649
// Archive snapshot folder into a single file
1642
- log:: debug!( "Archiving snapshot {:?}" , & snapshot_temp_dir_path ) ;
1650
+ log:: debug!( "Archiving snapshot {:?}" , & snapshot_temp_target_dir_path ) ;
1643
1651
let archiving = tokio:: task:: spawn_blocking ( move || {
1644
1652
let mut builder = TarBuilder :: new ( snapshot_temp_arc_file. as_file_mut ( ) ) ;
1645
1653
// archive recursively collection directory `snapshot_path_with_arc_extension` into `snapshot_path`
1646
- builder. append_dir_all ( "." , & snapshot_temp_dir_path ) ?;
1654
+ builder. append_dir_all ( "." , & snapshot_temp_target_dir_path ) ?;
1647
1655
builder. finish ( ) ?;
1648
1656
drop ( builder) ;
1649
1657
// return ownership of the file
0 commit comments