Skip to content

Commit

Permalink
sync: when using the jfs protocol header, close the session before th…
Browse files Browse the repository at this point in the history
…e program exits (#5221)
  • Loading branch information
zhijian-pro authored Oct 11, 2024
1 parent 7eb68cb commit fe6bb88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/scripts/sync/sync_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ skip_test_sync_between_oss(){
check_sync_log(){
grep "<FATAL>" sync.log && exit 1 || true
file_count=$1
file_copied=$(tail -1 sync.log | sed 's/.*copied: \([0-9]*\).*/\1/' )
if tail -1 sync.log | grep -q "close session"; then
file_copied=$(tail -n 2 sync.log | head -n 1 | sed 's/.*copied: \([0-9]*\).*/\1/' )
else
file_copied=$(tail -1 sync.log | sed 's/.*copied: \([0-9]*\).*/\1/' )
fi
if [ "$file_copied" != "$file_count" ]; then
echo "file_copied not equal, $file_copied, $file_count"
exit 1
Expand Down
4 changes: 4 additions & 0 deletions cmd/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ func getDefaultChunkConf(format *meta.Format) *chunk.Config {
return chunkConf
}

func (j *juiceFS) Shutdown() {
_ = j.jfs.Meta().CloseSession()
}

func newJFS(endpoint, accessKey, secretKey, token string) (object.ObjectStorage, error) {
metaUrl := os.Getenv(endpoint)
if metaUrl == "" {
Expand Down
4 changes: 4 additions & 0 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ func doSync(c *cli.Context) error {
if err != nil {
return err
}
defer func() {
object.Shutdown(src)
object.Shutdown(dst)
}()
if config.StorageClass != "" {
if os, ok := dst.(object.SupportStorageClass); ok {
err := os.SetStorageClass(config.StorageClass)
Expand Down

0 comments on commit fe6bb88

Please sign in to comment.