commands/e2e: drop topologyVersion from the handshake; rename to mongo-lite
Advertising topologyVersion in the hello reply is what tells a driver the server speaks the streaming (awaitable) hello protocol — in the Node driver it is the only condition checked. From the second heartbeat on, the driver then monitored with an exhaust hello (exhaustAllowed + maxAwaitTimeMS) and waited for a stream of replies carrying moreToCome. We answered once with the flag clear and went back to reading, so every heartbeat failed with "Server ended moreToCome unexpectedly", destroying the connection and clearing the pool. MongoDB Compass showed this as a connect/disconnect loop once per heartbeat. We do not implement streaming hello, so we must not claim to. Omitting the field keeps monitoring on the polling path, and agrees with the maxWireVersion 8 we report: streaming hello arrived in wire version 9. The existing e2e files all passed against the broken server — they issue their commands and exit before the second heartbeat — so e2e5 watches SDAM heartbeats on an idle connection instead. Also renames mongo-light to mongo-lite throughout (binary, log messages, docs, gitVersion). Unrelated to the fix above, but squashed in at request rather than left as a commit whose message described only the fix.
This commit is contained in:
@@ -35,7 +35,7 @@ pub const Server = struct {
|
||||
var listener = try addr.listen(io, .{ .reuse_address = true });
|
||||
defer listener.deinit(io);
|
||||
|
||||
std.debug.print("mongo-light: listening on {s}:{d}\n", .{ self.bind_ip, self.port });
|
||||
std.debug.print("mongo-lite: listening on {s}:{d}\n", .{ self.bind_ip, self.port });
|
||||
|
||||
var group: std.Io.Group = .init;
|
||||
defer group.cancel(io);
|
||||
@@ -48,7 +48,7 @@ pub const Server = struct {
|
||||
const stream = listener.accept(io) catch |err| switch (err) {
|
||||
error.Canceled => return,
|
||||
else => {
|
||||
std.debug.print("mongo-light: accept error: {s}\n", .{@errorName(err)});
|
||||
std.debug.print("mongo-lite: accept error: {s}\n", .{@errorName(err)});
|
||||
continue;
|
||||
},
|
||||
};
|
||||
@@ -72,7 +72,7 @@ fn ttl_monitor(io: std.Io, server: *Server) error{Canceled}!void {
|
||||
defer server.engine.unlock();
|
||||
const now_ms = std.Io.Timestamp.now(io, .real).toMilliseconds();
|
||||
_ = server.engine.ttl_sweep(now_ms) catch |err| {
|
||||
std.debug.print("mongo-light: TTL sweep failed: {s}\n", .{@errorName(err)});
|
||||
std.debug.print("mongo-lite: TTL sweep failed: {s}\n", .{@errorName(err)});
|
||||
continue;
|
||||
};
|
||||
}
|
||||
@@ -113,7 +113,7 @@ fn handle_connection_inner(io: std.Io, stream: std.Io.net.Stream, server: *Serve
|
||||
reader.interface.readSliceAll(&len_bytes) catch return; // clean client disconnect (EOF or RST)
|
||||
const total: u32 = std.mem.readInt(u32, &len_bytes, .little);
|
||||
if (total < 16 or total > wire.max_message_size) {
|
||||
std.debug.print("mongo-light: bad message length {d} on conn {d}\n", .{ total, connection_id });
|
||||
std.debug.print("mongo-lite: bad message length {d} on conn {d}\n", .{ total, connection_id });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,14 +122,14 @@ fn handle_connection_inner(io: std.Io, stream: std.Io.net.Stream, server: *Serve
|
||||
msg_buf.items.len = total;
|
||||
std.mem.writeInt(u32, msg_buf.items[0..4], total, .little);
|
||||
reader.interface.readSliceAll(msg_buf.items[4..]) catch |err| {
|
||||
std.debug.print("mongo-light: read error on conn {d}: {s} (body, len {d})\n", .{ connection_id, @errorName(err), total });
|
||||
std.debug.print("mongo-lite: read error on conn {d}: {s} (body, len {d})\n", .{ connection_id, @errorName(err), total });
|
||||
return;
|
||||
};
|
||||
|
||||
var msg = wire.Message.parse(server.gpa, msg_buf.items) catch |err| {
|
||||
// Unparseable request: close the connection.
|
||||
const op: i32 = if (msg_buf.items.len >= 16) std.mem.readInt(i32, msg_buf.items[12..16], .little) else 0;
|
||||
std.debug.print("mongo-light: bad message on conn {d}: {s} (opCode {d})\n", .{ connection_id, @errorName(err), op });
|
||||
std.debug.print("mongo-lite: bad message on conn {d}: {s} (opCode {d})\n", .{ connection_id, @errorName(err), op });
|
||||
return;
|
||||
};
|
||||
defer msg.deinit();
|
||||
@@ -154,16 +154,16 @@ fn handle_connection_inner(io: std.Io, stream: std.Io.net.Stream, server: *Serve
|
||||
else
|
||||
reply.build(server.gpa, reply_request_id, msg.request_id, &out_buf);
|
||||
built catch |err| {
|
||||
std.debug.print("mongo-light: reply build error on conn {d}: {s}\n", .{ connection_id, @errorName(err) });
|
||||
std.debug.print("mongo-lite: reply build error on conn {d}: {s}\n", .{ connection_id, @errorName(err) });
|
||||
return;
|
||||
};
|
||||
reply_request_id +%= 1;
|
||||
writer.interface.writeAll(out_buf.items) catch |err| {
|
||||
std.debug.print("mongo-light: write error on conn {d}: {s}\n", .{ connection_id, @errorName(err) });
|
||||
std.debug.print("mongo-lite: write error on conn {d}: {s}\n", .{ connection_id, @errorName(err) });
|
||||
return;
|
||||
};
|
||||
writer.interface.flush() catch |err| {
|
||||
std.debug.print("mongo-light: flush error on conn {d}: {s}\n", .{ connection_id, @errorName(err) });
|
||||
std.debug.print("mongo-lite: flush error on conn {d}: {s}\n", .{ connection_id, @errorName(err) });
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user