iTwin / imodels-clients

Monorepo for iModels API clients
MIT License
6 stars 2 forks source link

BriefcaseDb.locks.releaseAllLocks() does not release all locks #180

Closed PaulPierog closed 1 year ago

PaulPierog commented 1 year ago

Describe the bug Calling BriefcaseDb.locks.releaseAllLocks() should release all locks associated with a briefcase but it only releases the first 100 locks and leaves the remaining locks in place.

To Reproduce Steps to reproduce the behavior:

  1. Create a new iModel, add 200 elements and push to hub.
  2. Create exclusive locks on the 200 elements.
  3. Call BriefcaseDb.locks.releaseAllLocks()
  4. Use the "get-imodel-locks" api to retrieve locks associated with the iModel created in step 1. No locks should exist. The link for the dev. environment is: https://dev-developer.bentley.com/apis/imodels-v2/operations/get-imodel-locks/

All locks are not released.

Expected behavior Calling BriefcaseDb.locks.releaseAllLocks() should release all locks associated with a briefcase.

Screenshots N/A

Desktop (please complete the applicable information):

Additional context The code that releases locks is in "imodels-clients\itwin-platform-access\imodels-access-backend\src\BackendIModelsAccess.ts". The "releaseAllLocks" method is shown below. The only locks released are the ones associated with the "locks[0]" array element. Search for "const lock: Lock = locks[0];" in the code listed below.

` public async releaseAllLocks(arg: BriefcaseDbArg): Promise { const getLockListParams: GetLockListParams = { ...this.getIModelScopedOperationParams(arg), urlParams: { briefcaseId: arg.briefcaseId } };

const locksIterator: EntityListIterator<Lock> = this._iModelsClient.locks.getList(getLockListParams);
const locks: Lock[] = await toArray(locksIterator);
if (locks.length === 0)
  return;

const lock: Lock = locks[0];
this.setLockLevelToNone(lock.lockedObjects);

const updateLockParams: UpdateLockParams = {
  ...this.getIModelScopedOperationParams(arg),
  briefcaseId: lock.briefcaseId,
  changesetId: arg.changeset.id,
  lockedObjects: lock.lockedObjects
};

await this._iModelsClient.locks.update(updateLockParams);

}`

aruniverse commented 1 year ago

Resolved in @itwin/imodels-access-backend versions 3.1.1 and 4.0.4