Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete All for instrumentation config for an agent when multiple instrumentations are defined throws error #280

Closed
pavanie opened this issue Oct 12, 2017 · 2 comments

Comments

@pavanie
Copy link

pavanie commented Oct 12, 2017

Delete All In Instrumentation config page throws error.

  1. Create more than one instrumentation for an agent
  2. Go to instrumentation page and click delete all.
    The following error gets thrown on the screen....An error occurredhide stack traceorg.glowroot.common.repo.ConfigRepository$OptimisticLockExceptionat org.glowroot.central.repo.ConfigRepositoryImpl$15.updateAgentConfig(ConfigRepositoryImpl.java:799)at org.glowroot.central.repo.AgentConfigDao.update(AgentConfigDao.java:204)at org.glowroot.central.repo.ConfigRepositoryImpl.deleteInstrumentationConfigs(ConfigRepositoryImpl.java:783)at org.glowroot.ui.InstrumentationConfigJsonService.removeInstrumentationConfig(InstrumentationConfigJsonService.java:198)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.glowroot.ui.CommonHandler.callMethod(CommonHandler.java:587)at org.glowroot.ui.CommonHandler.handleJsonServiceMappings(CommonHandler.java:331)at org.glowroot.ui.CommonHandler.handleRequest(CommonHandler.java:248)at org.glowroot.ui.CommonHandler.handle(CommonHandler.java:165)at org.glowroot.ui.HttpServerHandler.channelRead(HttpServerHandler.java:183)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644)at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579)at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496)at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)at java.lang.Thread.run(Thread.java:745)
    --

Fix:

The culprit is these lines of code in ConfigRepositoryImpl.deleteInstrumentationConfigs

            while (i.hasNext()) {
                String currVersion = Versions.getVersion(i.next());
                if (remainingVersions.contains(currVersion)) {
                    i.remove();
                    remainingVersions.remove(currVersion);
                    break;
                }
            }

            if (!remainingVersions.isEmpty()) {
                throw new OptimisticLockException();
            }

If there are multiple instrumentations to be deleted the above loop exits after it finds the first one and does not remove the others and hence throws OptimisticLockException in subsequent lines of code.

Just remove the break statement will fix it.

@pavanie pavanie changed the title Delete All for instrumentation config for an agents when multiple instrumentations are defined throws error Delete All for instrumentation config for an agent when multiple instrumentations are defined throws error Oct 12, 2017
@pavanie
Copy link
Author

pavanie commented Oct 12, 2017

This seems to be fixed in 0.9.25 version of glowroot. Closing the issue.

@pavanie pavanie closed this as completed Oct 12, 2017
@trask
Copy link
Member

trask commented Oct 12, 2017

Yup, I ran into the same recently, fixed by 63cd777, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants