public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] Avoid lost updates to configuration during datastore deletion
@ 2025-10-30 10:48 Robert Obkircher
  2025-10-30 12:05 ` Fiona Ebner
  2025-11-03 12:14 ` Christian Ebner
  0 siblings, 2 replies; 4+ messages in thread
From: Robert Obkircher @ 2025-10-30 10:48 UTC (permalink / raw)
  To: pbs-devel

Previously, the following steps created files in /srv/test2 but
removed test2 from the configuration:

  proxmox-backup-manager datastore create test1 /srv/test1
  proxmox-backup-manager datastore remove test1 --destroy-data &
  sleep 0.1
  proxmox-backup-manager datastore create test2 /srv/test2

Reported-by: https://forum.proxmox.com/threads/possible-bug-when-deleting-a-datastore.174715/
Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
---
 pbs-datastore/src/datastore.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 03830616..14dad93a 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -2154,6 +2154,8 @@ impl DataStore {
         if ok {
             info!("Removing datastore from config...");
             let _lock = pbs_config::datastore::lock_config()?;
+            // read again to avoid loosing concurrent modifications
+            let (mut config, _digest) = pbs_config::datastore::config()?;
             let _ = config.sections.remove(name);
             pbs_config::datastore::save_config(&config)?;
         }
-- 
2.47.3



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] Avoid lost updates to configuration during datastore deletion
  2025-10-30 10:48 [pbs-devel] [PATCH proxmox-backup] Avoid lost updates to configuration during datastore deletion Robert Obkircher
@ 2025-10-30 12:05 ` Fiona Ebner
  2025-11-03 12:14 ` Christian Ebner
  1 sibling, 0 replies; 4+ messages in thread
From: Fiona Ebner @ 2025-10-30 12:05 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Robert Obkircher

Am 30.10.25 um 11:51 AM schrieb Robert Obkircher:
> Previously, the following steps created files in /srv/test2 but
> removed test2 from the configuration:
> 
>   proxmox-backup-manager datastore create test1 /srv/test1
>   proxmox-backup-manager datastore remove test1 --destroy-data &
>   sleep 0.1
>   proxmox-backup-manager datastore create test2 /srv/test2
> 
> Reported-by: https://forum.proxmox.com/threads/possible-bug-when-deleting-a-datastore.174715/

Please tell the user (and other developers to avoid potentially
duplicate work ;)) about the proposed fix in the forum.

> Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
> ---
>  pbs-datastore/src/datastore.rs | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
> index 03830616..14dad93a 100644
> --- a/pbs-datastore/src/datastore.rs
> +++ b/pbs-datastore/src/datastore.rs
> @@ -2154,6 +2154,8 @@ impl DataStore {
>          if ok {
>              info!("Removing datastore from config...");
>              let _lock = pbs_config::datastore::lock_config()?;
> +            // read again to avoid loosing concurrent modifications
> +            let (mut config, _digest) = pbs_config::datastore::config()?;
>              let _ = config.sections.remove(name);
>              pbs_config::datastore::save_config(&config)?;
>          }

Not very familiar with the code here, but looks good to me :)


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] Avoid lost updates to configuration during datastore deletion
  2025-10-30 10:48 [pbs-devel] [PATCH proxmox-backup] Avoid lost updates to configuration during datastore deletion Robert Obkircher
  2025-10-30 12:05 ` Fiona Ebner
@ 2025-11-03 12:14 ` Christian Ebner
  2025-11-03 14:58   ` Robert Obkircher
  1 sibling, 1 reply; 4+ messages in thread
From: Christian Ebner @ 2025-11-03 12:14 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Robert Obkircher

Thanks for the patch!

Only minor comments...

`Avoid lost updates to configuration during datastore deletion`

the title might mention that this are concurrent config updates, so maybe:

`fix: avoid loss of concurrent config changes during datastore deletion`

On 10/30/25 11:51 AM, Robert Obkircher wrote:
> Previously, the following steps created files in /srv/test2 but
> removed test2 from the configuration:

Apart from the steps to reproduce (which is always nice to have!), this 
should maybe also state that this fixes a race between the initial 
reading of the datastore config before destroying the datastore and 
concurrent config changes, by re-reading the config in a locked context 
before removing the just destroyed datastore from it.

> 
>    proxmox-backup-manager datastore create test1 /srv/test1
>    proxmox-backup-manager datastore remove test1 --destroy-data &
>    sleep 0.1
>    proxmox-backup-manager datastore create test2 /srv/test2
> 
> Reported-by: https://forum.proxmox.com/threads/possible-bug-when-deleting-a-datastore.174715/
This can be shortened to only include the thread ID, e.g.:
https://forum.proxmox.com/threads/174715/


> Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
> ---
>   pbs-datastore/src/datastore.rs | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
> index 03830616..14dad93a 100644
> --- a/pbs-datastore/src/datastore.rs
> +++ b/pbs-datastore/src/datastore.rs
> @@ -2154,6 +2154,8 @@ impl DataStore {
>           if ok {
>               info!("Removing datastore from config...");
>               let _lock = pbs_config::datastore::lock_config()?;
> +            // read again to avoid loosing concurrent modifications
> +            let (mut config, _digest) = pbs_config::datastore::config()?;
>               let _ = config.sections.remove(name);
>               pbs_config::datastore::save_config(&config)?;
>           }

With these changes to the commit message addressed, consider:

Reviewed-by: Christian Ebner <c.ebner@proxmox.com>Tested-by: Christian 
Ebner <c.ebner@proxmox.com>


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] Avoid lost updates to configuration during datastore deletion
  2025-11-03 12:14 ` Christian Ebner
@ 2025-11-03 14:58   ` Robert Obkircher
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Obkircher @ 2025-11-03 14:58 UTC (permalink / raw)
  To: Christian Ebner, Proxmox Backup Server development discussion


On 11/3/25 13:14, Christian Ebner wrote:
> Thanks for the patch!
>
> Only minor comments...
>
> `Avoid lost updates to configuration during datastore deletion`
>
> the title might mention that this are concurrent config updates, so 
> maybe:
>
> `fix: avoid loss of concurrent config changes during datastore deletion`
>
> On 10/30/25 11:51 AM, Robert Obkircher wrote:
>> Previously, the following steps created files in /srv/test2 but
>> removed test2 from the configuration:
>
> Apart from the steps to reproduce (which is always nice to have!), 
> this should maybe also state that this fixes a race between the 
> initial reading of the datastore config before destroying the 
> datastore and concurrent config changes, by re-reading the config in a 
> locked context before removing the just destroyed datastore from it.
>
>>
>>    proxmox-backup-manager datastore create test1 /srv/test1
>>    proxmox-backup-manager datastore remove test1 --destroy-data &
>>    sleep 0.1
>>    proxmox-backup-manager datastore create test2 /srv/test2
>>
>> Reported-by: 
>> https://forum.proxmox.com/threads/possible-bug-when-deleting-a-datastore.174715/
> This can be shortened to only include the thread ID, e.g.:
> https://forum.proxmox.com/threads/174715/
>
>
>> Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
>> ---
>>   pbs-datastore/src/datastore.rs | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/pbs-datastore/src/datastore.rs 
>> b/pbs-datastore/src/datastore.rs
>> index 03830616..14dad93a 100644
>> --- a/pbs-datastore/src/datastore.rs
>> +++ b/pbs-datastore/src/datastore.rs
>> @@ -2154,6 +2154,8 @@ impl DataStore {
>>           if ok {
>>               info!("Removing datastore from config...");
>>               let _lock = pbs_config::datastore::lock_config()?;
>> +            // read again to avoid loosing concurrent modifications
>> +            let (mut config, _digest) = 
>> pbs_config::datastore::config()?;
>>               let _ = config.sections.remove(name);
>>               pbs_config::datastore::save_config(&config)?;
>>           }
>
> With these changes to the commit message addressed, consider:
>
> Reviewed-by: Christian Ebner <c.ebner@proxmox.com>Tested-by: Christian 
> Ebner <c.ebner@proxmox.com>


Updated commit message in: 
https://lore.proxmox.com/pbs-devel/20251103145422.128701-1-r.obkircher@proxmox.com/T/#u



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-03 14:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-30 10:48 [pbs-devel] [PATCH proxmox-backup] Avoid lost updates to configuration during datastore deletion Robert Obkircher
2025-10-30 12:05 ` Fiona Ebner
2025-11-03 12:14 ` Christian Ebner
2025-11-03 14:58   ` Robert Obkircher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal