[ 
https://issues.apache.org/jira/browse/CASSANDRA-10031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14996410#comment-14996410
 ] 

Alexander Shopov commented on CASSANDRA-10031:
----------------------------------------------

Here I have gathered all instances of naming threads in current Cassandra tree.
Whatever new names we introduce - it is good to have some convention. I want
to discover what convention there is in practice.

There are two basic ways of naming a thread judging from the public Java API.
1. After creation there is the j.l.Thread.setName(String name) method
2. At creation - there are the different constuctors that either explicitly take
a String name parameter or default to some convention - which in Oracle's JDK is
expressed by the private init methods called by the constructor.

Here comes a list with all occurences I could find. First I state the method
that actually names the thread and then its usage in Cassandra - qualified name
of Class or Method using it, number of the line this happens in the source file
containing the aforementioned Class or Method. In cases that use implicit naming
I state the rule at the start. In cases that use explicit naming - I state the
name per case on next line.

1. j.l.Thread.setName(String name):
  This explicitly sets the thread name. Found 1 usage:
  org.apache.cassandra.repair.RepairRunnable #141 - name is "RepairTracePolling"

2. j.l.Thread.Thread():  
  This uses default naming of "Thread-" + CONSECUTIVE_POSITIVE_INTEGER - 11 
usages
  org.apache.cassandra.io.sstable.SSTableSimpleUnsortedWriter.DiskWriter #192
  org.apache.cassandra.thrift.ThriftServer.ThriftServerThread #108
  org.apache.cassandra.db.commitlog.CommitLogStressTest.CommitlogExecutor #400
  org.apache.cassandra.locator.DynamicEndpointSnitchLongTest.ScoreUpdater #78
  org.apache.cassandra.db.commitlog.CommitLogUpgradeTestMaker.CommitlogExecutor 
#210
  org.apache.cassandra.io.sstable.CQLSSTableWriterTest.WriterThread #212
  org.apache.cassandra.service.RemoveTest.testRemoveHostId() #116
  org.apache.cassandra.utils.CoalescingStrategiesTest.parkLoop() #237
  org.apache.cassandra.stress.Stress.ShutDown #142
  org.apache.cassandra.stress.StressAction.Consumer #250
  org.apache.cassandra.stress.StressServer.StressThread #76

3. j.l.Thread.Thread(Runnable)
  This also uses default naming of "Thread-" + CONSECUTIVE_POSITIVE_INTEGER - 
10 usages
  
org.apache.cassandra.streaming.compress.CompressedInputStream.CompressedInputStream(InputStream,
 CompressionInfo, ChecksumType, Supplier<Double>) #79
  org.apache.cassandra.repair.RepairRunnable.createQueryThread(int, UUID) #351
  org.apache.cassandra.service.StorageService.forceRepairAsync(String, 
RepairOption) #3069
  org.apache.cassandra.metrics.LatencyMetricsTest.testGetRecentLatency() #44
  org.apache.cassandra.concurrent.WaitQueueTest.testSerial(WaitQueue) #47
  org.apache.cassandra.concurrent.WaitQueueTest.testCondition(WaitQueue) #87
  org.apache.cassandra.hints.HintsBufferTest.testWrite() #117
  
org.apache.cassandra.cache.CacheProviderTest.concurrentCase(CachedBTreePartition,
 ICache<MeasureableString, IRowCacheEntry>) #138
  org.apache.cassandra.cql3.ViewLongTest.testConflictResolution() #95
  org.apache.cassandra.stress.StressServer.StressThread.run() #93
  
4. j.l.Thread.Thread(String)
  This explicitly sets the name
  
org.apache.cassandra.hadoop.cql3.CqlRecordWriter.RangeClient.RangeClient(List<InetAddress>)
 #253 
    "client-" + List<InetAddress> endpoints
  
org.apache.cassandra.net.IncomingStreamingConnection.IncomingStreamingConnection(int,
 Socket, Set<Closeable>) #47 
     "STREAM-INIT-" + socket.getRemoteSocketAddress()
  org.apache.cassandra.net.IncomingTcpConnection.IncomingTcpConnection(int, 
boolean, Socket, Set<Closeable>) #59
     "MessagingService-Incoming-" + socket.getInetAddress()
  
org.apache.cassandra.net.MessagingService.SocketThread.SocketThread(ServerSocket,
 String)  #1000
     "ACCEPT-" + localEp // -  InetAddress whose port to listen on
  
org.apache.cassandra.net.OutboundTcpConnection.OutboundTcpConnection(OutboundTcpConnectionPool)
  #139 
     "MessagingService-Outgoing-" + pool.endPoint() //  j.n.InetAddress
  
org.apache.cassandra.net.OutboundTcpConnection.handshakeVersion(DataInputStream)
 #487
     "HANDSHAKE-" + poolReference.endPoint() //  j.n.InetAddress
  
org.apache.cassandra.utils.CoalescingStrategies.CoalescingStrategy.CoalescingStrategy(Parker,
 Logger, String) #127 
     displayName + " debug thread" // displayName  one of "Time horizon moving 
average", "Moving average", "Fixed", "Disabled"
  
org.apache.cassandra.utils.memory.MemtableCleanerThread.MemtableCleanerThread(P,
 Runnable) #40 
     pool.getClass().getSimpleName() + "Cleaner"

j.l.Thread.Thread(Runnable, String)
  This explicitly sets the name
  org.apache.cassandra.concurrent.SEPWorker.SEPWorker(Long, Work, 
SharedExecutorPool)  #48
     pool.poolName + "-Worker-" + workerId  // poolName is SharedExecutorPool 
workerId is Long
  org.apache.cassandra.db.commitlog.AbstractCommitLogService.start() #161 
     One of "PERIODIC-COMMIT-LOG-SYNCER"  "COMMIT-LOG-WRITER"
  org.apache.cassandra.db.commitlog.CommitLogSegmentManager.start() #170 
     "COMMIT-LOG-ALLOCATOR"
  
org.apache.cassandra.scheduler.RoundRobinScheduler.RoundRobinScheduler(RequestSchedulerOptions)
 #72 
     "REQUEST-SCHEDULER"
  org.apache.cassandra.service.StorageService.initServer(int) #689
     "StorageServiceShutdownHook"
  org.apache.cassandra.streaming.ConnectionHandler.MessageHandler.start(Socket, 
int) #202
     name() + "-" + session.peer // name() is one of "STREAM-IN", "STREAM-OUT" 
and peer is InetAddress
  org.apache.cassandra.utils.TopKSamplerTest.testMultithreadedAccess() #82 
     "inserter"

j.l.Thread.Thread(ThreadGroup, Runnable, String)
 This explicitly sets the name, many possible values
  org.apache.cassandra.concurrent.NamedThreadFactory.newThread(Runnable) #58  
  *  id + ":" + n.getAndIncrement() // id is String, n new AtomicInteger(1)
  *  "Repair#" + cmd //  cmd is int
  *   // one of the following
    "Reference-Reaper", "Strong-Reference-Leak-Detector", "internal",
    "CommitLogArchiver", "CommitLogArchiver", "RepairJobTask",  
    "HintsWriteExecutor", "SSTableBatchOpen", "StreamConnectionEstablisher",
    "ReadStage", "MutationStage", "CounterMutationStage", "ViewMutationStage",
    "GossipStage", "RequestResponseStage", "AntiEntropyStage", "MigrationStage",
    "MiscStage", "TracingStage", "InternalResponseStage", "ReadRepairStage",
    "StreamingTransferTaskTimeouts", "StreamReceiveTask", "LocalPool-Cleaner",
    "PendingRangeCalculator", "MemtableFlushWriter", "MemtableFlushWriter",
    "MemtableReclaimMemory", "Thrift", "RPC-Thread", "SecondaryIndexManagement",
    "Sampler", "JmxCollector", "StressMetrics", "TEST", "MODIFY", "COMPARE",
    "checker" 



> Name threads for improved ops/debugging
> ---------------------------------------
>
>                 Key: CASSANDRA-10031
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10031
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: T Jake Luciani
>            Priority: Minor
>              Labels: lhf
>             Fix For: 3.x
>
>
> We currently provide basic names for threads in threads like {{STREAM-IN-1}}  
> which gives some basic information about what the job of the thread is.  
> When looking at a log statement or jstack it's helpful to have this context.
> For our work stealing thread pool we share threads across all thread pools so 
> we lose this insight.  
> I'd like to propose we start using the Thread.currentThread().setName("")
> In different aspects of the code to improve insight as to what cassandra is 
> doing at any given moment.
>    * At a minimum in the start of each run() method.
>   Ideally for much finer grain things.
>    * In compaction include the partition name currently being working on.  
>    * In SP include the client ip
> Etc...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to