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

Fix Packet size mismatch! error on collection drop #2813

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mongodb/vibe/db/mongo/collection.d
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,15 @@ struct MongoCollection {
}
}

/// Drop a collection
@safe unittest {
import vibe.db.mongo.mongo;
auto client = connectMongoDB("127.0.0.1");
auto chunks = client.getCollection("test.fs.chunks");

chunks.drop;
}

/**
Specifies a level of isolation for read operations. For example, you can use read concern to only read data that has propagated to a majority of nodes in a replica set.
Expand Down
8 changes: 4 additions & 4 deletions mongodb/vibe/db/mongo/connection.d
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ final class MongoConnection {
{
import std.traits;

auto bytes_read = m_bytesRead;
auto packet_start_index = m_bytesRead;
int msglen = recvInt();
int resid = recvInt();
int respto = recvInt();
Expand All @@ -731,7 +731,7 @@ final class MongoConnection {
sectionLength -= uint.sizeof; // CRC present

bool gotSec0;
while (m_bytesRead - bytes_read < sectionLength) {
while (m_bytesRead - packet_start_index < msglen) {
// TODO: directly deserialize from the wire
static if (!dupBson) {
ubyte[256] buf = void;
Expand Down Expand Up @@ -783,9 +783,9 @@ final class MongoConnection {
logDiagnostic("recvData: crc=%s (discarded)", crc);
}

assert(bytes_read + msglen == m_bytesRead,
assert(packet_start_index + msglen == m_bytesRead,
format!"Packet size mismatch! Expected %s bytes, but read %s."(
msglen, m_bytesRead - bytes_read));
msglen, m_bytesRead - packet_start_index));

return resid;
}
Expand Down
Loading