[RTFACT-18090] Create Repository REST API causes DB lock and Unresponsiveness in UI if repo key length is over 64 Created: 14/Dec/18  Updated: 07/Feb/19  Resolved: 08/Jan/19

Status: Resolved
Project: Artifactory Binary Repository
Component/s: Database
Affects Version/s: 6.1.0, 6.5.9
Fix Version/s: 6.7.0

Type: Bug Priority: High
Reporter: David Shin Assignee: Omri Ziv
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Contains(WBSGantt)
is contained in RTFACT-17016 Creating repository with illegal name... Resolved
Duplicate
is duplicated by RTFACT-11876 Missing repo key length check while u... Resolved

 Description   

Create Repository REST API causes DB lock and Unresponsiveness in UI if repo key length over 64 - https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-CreateRepository

Step to reproduce
1

 curl -uadmin:password  -X PUT 'http://mill.jfrog.info:33034/artifactory/api/repositories/test_repository_for_over_64_character_test_repository_for_over_64_character' -H "Content-Type: application/json" -d '{"name":"test_repository_for_over_64_character_test_repository_for_over_64_character","rclass":"local","packageType":"generic"}'

While the API run, UI hangs and is unresponsive.
After 120 seconds later. It shows below message.

Successfully created repository 'test_repository_for_over_64_character_test_repository_for_over_64_character'
(===> this is the problem, which should throw error message as 'repo' column set as varchar(64) in nodes table )

artifactory.config.xml will show below, it failed to create a new row in nodes table in DB definately.
<localRepository> <key>test_repository_for_over_64_character_test_repository_for_over_64_character</key>
<type>generic</type>

2. artifactory.log

|2018-12-13 23:38:48,188 [http-nio-8081-exec-7] [WARN ] (o.a.s.d.l.p.DbMapLockWrapper:46) - Could not acquire lock within 120 seconds. Couldn't acquire lock for: 120000 milliseconds
2018-12-13 23:38:48,200 [http-nio-8081-exec-7] [ERROR] (o.a.r.s.RepositoryServiceImpl:2527) - Failed to initialize local repository 'test_repository_for_over_64_character_test_repository_for_over_64_character'. Repository will be blacked-out
org.artifactory.concurrent.LockingException: Lock on LockEntryId test_repository_for_over_64_character_test_repository_for_over_64_character: not acquired in 120 seconds. Lock info: org.artifactory.storage.db.locks.provider.DbMapLockWrapper@66199594.
	at org.artifactory.storage.fs.lock.SessionLockEntry.acquire(SessionLockEntry.java:105)
	at org.artifactory.storage.fs.lock.SessionLockEntry.acquireWriteLock(SessionLockEntry.java:90)
	at org.artifactory.storage.db.fs.session.SqlStorageSession.writeLock(SqlStorageSession.java:88)
	at org.artifactory.storage.fs.lock.LockingHelper.writeLock(LockingHelper.java:55)
	at org.artifactory.storage.db.fs.model.DbFsItemProvider.getOrCreateMutableFsItem(DbFsItemProvider.java:147)
	at org.artifactory.storage.db.fs.model.DbMutableFolderProvider.getOrCreMutableFolder(DbMutableFolderProvider.java:65)
	at org.artifactory.repo.db.DbStoringRepoMixin.createOrGetFolder(DbStoringRepoMixin.java:689)
	at org.artifactory.repo.db.DbStoringRepoMixin.init(DbStoringRepoMixin.java:167)
	at org.artifactory.repo.db.DbLocalRepo.init(DbLocalRepo.java:96)
	at org.artifactory.repo.service.RepositoryServiceImpl$RepositoriesCacheBuilder.rebuildLocalRepositories(RepositoryServiceImpl.java:2525)
	at org.artifactory.repo.service.RepositoryServiceImpl$RepositoriesCacheBuilder.rebuildRepositories(RepositoryServiceImpl.java:2472)
	at org.artifactory.repo.service.RepositoryServiceImpl.rebuildRepositoriesInTransaction(RepositoryServiceImpl.java:1404)
	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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.artifactory.storage.fs.lock.aop.LockingAdvice.invoke(LockingAdvice.java:78)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
	at com.sun.proxy.$Proxy141.rebuildRepositoriesInTransaction(Unknown Source)
	at org.artifactory.repo.service.RepositoryServiceImpl$RepositoriesCacheLoader.call(RepositoryServiceImpl.java:2670)
	at org.artifactory.repo.service.RepositoryServiceImpl$RepositoriesCacheLoader.call(RepositoryServiceImpl.java:2665)
	at org.artifactory.storage.db.security.service.VersioningCache.get(VersioningCache.java:66)
	at org.artifactory.repo.service.RepositoryServiceImpl.getVirtualRepositories(RepositoryServiceImpl.java:626)
	at org.artifactory.repo.service.RepositoryServiceImpl.getVirtualRepoDescriptors(RepositoryServiceImpl.java:1648)
	at org.artifactory.repo.service.RepositoryServiceImpl.checkAndCleanChangedVirtualPomCleanupPolicy(RepositoryServiceImpl.java:362)
	at org.artifactory.repo.service.RepositoryServiceImpl.reload(RepositoryServiceImpl.java:312)
	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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.artifactory.storage.fs.lock.aop.LockingAdvice.invoke(LockingAdvice.java:76)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
	at com.sun.proxy.$Proxy141.reload(Unknown Source)
	at org.artifactory.spring.ArtifactoryApplicationContext.reload(ArtifactoryApplicationContext.java:393)
	at org.artifactory.config.CentralConfigServiceImpl.callReload(CentralConfigServiceImpl.java:538)
	at org.artifactory.config.CentralConfigServiceImpl.reloadConfiguration(CentralConfigServiceImpl.java:522)
	at org.artifactory.config.CentralConfigServiceImpl.saveDescriptor(CentralConfigServiceImpl.java:311)
	at org.artifactory.config.CentralConfigServiceImpl.saveAndReloadContext(CentralConfigServiceImpl.java:619)
	at org.artifactory.config.CentralConfigServiceImpl.lambda$saveAndReloadContextWithRetry$0(CentralConfigServiceImpl.java:573)
	at org.jfrog.common.ExecutionUtils.handleFunctionExecution(ExecutionUtils.java:57)
	at org.jfrog.common.ExecutionUtils.lambda$generateExecutionRunnable$0(ExecutionUtils.java:48)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:111)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:58)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:75)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:260)
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
	at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:56)
	at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:36)
	at org.jfrog.common.ExecutionUtils.retry(ExecutionUtils.java:41)
	at org.artifactory.config.CentralConfigServiceImpl.saveAndReloadContextWithRetry(CentralConfigServiceImpl.java:572)
	at org.artifactory.config.CentralConfigServiceImpl.saveEditedDescriptorAndReload(CentralConfigServiceImpl.java:514)
	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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201)
	at com.sun.proxy.$Proxy136.saveEditedDescriptorAndReload(Unknown Source)
	at org.artifactory.addon.rest.RestAddonImpl.handleCreateReplaceLocalRepository(RestAddonImpl.java:1615)
	at org.artifactory.addon.rest.RestAddonImpl.createOrReplaceRepository(RestAddonImpl.java:677)
	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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201)
	at com.sun.proxy.$Proxy289.createOrReplaceRepository(Unknown Source)
	at org.artifactory.rest.resource.repositories.RepositoriesResource.createOrReplaceRepository(RepositoriesResource.java:133)
	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 com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.artifactory.webapp.servlet.RepoFilter.execute(RepoFilter.java:184)
	at org.artifactory.webapp.servlet.RepoFilter.doFilter(RepoFilter.java:93)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.artifactory.webapp.servlet.authentication.ArtifactoryAuthenticationFilterChain.lambda$doFilter$1(ArtifactoryAuthenticationFilterChain.java:133)
	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:201)
	at org.artifactory.webapp.servlet.authentication.ArtifactoryBasicAuthenticationFilter.doFilter(ArtifactoryBasicAuthenticationFilter.java:84)
	at org.artifactory.webapp.servlet.authentication.ArtifactoryAuthenticationFilterChain.doFilter(ArtifactoryAuthenticationFilterChain.java:169)
	at org.artifactory.webapp.servlet.AccessFilter.authenticateAndExecute(AccessFilter.java:312)
	at org.artifactory.webapp.servlet.AccessFilter.doFilterInternal(AccessFilter.java:209)
	at org.artifactory.webapp.servlet.AccessFilter.doFilter(AccessFilter.java:168)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.artifactory.webapp.servlet.RequestFilter.doFilter(RequestFilter.java:78)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.artifactory.webapp.servlet.ArtifactoryCsrfFilter.doFilter(ArtifactoryCsrfFilter.java:66)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:164)
	at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80)
	at org.artifactory.webapp.servlet.SessionFilter.doFilter(SessionFilter.java:62)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.artifactory.webapp.servlet.ArtifactoryFilter.doFilter(ArtifactoryFilter.java:124)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.valves.rewrite.RewriteValve.invoke(RewriteValve.java:279)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)|Col A2|

3. Uploading a file through UI will cause below error.


|2018-12-13 23:40:34,944 [http-nio-8081-exec-9] [ERROR] (o.a.u.r.s.a.d.ArtifactDeployService:131) - org.artifactory.api.repo.exception.RepoRejectException: Cannot deploy file 'thread-dump-1.tdump'. The repository 'test_repository_for_over_64_character_test_repository_for_over_64_character' is blacked out and cannot serve artifact 'test_repository_for_over_64_character_test_repository_for_over_64_character:thread-dump-1.tdump'.

4. In order to fix the issue, copy artifactory.config.latest.xml to artifactory.config.import.xml
and then delete local repository block for which key has an excess of 64 characters in artifactory.config.import.xml and then restart Artifactory.

<localRepository>
<key>test_repository_for_over_64_character_test_repository_for_over_64_character</key>
<type>generic</type>
....
</localRepositroy>

We need to fix REST API which should not execute or throw error message in case repository key length has over 64 characters as table schema telling us

`repo` varchar(64) NOT NULL,

Note: If we change locking type to 'distributed' as below in artifactory.system.properties file, it will show below message.
artifactory.locking.provider.type=distributed


org.artifactory.storage.fs.VfsException: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'repo' at row 1
        at org.artifactory.storage.db.fs.service.FileServiceImpl.createFolder(FileServiceImpl.java:116) ~[artifactory-storage-db-4.9.0.jar:na]
        at org.artifactory.storage.db.fs.model.DbMutableFolder.doCreateNode(DbMutableFolder.java:118) ~[artifactory-storage-db-4.9.0.jar:na]




 Comments   
Comment by David Shin [ 14/Dec/18 ]

duplicated with https://www.jfrog.com/jira/browse/RTFACT-11876

Generated at Tue May 21 20:48:46 UTC 2019 using JIRA 7.6.3#76005-sha1:8a4e38d34af948780dbf52044e7aafb13a7cae58.