You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/05/05 13:38:28 UTC
[GitHub] candyleer opened a new issue #1174: Duplicate Service Name And
application id is 0
candyleer opened a new issue #1174: Duplicate Service Name And application id is 0
URL: https://github.com/apache/incubator-skywalking/issues/1174
Please answer these questions before submitting your issue.
- Why do you submit this issue?
- [ ] Question or discussion
- [x] Bug
- [ ] Requirement
- [ ] Feature or performance improvement
___
### Question
- What do you want to know?
___
### Bug
- Which version of SkyWalking, OS and JRE?
- Which company or project?
- What happen?
If possible, provide a way for reproducing the error. e.g. demo application, component version.
when I search in ui `service` page,I found each service has two record, and the `application_id` for one record is 0,I think this is a dirty data. such as
for `/hello/uvw`,the search result in index `service_name` are:
```json
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 4.0748634,
"hits": [
{
"_index": "service_name",
"_type": "type",
"_id": "29",
"_score": 4.0748634,
"_source": {
"service_name": "/hello/uvw",
"service_id": 29,
"src_span_type": 0,
"service_name_keyword": "/hello/uvw",
"application_id": -4
}
},
{
"_index": "service_name",
"_type": "type",
"_id": "-29",
"_score": 3.9653742,
"_source": {
"service_name": "/hello/uvw",
"service_id": -29,
"src_span_type": 0,
"service_name_keyword": "/hello/uvw",
"application_id": 0
}
}
]
}
}
```
and trace is `cross thread`,like
![image](https://user-images.githubusercontent.com/11530760/39663704-a9b21874-50aa-11e8-94a3-bf66ec696734.png)
the reason I try to pinpoint maybe
1. In `Agent`,`cross thread ` didn't have `parentApplicationInstanceId`,see code in `org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef#transform`
```java
public TraceSegmentReference transform() {
TraceSegmentReference.Builder refBuilder = TraceSegmentReference.newBuilder();
if (SegmentRefType.CROSS_PROCESS.equals(type)) {
refBuilder.setRefType(RefType.CrossProcess);
refBuilder.setParentApplicationInstanceId(parentApplicationInstanceId);
if (peerId == DictionaryUtil.nullValue()) {
refBuilder.setNetworkAddress(peerHost);
} else {
refBuilder.setNetworkAddressId(peerId);
}
} else {
refBuilder.setRefType(RefType.CrossThread);
}
refBuilder.setEntryApplicationInstanceId(entryApplicationInstanceId);
refBuilder.setParentTraceSegmentId(traceSegmentId.transform());
refBuilder.setParentSpanId(spanId);
if (entryOperationId == DictionaryUtil.nullValue()) {
refBuilder.setEntryServiceName(entryOperationName);
} else {
refBuilder.setEntryServiceId(entryOperationId);
}
if (parentOperationId == DictionaryUtil.nullValue()) {
refBuilder.setParentServiceName(parentOperationName);
} else {
refBuilder.setParentServiceId(parentOperationId);
}
return refBuilder.build();
}
```
but in `collector` code, this has been handled by this in `org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser.standardization.ReferenceIdExchanger#exchange`
```java
if (standardBuilder.getParentServiceId() == 0) {
String parentServiceName = StringUtils.isNotEmpty(standardBuilder.getParentServiceName()) ? standardBuilder.getParentServiceName() : Const.DOMAIN_OPERATION_NAME;
int parentServiceId = serviceNameService.getOrCreate(instanceCacheService.getApplicationId(standardBuilder.getParentApplicationInstanceId()), SpanType.Entry_VALUE, parentServiceName);
if (parentServiceId == 0) {
if (logger.isDebugEnabled()) {
int parentApplicationId = instanceCacheService.getApplicationId(standardBuilder.getParentApplicationInstanceId());
logger.debug("parent service name: {} from application id: {} exchange failed", parentServiceName, parentApplicationId);
}
return false;
} else {
standardBuilder.toBuilder();
standardBuilder.setParentServiceId(parentServiceId);
standardBuilder.setParentServiceName(Const.EMPTY_STRING);
}
}
```
in `standardBuilder.getParentApplicationInstanceId()` will always be 0 if in `cross thread` model,this maybe not as our expected.
so this will create a record which `application_id` is 0.
```java
int parentServiceId = serviceNameService.getOrCreate(instanceCacheService.getApplicationId(standardBuilder.getParentApplicationInstanceId()), SpanType.Entry_VALUE, parentServiceName);
```
#### maybe we should set `parentApplicationInstanceId` in `cross thread` in `Agent`.
___
### Requirement or improvement
- Please describe about your requirements or improvement suggestions.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services