Skip to content

Commit 5d90f76

Browse files
committed
Fix hanging of Get-DataLakeStoreDeletedItem for any errors or remote exceptions
1 parent 15c87de commit 5d90f76

File tree

3 files changed

+16
-40
lines changed

3 files changed

+16
-40
lines changed

src/DataLakeStore/DataLakeStore/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fix hanging of Get-DataLakeStoreDeletedItem for any errors or remote exceptions.
2122

2223
## Version 1.2.1
2324
* Update the ADLS sdk to use httpclient, integrate dataplane testing with azure framework

src/DataLakeStore/DataLakeStore/DataPlaneCommands/GetAzureRmDataLakeStoreDeletedItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class GetAzureDataLakeStoreDeletedItem : DataLakeStoreFileSystemCmdletBas
5454

5555
public override void ExecuteCmdlet()
5656
{
57-
var toReturn = DataLakeStoreFileSystemClient.EnumerateDeletedItems(Account, Filter, Count, CmdletCancellationToken).Select(entry => new DataLakeStoreDeletedItem(entry)).ToList();
57+
var toReturn = DataLakeStoreFileSystemClient.EnumerateDeletedItems(Account, Filter, Count, this, CmdletCancellationToken).Select(entry => new DataLakeStoreDeletedItem(entry)).ToList();
5858
WriteObject(toReturn);
5959
}
6060
}

src/DataLakeStore/DataLakeStore/DataPlaneModels/DataLakeStoreFileSystemClient.cs

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -777,49 +777,24 @@ public void GetFileProperties(string accountName, string path, bool getAclUsage,
777777
/// <param name="filter">Query to match items in trash</param>
778778
/// <param name="count">Minimum number of entries to search for</param>
779779
/// <param name="cmdletCancellationToken">CancellationToken</param>
780-
public IEnumerable<TrashEntry> EnumerateDeletedItems(string accountName, string filter, int count, CancellationToken cmdletCancellationToken = default(CancellationToken))
780+
public IEnumerable<TrashEntry> EnumerateDeletedItems(string accountName, string filter, int count, Cmdlet cmdlet, CancellationToken cmdletCancellationToken = default(CancellationToken))
781781
{
782-
IEnumerable<TrashEntry> result = null;
783-
Task enumerateTask = null;
784-
bool completed = false;
785-
object syncPrimitive = new object();
786-
787-
var progressTracker = new Progress<EnumerateDeletedItemsProgress>();
788-
progressTracker.ProgressChanged += (s, e) =>
789-
{
790-
// TODO: Update job progress here
791-
lock (syncPrimitive)
792-
{
793-
if (e.NumFound >= count || String.IsNullOrEmpty(e.NextListAfter))
794-
{
795-
completed = true;
796-
}
797-
798-
Monitor.Pulse(syncPrimitive);
799-
}
800-
};
801-
802-
enumerateTask = Task.Run(() =>
782+
var client = AdlsClientFactory.GetAdlsClient(accountName, _context);
783+
if (_isDebugEnabled)
803784
{
804-
result = AdlsClientFactory.GetAdlsClient(accountName, _context).EnumerateDeletedItems(filter, "", count, progressTracker, cmdletCancellationToken);
805-
}, cmdletCancellationToken);
806-
807-
// Keep printing (?) the updates returned by successive calls by the SDK to the backend, until the whole query completes
808-
while(true)
785+
IEnumerable<TrashEntry> result = null;
786+
// Api call below consists of multiple rest calls so multiple debug statements will be posted
787+
// so since we want to the debug lines to be updated while the command runs, we have to flush the debug statements in queue and thats why we want to do it this way
788+
var enumerateTask = Task.Run(() => {
789+
result = client.EnumerateDeletedItems(filter, "", count, null, cmdletCancellationToken);
790+
}, cmdletCancellationToken);
791+
TrackTaskProgress(enumerateTask, cmdlet, null, cmdletCancellationToken);
792+
return result;
793+
}
794+
else
809795
{
810-
lock (syncPrimitive)
811-
{
812-
Monitor.Wait(syncPrimitive);
813-
if(completed)
814-
{
815-
break;
816-
}
817-
}
796+
return client.EnumerateDeletedItems(filter, "", count, null, cmdletCancellationToken);
818797
}
819-
820-
WaitForTask(enumerateTask, cmdletCancellationToken);
821-
822-
return result;
823798
}
824799

825800
/// <summary>

0 commit comments

Comments
 (0)