-
Notifications
You must be signed in to change notification settings - Fork 47
Fix repo serialization with default commit metadata #863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
58bbe1f
b3b491b
570991a
ae7049f
ba8b471
b057718
dfd56ad
52e18a0
c499c33
9c0b306
91ddba0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ use std::{ | |
| collections::{BTreeSet, HashMap, HashSet}, | ||
| future::ready, | ||
| ops::RangeBounds, | ||
| sync::Arc, | ||
| sync::{Arc, Mutex}, | ||
| }; | ||
|
|
||
| use async_recursion::async_recursion; | ||
|
|
@@ -16,7 +16,6 @@ use futures::{ | |
| use regex::bytes::Regex; | ||
| use serde::{Deserialize, Serialize}; | ||
| use thiserror::Error; | ||
| use tokio::sync::RwLock; | ||
| use tokio::task::JoinError; | ||
| use tracing::{Instrument, debug, error, instrument, trace}; | ||
|
|
||
|
|
@@ -60,7 +59,8 @@ pub enum RepositoryErrorKind { | |
| FormatError(IcechunkFormatErrorKind), | ||
| #[error(transparent)] | ||
| Ref(RefErrorKind), | ||
|
|
||
| #[error("failed to obtain mutex lock")] | ||
| SyncError, | ||
| #[error("snapshot not found: `{id}`")] | ||
| SnapshotNotFound { id: SnapshotId }, | ||
| #[error("branch {branch} does not have a snapshots before or at {at}")] | ||
|
|
@@ -139,8 +139,7 @@ pub struct Repository { | |
| asset_manager: Arc<AssetManager>, | ||
| virtual_resolver: Arc<VirtualChunkResolver>, | ||
| virtual_chunk_credentials: HashMap<ContainerName, Credentials>, | ||
| #[serde(skip)] | ||
| default_commit_metadata: Arc<RwLock<Option<SnapshotProperties>>>, | ||
| default_commit_metadata: Arc<Mutex<Option<SnapshotProperties>>>, | ||
|
||
| } | ||
|
|
||
| impl Repository { | ||
|
|
@@ -312,7 +311,7 @@ impl Repository { | |
| virtual_resolver, | ||
| asset_manager, | ||
| virtual_chunk_credentials, | ||
| default_commit_metadata: Arc::new(RwLock::new(None)), | ||
| default_commit_metadata: Arc::new(Mutex::new(None)), | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -382,17 +381,27 @@ impl Repository { | |
| } | ||
|
|
||
| #[instrument(skip_all)] | ||
| pub async fn set_default_commit_metadata( | ||
| pub fn set_default_commit_metadata( | ||
| &self, | ||
| metadata: Option<SnapshotProperties>, | ||
| ) { | ||
| let mut guard = self.default_commit_metadata.write().await; | ||
| ) -> RepositoryResult<()> { | ||
mpiannucci marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let mut guard = self | ||
| .default_commit_metadata | ||
| .lock() | ||
| .map_err(|_| RepositoryErrorKind::SyncError)?; | ||
| *guard = metadata; | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[instrument(skip_all)] | ||
| pub async fn default_commit_metadata(&self) -> Option<SnapshotProperties> { | ||
| self.default_commit_metadata.read().await.clone() | ||
| pub fn default_commit_metadata( | ||
| &self, | ||
| ) -> RepositoryResult<Option<SnapshotProperties>> { | ||
| let guard = self | ||
| .default_commit_metadata | ||
| .lock() | ||
| .map_err(|_| RepositoryErrorKind::SyncError)?; | ||
| Ok(guard.clone()) | ||
| } | ||
|
|
||
| #[instrument(skip(storage, config))] | ||
|
|
@@ -774,7 +783,10 @@ impl Repository { | |
| self.virtual_resolver.clone(), | ||
| branch.to_string(), | ||
| ref_data.snapshot.clone(), | ||
| self.default_commit_metadata.read().await.clone(), | ||
| self.default_commit_metadata | ||
| .lock() | ||
| .map_err(|_| RepositoryErrorKind::SyncError)? | ||
| .clone(), | ||
| ); | ||
|
|
||
| self.preload_manifests(ref_data.snapshot); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.