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

sendSegment is not thread-safe #44

Open
liberize opened this issue Dec 21, 2020 · 5 comments
Open

sendSegment is not thread-safe #44

liberize opened this issue Dec 21, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@liberize
Copy link

sendSegment is not thread-safe because GrpcAsyncSegmentReporterStream::clearPendingMessages is not
which causes SIGABRT with proto_buffer_writer.h:65 assertion failed: !byte_buffer->Valid()

@wu-sheng
Copy link
Member

@Shikugawa Do we open multiple threads for sending the segment?

@Shikugawa
Copy link
Member

Shikugawa commented Dec 21, 2020

It won't be a problem on Envoy integration so I ignored this problem although I already know about it. But when we use it as SDK, It will be a critical problem. This problem is not directly related with Envoy integration. So I will submit a patch for 0.2.0.

@Shikugawa Shikugawa added this to the 0.2.0 milestone Dec 21, 2020
@Shikugawa Shikugawa added the bug Something isn't working label Jan 14, 2021
@Shikugawa
Copy link
Member

@liberize After all we don't have to allow sharing tracer between threads because it should be lock-free. Have you considered this to have per thread?

@wu-sheng
Copy link
Member

wu-sheng commented Feb 3, 2021

@Shikugawa Tracer as per thread is fine, if it is designed in this way, but notice, the sender and grpc channel should be shared across threads, typically using a memory queue to buffer.

@Shikugawa Shikugawa removed this from the 0.2.0 milestone Mar 17, 2021
@xlj
Copy link

xlj commented Dec 3, 2022

I have the same problem. this problem occur in my test demo. demo has only one thread.
this is my demo code:
`#include
#include

#include "cpp2sky/propagation.h"
#include "cpp2sky/tracer.h"
#include "cpp2sky/tracing_context.h"
#include "cpp2sky/well_known_names.h"
using namespace cpp2sky;
TracerConfig config;

void DoTest(int num){
std::fprintf(stdout, "start\n");
config.set_instance_name("node_0");
config.set_service_name("mesh");
config.set_address("0.0.0.0:11800");
TracerPtr _Kcbp_tracer = createInsecureGrpcTracer(config);
std::fprintf(stdout, "start1\n");
while (num-- > 0) {
std::fprintf(stdout, "num:%d\n", num);
auto tracing_context = _Kcbp_tracer->newContext();
{
std::shared_ptr spExitAf = std::make_shared(tracing_context, spSpan->get(), "KCBP_SKYNAME_BpcallAfter");

        auto span = tracing_context->createEntrySpan();
        span->startSpan("/grpc_client.Greeter/handle");
        if (tracing_context != nullptr) {
            span->endSpan();
        }
    }
    bool bRet = _Kcbp_tracer->report(std::move(tracing_context));
}

std::fprintf(stdout, "end\n");

}

int main() {
std::fprintf(stdout, "main\n");
DoTest(3000);
return 0;
}`

the cpp2sky branch is main.
gcc 4.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants