From 8b3d76b24dc52a0d125c372b439d711a065b2d40 Mon Sep 17 00:00:00 2001
From: chrislu <chris.lu@gmail.com>
Date: Tue, 5 Apr 2022 10:53:36 -0700
Subject: [PATCH] prevent concurrent access during shutdown

---
 weed/mount/page_writer/upload_pipeline.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/weed/mount/page_writer/upload_pipeline.go b/weed/mount/page_writer/upload_pipeline.go
index e084ca58f..0c7446cad 100644
--- a/weed/mount/page_writer/upload_pipeline.go
+++ b/weed/mount/page_writer/upload_pipeline.go
@@ -187,6 +187,9 @@ func (up *UploadPipeline) moveToSealed(memChunk PageChunk, logicChunkIndex Logic
 
 func (up *UploadPipeline) Shutdown() {
 	up.swapFile.FreeResource()
+
+	up.sealedChunksLock.Lock()
+	defer up.sealedChunksLock.Unlock()
 	for logicChunkIndex, sealedChunk := range up.sealedChunks {
 		sealedChunk.FreeReference(fmt.Sprintf("%s uploadpipeline shutdown chunk %d", up.filepath, logicChunkIndex))
 	}