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: ensure storages are force flushed during uplink shutdown #311

Merged
merged 12 commits into from
Jan 4, 2024

Conversation

de-sh
Copy link
Contributor

@de-sh de-sh commented Dec 1, 2023

Closes #

Changes

Why?

Storage might contain publishes that aren't enough to overflow from in-memory buffer onto disk, in this situation, during shutdown, uplink must force them to be written into file to save them from being lost.

Trials Performed

Consult linked PRs for more detail

Devdutt Shenoi added 4 commits December 1, 2023 20:46
* feat: force serializer into crash mode on shutdown

* log: writing incoming data into persistence

* fix: pull pending requests from channel
* feat: force flush non-overflowed in-memory buffers

* fix: increase shutdown period

NOTE: necessary for safely handling force flush to disk

* log: successful force flush

* doc: update comment

* fix: `try_recv` to trigger storage flush

NOTE: needs to be verified for any realistic possibility of data loss

* fix: ignore empty buffers

* fix: write not read buffer

* fix: ignore empty write buffers

* fix: wait max 2 secs for data flushed from bridge
@de-sh de-sh marked this pull request as draft December 5, 2023 11:58
de-sh pushed a commit that referenced this pull request Dec 10, 2023
@de-sh
Copy link
Contributor Author

de-sh commented Dec 10, 2023

Code to ease readability of control handles as requested by @tekjar is included in the PR #316 and this commit

@de-sh de-sh marked this pull request as ready for review December 10, 2023 17:37
@de-sh de-sh requested a review from tekjar December 10, 2023 17:37
de-sh

This comment was marked as resolved.

@@ -200,7 +200,7 @@ fn main() -> Result<(), Error> {
uplink.resolve_on_shutdown().await.unwrap();
info!("Uplink shutting down...");
// NOTE: wait 5s to allow serializer to write to network/disk
sleep(Duration::from_secs(5)).await;
sleep(Duration::from_secs(10)).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make shutdown reactive/synchronous in a separate PR

@de-sh de-sh merged commit 2d1a69d into main Jan 4, 2024
2 checks passed
@de-sh de-sh deleted the force-flush branch January 4, 2024 10:29
de-sh pushed a commit that referenced this pull request Jan 4, 2024
* changes by vilayat

* changes by vilayat

* fix: basic implementation fixes, needs debugging

* doc: note on where to load inflight publishes

* fix: `EventLoop::clean` to force persist inflight

* chore: cleanup

* doc: remove outdated comments

* doc: don't disconnect, note why

* chore: rm unused loc

* feat: load saved inflight publishes on uplink restart (#307)

* Implemeted reading from disk and publishing onto the network

* inflight persistence logic

* doc: make the code readable

---------

Co-authored-by: Devdutt Shenoi <devdutt@bytebeam.io>

* chore: revert unrelated changes

* doc: make it clear what is happening

* doc: replace commented out code with TODO

* fix: `Error=PacketIdZero`

* chore: cargo update

* fix: handle incoming data during inflight recovery

* doc: describe undesired behavior

* refactor: DRY `PersistenceFile`

* log: add condition for successful completion

* doc: improve comments in `recovery`

* refactor: improve readability with placement

* fix: merge breaking code

* doc: code improvement TODO based on #311

* feat: `Ctrl` handles for `Mqtt`

* refactor: remove code that never gets hit

* refactor: load pending packets into eventloop

* fix: delete file once read

* refactor: error handling in recovery

* fix: glienicke bridge to limit inflight growth

* refactor: unnecessary copy

* style: don't log before success

* log: make sense

* fix: save pending files from getting lost

* fix: `VecDeque` to maintain order

* doc: revert update to illustration

* style: remove whitespace

* rm: unused directories

* chore: use main rumqtt

* doc: update note

* fix: don't change pkid of inflight

* log: improve messaging

* style: make it obvious

---------

Co-authored-by: vilayat-ali <vilayatcodemysite@gmail.com>
Co-authored-by: Syed Vilayat Ali Rizvi <73014428+Vilayat-Ali@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants