Visitar URL original
sendSegment is not thread-safe · Issue #44 · SkyAPM/cpp2sky · GitHub
Skip to content

sendSegment is not thread-safe #44

Description

@liberize

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

Activity

  1. wu-sheng commented on Dec 21, 2020

    @wu-sheng
    Member

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

  2. Shikugawa commented on Dec 21, 2020

    @Shikugawa
    Member

    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.

  3. added this to the 0.2.0 milestone on Dec 21, 2020
  4. Shikugawa commented on Feb 3, 2021

    @Shikugawa
    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?

  5. wu-sheng commented on Feb 3, 2021

    @wu-sheng
    Member

    @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.

  6. removed this from the 0.2.0 milestone on Mar 17, 2021
  7. xlj commented on Dec 3, 2022

    @xlj

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions