nucliadb 6.3.3.post3613__py3-none-any.whl → 6.3.3.post3626__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,12 +20,15 @@
20
20
 
21
21
 
22
22
  import asyncio
23
+ import logging
23
24
 
24
25
  from nucliadb.backups.const import StorageKeys
25
26
  from nucliadb.backups.models import DeleteBackupRequest
26
27
  from nucliadb.backups.settings import settings
27
28
  from nucliadb.common.context import ApplicationContext
28
29
 
30
+ logger = logging.getLogger(__name__)
31
+
29
32
 
30
33
  async def delete_backup_task(context: ApplicationContext, msg: DeleteBackupRequest):
31
34
  """
@@ -35,12 +38,15 @@ async def delete_backup_task(context: ApplicationContext, msg: DeleteBackupReque
35
38
 
36
39
 
37
40
  async def delete_backup(context: ApplicationContext, backup_id: str):
41
+ total_deleted = 0
38
42
  while True:
39
43
  deleted = await delete_n(context, backup_id, n=1000)
40
44
  if deleted == 0:
41
45
  # No more objects to delete
42
46
  break
43
- await asyncio.sleep(1)
47
+ total_deleted += deleted
48
+ logger.info(f"Deleted {total_deleted} objects from backup", extra={"backup_id": backup_id})
49
+ logger.info(f"Backup deletion completed", extra={"backup_id": backup_id})
44
50
 
45
51
 
46
52
  async def delete_n(context: ApplicationContext, backup_id: str, n: int):
nucliadb/backups/tasks.py CHANGED
@@ -21,7 +21,7 @@ from typing import Awaitable, Callable
21
21
 
22
22
  from nucliadb.backups.const import BackupsNatsConfig
23
23
  from nucliadb.backups.create import backup_kb_task
24
- from nucliadb.backups.delete import delete_backup
24
+ from nucliadb.backups.delete import delete_backup_task
25
25
  from nucliadb.backups.models import CreateBackupRequest, DeleteBackupRequest, RestoreBackupRequest
26
26
  from nucliadb.backups.restore import restore_kb_task
27
27
  from nucliadb.common.context import ApplicationContext
@@ -83,11 +83,11 @@ async def restore(kbid: str, backup_id: str) -> None:
83
83
 
84
84
 
85
85
  def deleter_consumer() -> NatsTaskConsumer[DeleteBackupRequest]:
86
- consumer: NatsTaskConsumer = create_consumer(
86
+ consumer: NatsTaskConsumer[DeleteBackupRequest] = create_consumer(
87
87
  name="backup_deleter",
88
88
  stream=BackupsNatsConfig.stream,
89
89
  consumer=BackupsNatsConfig.delete_consumer,
90
- callback=delete_backup,
90
+ callback=delete_backup_task,
91
91
  msg_type=DeleteBackupRequest,
92
92
  max_concurrent_messages=2,
93
93
  )
@@ -21,6 +21,7 @@ import asyncio
21
21
  import importlib.metadata
22
22
  from typing import AsyncGenerator
23
23
 
24
+ from nucliadb.common import datamanagers
24
25
  from nucliadb.common.cluster.exceptions import NodeError, ShardNotFound
25
26
  from nucliadb.common.cluster.utils import setup_cluster, teardown_cluster
26
27
  from nucliadb.common.maindb.driver import Driver
@@ -185,7 +186,11 @@ async def _purge_resources_storage_batch(driver: Driver, storage: Storage, batch
185
186
  tasks = []
186
187
  for key in to_delete_batch:
187
188
  kbid, resource_id = key.split("/")[-2:]
188
- tasks.append(asyncio.create_task(storage.delete_resource(kbid, resource_id)))
189
+ # Check if resource exists in maindb. This can happen if a file is deleted (marked for purge) and immediately
190
+ # reuploaded. Without this check, we will delete the data of the newly uploaded copy of the resource.
191
+ if not await datamanagers.atomic.resources.resource_exists(kbid=kbid, rid=resource_id):
192
+ tasks.append(asyncio.create_task(storage.delete_resource(kbid, resource_id)))
193
+
189
194
  await asyncio.gather(*tasks)
190
195
 
191
196
  # Delete the schedule-to-delete keys
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb
3
- Version: 6.3.3.post3613
3
+ Version: 6.3.3.post3626
4
4
  Summary: NucliaDB
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License: AGPL
@@ -20,11 +20,11 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3 :: Only
21
21
  Requires-Python: <4,>=3.9
22
22
  Description-Content-Type: text/markdown
23
- Requires-Dist: nucliadb-telemetry[all]>=6.3.3.post3613
24
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.3.post3613
25
- Requires-Dist: nucliadb-protos>=6.3.3.post3613
26
- Requires-Dist: nucliadb-models>=6.3.3.post3613
27
- Requires-Dist: nidx-protos>=6.3.3.post3613
23
+ Requires-Dist: nucliadb-telemetry[all]>=6.3.3.post3626
24
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.3.post3626
25
+ Requires-Dist: nucliadb-protos>=6.3.3.post3626
26
+ Requires-Dist: nucliadb-models>=6.3.3.post3626
27
+ Requires-Dist: nidx-protos>=6.3.3.post3626
28
28
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
29
29
  Requires-Dist: nuclia-models>=0.24.2
30
30
  Requires-Dist: uvicorn
@@ -42,11 +42,11 @@ nucliadb/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
42
  nucliadb/backups/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
43
43
  nucliadb/backups/const.py,sha256=9vPAhLxQO_gNAjSdPxWuv3V66s9WcdpjOQ89CZlfmuk,1894
44
44
  nucliadb/backups/create.py,sha256=TJtYewhD0jkYV_h3rNUhKzhqB2QHAhLWYOgRVlGysGs,11450
45
- nucliadb/backups/delete.py,sha256=1rnBhVUGYYZJXSZUrrgYMDZ5NyswEWkIA-G-crRCyHk,2404
45
+ nucliadb/backups/delete.py,sha256=AAs-WP-ujejj6c1LJgiMn7Ht67N_j0a1sKQlUepHpEA,2659
46
46
  nucliadb/backups/models.py,sha256=-hITU4Mv6AxePu12toBu_fjpEv6vVGcwNVxV22O9jQA,1273
47
47
  nucliadb/backups/restore.py,sha256=YD3Bbo9ry4YLMM6imB-DXbOAMXfGxVzJtTAAUFDvB0I,10153
48
48
  nucliadb/backups/settings.py,sha256=SyzsInj1BRbBI0atg5IXWbMbOZ_eVg4eSQ3IcnUhCxQ,1357
49
- nucliadb/backups/tasks.py,sha256=4_kOVJ2yCwMvDEpzJgTuTt75TNlpq5woyw9sTAcaSkw,4194
49
+ nucliadb/backups/tasks.py,sha256=WkL1LgdYBHbV_A5ilyYv5p3zmXwxH68TDudytN5f7zk,4225
50
50
  nucliadb/backups/utils.py,sha256=_Vogjqcru5oqNZM-bZ0q7Ju79Bv1PD-LVFEa7Z-Q13I,1261
51
51
  nucliadb/common/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
52
52
  nucliadb/common/constants.py,sha256=QpigxJh_CtD85Evy0PtV5cVq6x0U_f9xfIcXz1ymkUg,869
@@ -165,7 +165,7 @@ nucliadb/migrator/settings.py,sha256=jOUX0ZMunCXN8HpF9xXN0aunJYRhu4Vdr_ffjRIqwtw
165
165
  nucliadb/migrator/utils.py,sha256=NgUreUvON8_nWEzTxELBMWlfV7E6-6qi-g0DMEbVEz4,2885
166
166
  nucliadb/models/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
167
167
  nucliadb/models/responses.py,sha256=qnuOoc7TrVSUnpikfTwHLKez47_DE4mSFzpxrwtqijA,1599
168
- nucliadb/purge/__init__.py,sha256=p-DxJ3vGtEcCuiSsWY22bQn99vTMHk32BQdQJVy5b0k,11983
168
+ nucliadb/purge/__init__.py,sha256=UXbto56EWYLwZj6uEc-flQVe3gDDNFtM6EV-aIkryPU,12353
169
169
  nucliadb/purge/orphan_shards.py,sha256=AU1Jfc4qtQFasB6dkuGz0a_Zjs-i7liUTf7Xpl8R8ng,7939
170
170
  nucliadb/reader/__init__.py,sha256=C5Efic7WlGm2U2C5WOyquMFbIj2Pojwe_8mwzVYnOzE,1304
171
171
  nucliadb/reader/app.py,sha256=Se-BFTE6d1v1msLzQn4q5XIhjnSxa2ckDSHdvm7NRf8,3096
@@ -351,8 +351,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
351
351
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
352
352
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
353
353
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
354
- nucliadb-6.3.3.post3613.dist-info/METADATA,sha256=NjyQDQSB_zbOUyfe9Zcekfh2SMCNZHggFv3GkrVI6gE,4291
355
- nucliadb-6.3.3.post3613.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
356
- nucliadb-6.3.3.post3613.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
357
- nucliadb-6.3.3.post3613.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
358
- nucliadb-6.3.3.post3613.dist-info/RECORD,,
354
+ nucliadb-6.3.3.post3626.dist-info/METADATA,sha256=IoTcS-I-HSFWU6Be7gUPbWE3I60TUvgAfOP3jRQ-LUs,4291
355
+ nucliadb-6.3.3.post3626.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
356
+ nucliadb-6.3.3.post3626.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
357
+ nucliadb-6.3.3.post3626.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
358
+ nucliadb-6.3.3.post3626.dist-info/RECORD,,