Skip to content

Commit 90f5529

Browse files
authored
Merge pull request #1195 from atlanhq/FT-898
Fixes deadlock on data domain caching
2 parents 3aa8e51 + 23d89a9 commit 90f5529

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

package-toolkit/runtime/src/main/kotlin/com/atlan/pkg/cache/DataDomainCache.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ class DataDomainCache(val ctx: PackageContext<*>) : AssetCache<DataDomain>(ctx,
6767
if (asset.parentDomain == null) {
6868
""
6969
} else {
70-
getIdentity(asset.parentDomain.guid)
70+
// Note: this MUST bypass the read lock, since it is called within a write lock
71+
// (otherwise, this will become a deadlock -- the read will wait until write lock is released,
72+
// which will never happen because it is waiting on this read operation to complete.)
73+
getIdentity(asset.parentDomain.guid, true)
7174
}
7275
return if (parentIdentity.isNullOrBlank()) {
7376
asset.name
@@ -89,11 +92,14 @@ class DataDomainCache(val ctx: PackageContext<*>) : AssetCache<DataDomain>(ctx,
8992
dataDomain as DataDomain
9093
cache(dataDomain.guid, getIdentityForAsset(dataDomain), dataDomain)
9194
}
95+
// Note: this should NOT be streamed in parallel, as we could otherwise have situations
96+
// where a parent and child are processed at the same time (in separate threads) and
97+
// therefore the child becomes unable to resolve its parent's identity.
9298
DataDomain.select(client)
9399
.includesOnResults(includesOnResults)
94100
.where(DataDomain.PARENT_DOMAIN_QUALIFIED_NAME.hasAnyValue())
95101
.sort(DataDomain.PARENT_DOMAIN_QUALIFIED_NAME.order(SortOrder.Asc))
96-
.stream(true)
102+
.stream(false)
97103
.forEach { dataDomain ->
98104
dataDomain as DataDomain
99105
cache(dataDomain.guid, getIdentityForAsset(dataDomain), dataDomain)

0 commit comments

Comments
 (0)