scylladb / seastar

High performance server-side application framework
http://seastar.io
Apache License 2.0
8.39k stars 1.55k forks source link

Error When run memcached #174

Open xiyanxiyan10 opened 8 years ago

xiyanxiyan10 commented 8 years ago

./core/iostream-impl.hh:60: future<> output_stream::write(net::packet) [with CharType = char]: Assertion `!_end && "Mixing buffered writes and zero-copy writes not supported yet"' failed.

send msg here

build scattered msg and send
765         if (_parser._keys.size() == 1) {
 766             return _cache.get(_parser._keys[0]).then([&out] (auto item) -> future<> {
 767                 scattered_message<char> msg;
 768                 this_type::append_item<WithVersion>(msg, std::move(item));
 769                 msg.append_static(msg_end);                                                                                                                                                             
 770                 return out.write(std::move(msg));
 771             });
 772         } else {

but error here

5 template<typename CharType>
 76 future<> output_stream<CharType>::write(temporary_buffer<CharType> p) {
 77     if (p.empty()) {
 78         return make_ready_future<>();
 79     }
 80     assert(!_end && "Mixing buffered writes and zero-copy writes not supported yet");
 81     if (!_trim_to_size || p.size() <= _size) {
 82         // TODO: aggregate buffers for later coalescing.
 83         return _fd.put(std::move(p));
 84     }
 85     auto head = p.share(0, _size);
 86     p.trim_front(_size);
 87     return _fd.put(std::move(head)).then([this, p = std::move(p)] () mutable {
 88         return write(std::move(p));
 89     });
 90 }
xiyanxiyan10 commented 8 years ago

Oh! I fixed by

765         if (_parser._keys.size() == 1) {
 766             return _cache.get(_parser._keys[0]).then([&out] (auto item) -> future<> {
                       //@TODO null ptr need check here
 767                 //scattered_message<char> msg;
 768                 //this_type::append_item<WithVersion>(msg, std::move(item));
 769                 //msg.append_static(msg_end);
 770   
 771                 std::experimental::string_view key = item->key();
 772                 out.write(key.data(), key.size());
 773 
 774               //  std::experimental::string_view key = item->key();
 775                // out.write(key.data(), key.size());                                                                                                                                                      
 776 
 777                 std::experimental::string_view value = item->value();
 778                 out.write(value.data(), value.size()); 
 779                 
 780                 return make_ready_future<>();
 781             }); 
tgrabiec commented 8 years ago

output_stream does support writing scattered message. It doesn't support mixing scattered with not scattered. It used to be the case that the scope of mixing was limited to flush() boundary and because we flushed after each handler, some handlers could use scattering, and some not, without violating the no mixing rule. But I can see that flush batching relaxed those boundaries since it no longer clears _end.

tgrabiec commented 8 years ago

I can see the following options:

@avikivity @gleb-cloudius