micheal-o commented on code in PR #48697:
URL: https://github.com/apache/spark/pull/48697#discussion_r1825252564
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -965,12 +968,33 @@ class RocksDB(
/**
* Function to release RocksDB instance lock that allows for synchronized
access to the state
- * store instance
+ * store instance. Optionally provide a thread to check against, and release
only if provided
+ * thread is the one that acquired the lock.
*
* @param opType - operation type releasing the lock
+ * @param releaseForThreadOpt - optional thread to check against acquired
thread
*/
- private def release(opType: RocksDBOpType): Unit = acquireLock.synchronized {
+ private def release(
+ opType: RocksDBOpType,
+ releaseForThreadOpt: Option[AcquiredThreadInfo] = None): Unit =
acquireLock.synchronized {
if (acquiredThreadInfo != null) {
+ if (releaseForThreadOpt.nonEmpty) {
+ if (releaseForThreadOpt.get.threadRef.get.isEmpty) {
+ logInfo(log"Thread reference is empty when attempting to release
for" +
+ log" opType=${MDC(LogKeys.OP_TYPE, opType.toString)}, ignoring
release." +
+ log" Lock is held by ${MDC(LogKeys.THREAD, acquiredThreadInfo)}")
+ return
+ }
+
+ if (acquiredThreadInfo.threadRef.get.isDefined
+ && acquiredThreadInfo != releaseForThreadOpt.get) {
Review Comment:
@liviazhu-db I agree that comparing the entire object is a better pattern,
my question here was more about why they are different, just to make sure we
know why and not missing something. Don't want us to be consistent for just
consistency sake. If we believe comparing the full object is the safer approach
then lets do that. We can just do that for only this release func for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]