Skip to content

[ENH] Add a scout-logs function to find the max log position. #4232

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

Merged
merged 21 commits into from
Apr 10, 2025

Conversation

rescrv
Copy link
Contributor

@rescrv rescrv commented Apr 8, 2025

This PR makes a currently-not-used scout-logs function. It adds it to
the go service, the rust log service over grpc, and the rust log client
over grpc and in-memory.

Copy link

github-actions bot commented Apr 8, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@rescrv rescrv force-pushed the rescrv/scout-logs branch from 381ad43 to 97af226 Compare April 9, 2025 18:24
@@ -45,6 +45,13 @@ SELECT CAST(COALESCE(MIN(r.offset), 0) as bigint) AS min_offset, CAST(COALESCE(M
FROM record_log r
WHERE r.collection_id = $1;

-- name: GetBoundsForCollection :one
SELECT
COALESCE(record_compaction_offset_position, 0) AS record_compaction_offset_position,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm, COALESCE will ensure that if the collection does not exist in the table then it returns 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make it return the uncoalesced row instead. I thought "one" would enforce it.

var tx pgx.Tx
tx, err = r.conn.BeginTx(ctx, pgx.TxOptions{})
if err != nil {
trace_log.Error("Error in begin transaction for garbage collection", zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: error msg is wrong. This is not inside garbage_collection

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a nit. Fixed.

}
rollback = false;
tx.Commit(ctx)
start = bounds.RecordEnumerationOffsetPosition
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I am misunderstanding something, shouldn't start be bounds.RecordsCompactionOffsetPosition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

return
}
var totalUncompactedDepth int64
totalUncompactedDepth, err = queriesWithTx.GetTotalUncompactedRecordsCount(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this call? Isn't start = bounds.RecordsCompactionOffsetPosition and limit=bounds.RecordEnumerationOffsetPosition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that and it fails predictably on a number of tests.

@rescrv rescrv force-pushed the rescrv/scout-logs branch from 705bdbf to 97b6fdb Compare April 10, 2025 14:47
@rescrv rescrv requested a review from sanketkedia April 10, 2025 18:17
var collectionID types.UniqueID
collectionID, err = types.ToUniqueID(&req.CollectionId)
if err != nil {
// TODO HANDLE ERROR
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: don't understand the todo

@@ -14,6 +14,15 @@ message PushLogsResponse {
int32 record_count = 1;
}

message ScoutLogsRequest {
string collection_id = 1;
int64 start_from_offset = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

start_from_offset does not seem to be used anywhere

let start = start as i64;
let sema = Arc::clone(&sema);
async move {
let _permit = sema.acquire().await.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a few places where we have this pattern. Might be useful to have a util abstraction for this. Don't have to do it in this PR though

@rescrv rescrv merged commit 9866b83 into main Apr 10, 2025
66 checks passed
@rescrv rescrv deleted the rescrv/scout-logs branch April 10, 2025 20:07
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