[fleet] temporary measure to fix short-circuit run configuration

somehow DbContext.threadLocal stuck on UI thread after some previous tests, resulting in poisoned DbContext on the thread of db-free tests. DbContext.isBound returns true, and consequent db reads fail with poison-exception, resulting in massive test failures.

GitOrigin-RevId: 2dc6b487761ab408bc1b78e49558424c89e8abd5
This commit is contained in:
Andrey Zaytsev
2024-10-04 17:31:26 +02:00
committed by intellij-monorepo-bot
parent a1ec2591bf
commit 29bf8c213c
4 changed files with 16 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ interface DbSource {
override fun updateThreadContext(context: CoroutineContext): DbContext<*>? {
// resuming
val oldState = if (DbContext.isBound()) DbContext.threadBound else null
val oldState = DbContext.threadBoundOrNull
runCatching { dbSource.latest }
.onSuccess { latest ->
val ctx = DbContext<DB>(latest, dbSource)

View File

@@ -28,5 +28,6 @@
<orderEntry type="library" name="kotlin-reflect" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
</component>
</module>

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.rhizomedb
import org.jetbrains.annotations.TestOnly
import kotlin.coroutines.cancellation.CancellationException
//fun getStack(): Throwable = Throwable("dbcontext creation stack")
@@ -44,8 +45,19 @@ class DbContext<out QQ : Q>(
val threadBound: DbContext<Q>
get() =
threadLocal.get() ?: throw OutOfDbContext()
/**
* Current context, associated with the thread.
* */
val threadBoundOrNull: DbContext<Q>?
get() =
threadLocal.get()
fun isBound(): Boolean = threadLocal.get() != null
@TestOnly
fun isBound(): Boolean =
threadLocal.get().let {
it != null && it.impl !is Throwable
}
fun clearThreadBoundDbContext() {
threadLocal.set(null)

View File

@@ -7,6 +7,7 @@ module fleet.rhizomedb {
requires it.unimi.dsi.fastutil;
requires transitive kotlinx.serialization.core;
requires kotlinx.serialization.json;
requires org.jetbrains.annotations;
exports com.jetbrains.rhizomedb;
exports com.jetbrains.rhizomedb.impl;
exports com.jetbrains.rhizomedb.rql;