Missed Signals : state-dependent in concurrent

【信息科学与工程学】【数据中心】第三十五篇 云计算数据中心的学科知识04 编号学科(课程)核心知识点在云计算/云存储/云网络/云安全/云MaaS中的作用代表教材/资料/论文 + 数学方程式列表工业界应用D1421​云原生数据库:TiDB​HTAP(混合事务/分析处理)、分布式SQL、水平扩展、强一致(Raft)、自动故障恢复、与MySQL兼容、TiFlash列式引擎提供弹性扩展的分布式数据库;支撑高并发在线交易与实时分析教材:《TiDB in Action》PingCAP(2020) 论文:《TiDB: A Raft-based HTAP Database》(2017) 阅读详情

In my work, I find guys often  make a mistaken of missed signals 

 

 

thread_1 test condition and find it true, before it enters synchronize block to wait, thread_2 change the condition and sends out notification. CPU cycle come back for thread_1, thread_1 wait for a missed signal. May be a long time potentially forever. 

If thread_1 is a executing service  thread (engine thread) to process task, then it may be in danger of task accumulating, the whole system is blocked. 

 

A similar error is invalid clean up

 

If thread_2 execute before thread_1, then the 'target' object would be never removed and exist in container forever. If the target is limited resources such as thread, connection pool, socket... Then it  has dangerous all of limited resources are consumed and exhausted.

 

 


 

 

Java Concurrency in Practice chapter 14  Building Custom Synchronizers
The Condition Predicate
The condition predicate is the precondition that makes an operation state-dependent in the first place. In a bounded buffer, take can proceed only if the buffer is not empty; otherwise it must wait. For take, the condition predicate is "the buffer is not empty", which take must test for before proceeding. Similarly, the condition predicate for put is "the buffer is not full". Condition predicates are expressions constructed from the state variables of the class; BaseBoundedBuffer tests for "buffer not empty" by comparing count to zero, and tests for "buffer not full" by comparing countto the buffer size.

Wait - Waking Up Too Soon

When control re-enters the code calling wait, it has reacquired the lock associated with the condition queue. Is the condition predicate now true? Maybe. It might have been true at the time the notifying thread called notifyAll, but could have become false again by the time you reacquire the lock. Other threads may have acquired the lock and changed the object's state between when your thread was awakened and when wait reacquired the lock. Or maybe it hasn't been true at all since you called wait. 

 

 

When using condition waits (Object.wait or Condition.await):

  • Always have a condition predicatesome test of object state that must hold before proceeding;

  • Always test the condition predicate before calling wait, and again after returning from wait;

  • Always call wait in a loop;

  • Ensure that the state variables making up the condition predicate are guarded by the lock associated with the condition queue;

  • Hold the lock associated with the the condition queue when calling wait,notify, or notifyAll; and

  • Do not release the lock after checking the condition predicate but before acting on it.

Wait - Missed Signals

A missed signal occurs when a thread must wait for a specific condition that is already true, but fails to check the condition predicate before waiting. Now the thread is waiting to be notified of an event that has already occurred.

Listing 14.7. Canonical Form for State-dependent Methods.

 

 

Notification

Whenever you wait on a condition, make sure that someone will perform a notification whenever the condition predicate becomes true.

 

Because multiple threads could be waiting on the same condition queue for different condition predicates, using notify instead of notifyAll can be dangerous, primarily because single notification is prone to a problem akin to missed signals.

 

Single notify can be used instead of notifyAll only when both of the following conditions hold:

  • Uniform waiters. Only one condition predicate is associated with the condition queue, and each thread executes the same logic upon returning from wait; and
  • One-in, one-out. A notification on the condition variable enables at most one thread to proceed.

The notification done by put and take in BoundedBuffer is conservative: a notification is performed every time an object is put into or removed from the buffer. This could be optimized by observing that a thread can be released from a wait only if the buffer goes from empty to not empty or from full to not full, and notifying only if a put or take  one of these state transitions. This is called conditional notification

 

 

Listing 14.1. Structure of Blocking State-dependent Actions.

 

Propagating Precondition Failure to Callers

 

Polling and Sleeping

 

Condition Queues

 

 

Crossformer实战:从零开始搭建多变量时间序列预测模型(附ETTh1数据集调参指南) 本文提供了从零开始搭建Crossformer多变量时间序列预测模型的实战指南,并附有详细的ETTh1数据集调参攻略。文章深入解析了Crossformer的核心设计,重点探讨了seg_len和win_size等关键参数对模型性能的影响,并分享了环境配置、训练调试及常见问题的解决方案,帮助开发者高效应用这一前沿深度学习模型。 阅读详情

相关推荐

Android息屏后台任务保活实战:从定时器失效到厂商白名单破解

本文深入探讨了Android应用在息屏后定时任务失效的根源,即系统为省电而触发的休眠机制。文章提供了从传统方案失效分析到实战破解的完整路径,核心在于引导用户将应用加入电池优化白名单并开启自启动权限,从而合法绕过限制。同时,结合WorkManager、AlarmManager等可靠定时方案,实现稳定的后台任务执行。

weixin_28475533的博客 433

quartz定时任务创建成功但无法生成实例

quartz在oracle中无法生成实例 描述:使用quartz完成定时任务,连接oracle库时可以正常创建任务,quartz的那些表中也正常创建了jobdetail和trigger等信息,但就是到了启动时间后不执行任务,不生成任务实例,然后控制台会打印misfire等错过信息,会反复打印,如下: 2018-03-02 16:40:09.550 [QuartzScheduler_Sche...

kane0409的博客 5448

ubuntu安装glibc

VSCode 在ubuntu下调试无法打开libc-start.c raise.c等1. 安装glibc2. launch.json中添加路径映射3. 调试 1. 安装glibc apt install glibc-source cd /usr/src/glibc/ sudo tar -xvf glibc-[VERSION].tar.xz 2. launch.json中添加路径映射 "sourceFileMap": { "/build/glibc-S7xCS9": "/usr/src/glib

wq_0708的博客 3万+

bug宝典JAVA篇 missed their scheduled fire-time

使用quartz做定时任务的时候,发现时而定时任务不执行,检查日志如下:10:42:33.925 INFO o.s.scheduling.quartz.LocalDataSourceJobStore - ClusterManager: detected 1 failed or restarted instances. 10:42:33.925 INFO o.s.scheduling.quartz

warrah 南极狼 1万+

西门子840D新建项目

1、需要一个32位的WIN7或者XP系统,并且已经在系统中安装完成西门子840Dsl开发包和VS2008。(我采用的是XP系统虚拟机) 2、在开始->所有程序找到如下位置 3、在这个位置打开Visual Studio 4、文件->新建->项目 名称和位置都可以随意更改,点击确定。 5、在左侧选择第二个选项进入下面的界面 点击“Add Screen”按钮 可以修改“class name”然后点击“OK”返回上一个界面,再点击“Add Form” 可以修...

qq_36987047的博客 1865

Python读取ECMWF grib数据;Anaconda配置eccodes和cfgrib环境及安装过程

python读取grib数据,eccodes,cfgrib安装。

qq_36714629的博客 2250

quartz集群使用遇到问题解决

quartz集群部署 s still active but was recovered by another instance in the cluster问题源码分析解决 问题如下在集群启动的时候包如下错误 2021-03-21 14:49:22.984 WARN 12516 — [_ClusterManager] o.s.s.quartz.LocalDataSourceJobStore [3334] : This scheduler instance (scsp-1.novalocal1616

weixin_37601506的博客 4689

Unity详细介绍说明限制Unity帧率的方式

在Unity开发中,帧率(FPS,Frames per Second)是一个非常重要的表现标准,它直接影响了游戏运行的流畅度。在某些应用场景里,我们可能需要手动限制帧率。限制帧率可以减少电脑的CPU和GPU负载,使运行更加稳定,同时对于移动设备来说还能有效降低电量消耗。下面就详细介绍几种限制Unity中帧率的方式。

zjw1349547081的专栏 5443

Quartz的冲突处理

说明一下如何处理好quartz的调度关系 首先查看一下quartz的配置,有设置thread factory的方法,具体没有试过。还有thread factory的大小的设置 org.quartz.scheduler.jobFactory.class:com.yh.bigdata.silkworm.api.scheduler.JobFactory org.quartz.threadPool.cla...

zhoucs86的博客 2918

2025年7月12日全国青少年信息素养大赛图形化(Scratch)编程小学低年级组复赛真题+答案解析

2025年7月12日全国青少年信息素养大赛图形化(Scratch)编程小学低年级组复赛真题+答案解析

伶俐角少儿编程 720

全局注意机制 GAM | Global Attention Mechanism: Retain Information to Enhance Channel-Spatial Interactions

全局注意机制 GAM

Coding... 2586

Java Thread Pools — Deep Dive

Java线程池核心原理摘要 线程池作用:解决线程创建开销大、资源耗尽问题,通过复用固定线程、控制并发量、任务队列解耦任务提交与执行。Java提供Executor框架(Java 5+)实现。 核心类层次: Executor → ExecutorService → ThreadPoolExecutor(核心)/ScheduledThreadPoolExecutor(定时) ForkJoinPool:工作窃取,支持并行流和CompletableFuture ThreadPoolExecutor关键参数: core

quwenqian的专栏 391

手把手写深度学习(27):如果获得相机位姿态的plücker embedding?以RealEstate10K为例

用plücker embedding表示相机的位姿是一种非常常用的方法,这篇博客以RealEstate10K数据集为例子,详细讲解如何从相机的轨迹坐标中获得plücker embedding,用于下一步模型的学习。

沉迷单车的追风少年 2246

Quartz中Misfire机制源码级解析

Quartz为了补偿Misfire,为用户提供可选用的各种补偿策略,并在初始化、查询触发任务以及创建了一个后台线程定时进行补偿。但是无论哪种补偿机制,终究都是补偿。正确了解后面的机制,合理设置工作线程大小,创建任务时考虑任务时长,合理设置触发时间,才是根本之道。

m0_37607945的博客 3151

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Quartz使用问题记录

新旧两个集群同时共存; job class; 本地测试Job;

lonelymanontheway的博客 3567

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Quartz框架多个trigger任务执行出现漏执行的问题分析

一、问题描述 使用Quartz配置定时任务,配置了超过10个定时任务,这些定时任务配置的触发时间都是5分钟执行一次,实际运行时,发现总有几个定时任务不能执行到。 二、示例程序 1、简单介绍 采用spring+quartz整合方案实现定时任务,Quartz的SchedulerFactoryBean配置参数中不注入taskExecutor属性,使用默认自带的线程池。准备了15个定时任务,全部设置为每隔10秒触发一次,定时任务的实现逻辑是使用休眠8秒的方式模拟执行定时任务的时间耗费。 2、配置文件信息如下(节

岁月静好 4512

quartz的使用注意事项

问题: 在使用quartz做定时任务调度时,遇到的问题: Handling 7 trigger(s) that missed their scheduled fire-time. 可能原因: 此问题产生的原因就是quartz该启动的任务没有启动起来,就会有这个报错, 网上查找到的三个原因是: 1.所有的woker thread(工作线程; 辅助线程)都在运行其他的job 2.scheduler(调度器)down了 3.任务被安排在过去的某一时刻启动(此可能为代码错误) 排查中发现遇到的问题就是第一个原因,

weixin_44148825的博客 4119

JAVA - Quartz 定时任务_启动原理

JAVA - Quarz 定时任务_启动原理 前言 在开发过程中,我们会用定时任务来执行一些操作,例如定时去捞取流水重试业务、定时去消息中间件获取消息等等相关需求 简单的定时任务实现可以借助Spring提供的 @Scheduled 注解 详细看 Spring 原理之 Scheduled 如果涉及到 定时任务的动态管理就需要使用到其他技术,下面介绍一下Quartz Quartz是一个开源的任务日程管理系统, 由 OpenSymphony开源,同时它是一个功能丰富的任务调用系统,可创建简单或者复杂的几十、几

weixin_42272869的博客 2427

springquartz的LocalDataSourceJobStore

spring 为quartz 提供了一个 继承 JobStoreCMT的 LocalDataSourceJobStore,主要是为了和spring更好的集成。public class LocalDataSourceJobStore extends JobStoreCMT { /** * Name used for the transactional ConnectionProvide...

weixin_30216561的博客 4692

Handling 2 trigger(s) that missed their scheduled fire-time,JobPersistenceException: Couldn't store

测试服应用 启动, quartz模块 报错 Handling 2 trigger(s) that missed their scheduled fire-time MisfireHandler: Error handling misfires: Couldn’t store trigger ‘group2.job2’ for ‘group2.job2’ job:Couldn’t retrieve ...

a704397849的博客 8348

使用quartz时,遇见 "missed their scheduled fire-time"

如果你在用quartz的时候,也看到这个日志信息(Handling 2 trigger(s) that missed their scheduled fire-time.)了,并且发现quartz管理的任务,都不再被触发了,那么,你可以看看这篇文章。 原文地址: http://java.dzone.com/articles/quartz-scheduler-misfire 由于本人

fengyuxue11011的专栏 4万+

码农小汪-线程通信

线程通信的目标是使线程间能够互相发送信号。另一方面,线程通信使线程能够等待其他线程的信号。例如,线程B可以等待线程A的一个信号,这个信号会通知线程B数据已经准备好了。这个就是一个同步的过程涩通过共享对象通信线程间发送信号的一个简单方式是在共享对象的变量里设置信号值。线程A在一个同步块里设置boolean型成员变量hasDataToProcess为true,线程B也在同步块里读取hasDataToPr

汪小哥 743
上一篇: Assembly line / Pipeline
下一篇: Integer.toHexString cannot be decoded back Integer.parseInt
FireCoder
博客等级 码龄17年 65粉丝 100原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FireCoder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址