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

refactoring: Move insert_documents to execute ql #259

Merged
merged 3 commits into from
Dec 3, 2023

Conversation

SergeiNA
Copy link
Collaborator

@SergeiNA SergeiNA commented Oct 8, 2023

Main task Insert, delete and update should be part of execute_ql

  • Now insert_one and insert_many are part of the execute_ql
  • Now we have to wait on wal response for all mutable operations
  • For update and delete we don't wait (will be fixed soon)
  • Now when wal is off we correctly process on empty manager_wal_replicate
  • Remove waiting signal from disk on remove collection

@SergeiNA SergeiNA force-pushed the sn-remove-insert_document branch 3 times, most recently from 43e5e37 to 1f1d995 Compare November 29, 2023 00:45
* Now insert_one and insert_many are part of the execute_ql
* Now we have to wait on wal response for all mutable operations
* For update and delete we don't wait (will be fixed soon)
* Now when wal is off we correctly process on empty manager_wal_replicate
* Remove waiting signal from disk on remove collection
@SergeiNA SergeiNA changed the title Remove insert document method accross services code base Move insert_documents to execute ql Nov 29, 2023
load_count_answers_ = records.size();
void dispatcher_t::load_from_wal_result(components::session::session_id_t& session, std::vector<services::wal::record_t> in_records) {
// TODO think what to do with records
records_ = std::move(in_records);
Copy link
Collaborator Author

@SergeiNA SergeiNA Nov 29, 2023

Choose a reason for hiding this comment

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

@kotbegemot @makeyavelly plz pay attention to this. We decided to add this with @makeyavelly because before we got it as non const reference

void dispatcher_t::load_from_wal_result(components::session::session_id_t& session, std::vector<services::wal::record_t>& in_records)

This potentially can lead to danling references.

@@ -195,96 +198,83 @@ namespace services::dispatcher {
}

void dispatcher_t::execute_ql_finish(components::session::session_id_t& session, const result_t& result) {
result_storage_[session] = result;
Copy link
Collaborator Author

@SergeiNA SergeiNA Nov 29, 2023

Choose a reason for hiding this comment

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

@kotbegemot @makeyavelly I've added this to be able to unlock wrapper_dsipathcer form wal_success

        auto result = result_storage_[session];
        actor_zeta::send(session_obj.address(), dispatcher_t::address(), handler_id(route::execute_ql_finish), session, result);

I don't know how effective is it.

void execute_ql(components::session::session_id_t& session, components::ql::ql_statement_t* ql, actor_zeta::address_t address);
void execute_ql_finish(components::session::session_id_t& session, const components::result::result_t& result);
void drop_collection_finish_from_disk(components::session::session_id_t& session, std::string& collection_name);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This no longer need -> we don't wait response form disk

@SergeiNA SergeiNA self-assigned this Nov 29, 2023
@SergeiNA SergeiNA changed the title Move insert_documents to execute ql refactoring/enhancement: Move insert_documents to execute ql Nov 29, 2023
@kotbegemot kotbegemot added the enhancement New feature or request label Nov 29, 2023
@kotbegemot kotbegemot changed the title refactoring/enhancement: Move insert_documents to execute ql refactoring: Move insert_documents to execute ql Nov 29, 2023
@SergeiNA SergeiNA marked this pull request as ready for review November 29, 2023 20:48
Copy link
Collaborator

@makeyavelly makeyavelly left a comment

Choose a reason for hiding this comment

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

Well done!

auto session_obj = find_session(session_to_address_, session);
const bool is_from_wal = session_obj.address().get() == manager_wal_.get();
if(is_from_wal){
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to clean session`s storage:

remove_session(session_to_address_, session);

Copy link
Collaborator Author

@SergeiNA SergeiNA Dec 3, 2023

Choose a reason for hiding this comment

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

I'm not sure - session will be removed here, isn't it?

        if (!check_load_from_wal(session)) {
            actor_zeta::send(s.address(), dispatcher_t::address(), handler_id(route::execute_ql_finish), session, result);
            remove_session(session_to_address_, session);
        }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And looks like in this case one of the test is fail

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ottergon/integration/cpp/test/test_save_load.cpp:167: FAILED:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -64,7 +64,9 @@ namespace ottergon {
auto doc = to_document(document);
generate_document_id_if_not_exists(doc);
auto session_tmp = ottergon::session_id_t();
auto result = ptr_->insert_one(session_tmp, database_, name_, doc);
auto result_variant = ptr_->insert_one(session_tmp, database_, name_, doc);
assert(result_variant.is_type<components::result::result_insert>() && "wrapper_collection::insert_one result error");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Possible error_result_t

Copy link
Collaborator Author

@SergeiNA SergeiNA Dec 3, 2023

Choose a reason for hiding this comment

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

How I should process it in this case? raise exception?

Added check

            if(result_variant.is_error()){
                debug(log_, "wrapper_collection::insert_one has result error while insert");
                throw std::runtime_error("wrapper_collection::insert_one error_result");
            }

@makeyavelly @makeyavelly PTAL

@SergeiNA SergeiNA merged commit 93353a8 into duckstax:develop Dec 3, 2023
15 of 19 checks passed
@SergeiNA SergeiNA deleted the sn-remove-insert_document branch December 3, 2023 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants