Hi everyone,
I’m new to this community and MongoDB in general. I apologize if I’ve used incorrect tags. I’m facing a peculiar issue.
I have a script that updates the deviceName property of a Device object when a method is called. Here’s the relevant code:
`
@Override
public void handle(DeviceDTO deviceDTO) {
var device = deviceService.getByDeviceId(deviceDTO.getDeviceId());
var deviceData = deviceDTO.bindDataToClass(DeviceRenameData.class);
var newName = deviceData.getName();
var deviceInfo = device.getDeviceInfo();
deviceInfo.setDeviceName(newName);
device.setDeviceInfo(deviceInfo);
deviceRepository.save(device);
}
`
This code works perfectly when connected to my local database. However, when I connect to a remote MongoDB M10 cluster, the changes to deviceName are reverted back within about 2 seconds.
I’ve reviewed the MongoDB logs, and here’s what I found:
`
Jul 26, 2024 8:38:21 AM org.example.Main main
INFO: Full Document: "Document{{_id=669f67863c6a102d7f2bad9c, deviceId=22e01a2c-b416-4988-a9ff-f67f4d31a546, tenantId=rahul, deviceStatus=Online, deviceInfo=Document{{ deviceName=TAKSHAK-PL, deviceModel=INTEL H110 Default string }} }}
Jul 26, 2024 8:38:30 AM org.example.Main main
INFO: Full Document: "Document{{_id=669f67863c6a102d7f2bad9c, deviceId=22e01a2c-b416-4988-a9ff-f66f4d31a546, tenantId=rahul, deviceStatus=Online, deviceInfo=Document{{deviceName=BREAKER, deviceModel=INTEL H110 Default string}} }}
Jul 26, 2024 8:38:32 AM org.example.Main main
INFO: Full Document: "Document{{_id=669f67863c6a102d7f2bad9c, deviceId=20e01a2c-b416-4988-a9ff-f67f4d31a546, tenantId=rahul, deviceStatus=Offline, deviceInfo=Document{{deviceName=TAKSHAK-PL, deviceModel=INTEL H110 Default string}} }}
`
As you can see, the deviceName is reverted back to “TAKSHAK-PL” after a short period. The interesting part is that this issue isn’t always reproducible; sometimes, the update persists.
I’d appreciate any insights you can offer on what might be causing this problem.