Repository navigation
Bots: Channel::history reads the store after a restart - #116
Open
TheSeydiCharyyev wants to merge 1 commit into
Open
TheSeydiCharyyev wants to merge 1 commit into
TheSeydiCharyyev wants to merge 1 commit into
Conversation
STATE holds only a window, and a new process starts with none of it, so history returned nothing a bot had stored before a restart, and a sync page could not bring it back. get_messages_before now reads the store too, with a cursor query in db/events.rs. Closes VectorPrivacy#115
Author
|
The red |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A bot's
Channel::historyandChannel::history_beforenow return the messages it stored before a restart. Closes #115.Change
db::events::get_messages_before(new): up tolimitstored messages strictly before an(at_ms, id)cursor, in the same order as STATE's paging. SQL works in whole seconds, so the query reads every row of each second it reaches, and the exact(at, id)order and the cursor check are done in Rust. The cursor is still compared by value, so it works after its message is deleted.VectorCore::get_messages_before: reads STATE as before, then the store, merges by id and keeps the newestlimit. STATE's copy of a message wins, because it can hold a message that is applied but not saved yet.Test
history_reads_the_store_after_a_restartinvector-core/src/community/v2/service.rs:v2_ingest_chat_page: two in the same millisecond, one later in that second, one 5 s before;swap_tothe same actor again, so a new session with an empty STATE opens the same database;limit1 by cursor, and a walk after the same page is ingested again. All three must give the four messages in(at, id)order.Without the fix, all three are
[], whileget_messagestill finds the rows. Three broken versions of the new query also fail the test: reading only the newest second, skipping the cursor's own second, and dropping the cursor check.Verified at
4c865db+ this commit, on Windows:cd crates && cargo test -p vector-core: 2934 passed, 4 failed; integration tests 5 passed, doc tests 5 passed. The 4 are relay and SOCKS tests (a_relay_never_reached_leaves_the_read_of_the_others_complete,heal_waits_out_the_backoff_of_a_recent_close,a_live_subscription_a_relay_closes_is_sent_again,bridge_socks_protocol). They also fail on this machine at4c865dbwithout this change.cargo test -p vector-core --lib -- --ignored guarded_key: 6 passed, 0 failed.Not covered
VectorCore::get_messages(offset paging) still reads only STATE, and the SDK README sends bots to it for older history ("usebot.core().get_messages(...)"). I can change it the same way, or point that README line tochannel.history(), if you want.get_messages_before, so they read the store too now. The test covers a Community channel only.