Skip to content

Fix hanging of Get-DataLakeStoreDeletedItem for any errors or remote exceptions #9706

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

Merged
merged 2 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DataLakeStore/DataLakeStore/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Fix hanging of Get-DataLakeStoreDeletedItem for any errors or remote exceptions.
* Fixed miscellaneous typos across module

## Version 1.2.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class GetAzureDataLakeStoreDeletedItem : DataLakeStoreFileSystemCmdletBas

public override void ExecuteCmdlet()
{
var toReturn = DataLakeStoreFileSystemClient.EnumerateDeletedItems(Account, Filter, Count, CmdletCancellationToken).Select(entry => new DataLakeStoreDeletedItem(entry)).ToList();
var toReturn = DataLakeStoreFileSystemClient.EnumerateDeletedItems(Account, Filter, Count, this, CmdletCancellationToken).Select(entry => new DataLakeStoreDeletedItem(entry)).ToList();
WriteObject(toReturn);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,49 +777,24 @@ public void GetFileProperties(string accountName, string path, bool getAclUsage,
/// <param name="filter">Query to match items in trash</param>
/// <param name="count">Minimum number of entries to search for</param>
/// <param name="cmdletCancellationToken">CancellationToken</param>
public IEnumerable<TrashEntry> EnumerateDeletedItems(string accountName, string filter, int count, CancellationToken cmdletCancellationToken = default(CancellationToken))
public IEnumerable<TrashEntry> EnumerateDeletedItems(string accountName, string filter, int count, Cmdlet cmdlet, CancellationToken cmdletCancellationToken = default(CancellationToken))
{
IEnumerable<TrashEntry> result = null;
Task enumerateTask = null;
bool completed = false;
object syncPrimitive = new object();

var progressTracker = new Progress<EnumerateDeletedItemsProgress>();
progressTracker.ProgressChanged += (s, e) =>
{
// TODO: Update job progress here
lock (syncPrimitive)
{
if (e.NumFound >= count || String.IsNullOrEmpty(e.NextListAfter))
{
completed = true;
}

Monitor.Pulse(syncPrimitive);
}
};

enumerateTask = Task.Run(() =>
var client = AdlsClientFactory.GetAdlsClient(accountName, _context);
if (_isDebugEnabled)
{
result = AdlsClientFactory.GetAdlsClient(accountName, _context).EnumerateDeletedItems(filter, "", count, progressTracker, cmdletCancellationToken);
}, cmdletCancellationToken);

// Keep printing (?) the updates returned by successive calls by the SDK to the backend, until the whole query completes
while(true)
IEnumerable<TrashEntry> result = null;
// Api call below consists of multiple rest calls so multiple debug statements will be posted
// 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
var enumerateTask = Task.Run(() => {
result = client.EnumerateDeletedItems(filter, "", count, null, cmdletCancellationToken);
}, cmdletCancellationToken);
TrackTaskProgress(enumerateTask, cmdlet, null, cmdletCancellationToken);
return result;
}
else
{
lock (syncPrimitive)
{
Monitor.Wait(syncPrimitive);
if(completed)
{
break;
}
}
return client.EnumerateDeletedItems(filter, "", count, null, cmdletCancellationToken);
}

WaitForTask(enumerateTask, cmdletCancellationToken);

return result;
}

/// <summary>
Expand Down