Hello @Roshan Thomas(UST,IN),
welcome to this moderated Azure community forum.
You have a lot of questions about Azure IoT Edge. Great.
Are you aware of the many free learning modules available on MS Learn about this topic?
Regarding the dataloss, you can track everything happening within the modules and on the routing.
Messages from custom modules are sent to other modules or to the cloud (via the EdgeHub) via the internal routing. This routing is persisted for a certain time (you can set it in the deployment manifest). These survive a restart. Data still being executed within your module could be persisted depending the custom logic.
Sudo iotedge restart has a disruptive behavior on the edgeAgent and edgeHub. Check the logging of both modules. There you see this is done in a graceful way.
Data messages are always sent/flushed to IoT Hub when a connection is available.
Messages are only dropped locally when the retention time is passed, probably because the device is disconnected for a longer period.
Take some time to read through the documentation of the offline capabilities too.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.