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

RavenDB-14963 - All revisions view #18504

Open
wants to merge 8 commits into
base: v6.0
Choose a base branch
from

Conversation

shaharhikri
Copy link
Contributor

@shaharhikri shaharhikri commented May 12, 2024

Issue link

https://issues.hibernatingrhinos.com/issue/RavenDB-14963/All-revisions-view

Additional description

Add All revisions view EP

{
"TotalResults": 8,
"Results": [
{
"Id": "Users/1",
"Etag": 16,
"LastModified": "2024-05-12T11:53:41.8128727Z",
"ChangeVector": "A:15-UkgaAlPii063JyiBPFBdYQ",
"Flags": "HasRevisions, Revision"
},
{
"Id": "Companies/1",
"Etag": 14,
"LastModified": "2024-05-12T11:53:35.7369914Z",
"ChangeVector": "A:13-UkgaAlPii063JyiBPFBdYQ",
"Flags": "HasRevisions, Revision"
},
{
"Id": "Companies/1",
"Etag": 12,
"LastModified": "2024-05-12T11:53:33.9179408Z",
"ChangeVector": "A:11-UkgaAlPii063JyiBPFBdYQ",
"Flags": "HasRevisions, Revision"
},
{
"Id": "Docs/1",
"Etag": 10,
"LastModified": "2024-05-12T11:53:23.5946301Z",
"ChangeVector": "A:9-UkgaAlPii063JyiBPFBdYQ",
"Flags": "HasRevisions, Revision"
},
{
"Id": "Docs/1",
"Etag": 8,
"LastModified": "2024-05-12T11:53:21.7090247Z",
"ChangeVector": "A:7-UkgaAlPii063JyiBPFBdYQ",
"Flags": "HasRevisions, Revision"
},
{
"Id": "Users/1",
"Etag": 6,
"LastModified": "2024-05-12T11:53:13.4545503Z",
"ChangeVector": "A:5-UkgaAlPii063JyiBPFBdYQ",
"Flags": "HasRevisions, Revision"
},
{
"Id": "Users/1",
"Etag": 4,
"LastModified": "2024-05-09T08:34:28.8081143Z",
"ChangeVector": "A:3-UkgaAlPii063JyiBPFBdYQ",
"Flags": "HasRevisions, Revision"
},
{
"Id": "Users/1",
"Etag": 2,
"LastModified": "2024-05-09T08:34:25.7935544Z",
"ChangeVector": "A:1-UkgaAlPii063JyiBPFBdYQ",
"Flags": "HasRevisions, Revision"
}
]
}

Type of change

  • Bug fix
  • Regression bug fix
  • Optimization
  • New feature

How risky is the change?

  • Low
  • Moderate
  • High
  • Not relevant

Backward compatibility

  • Non breaking change
  • Ensured. Please explain how has it been implemented?
  • Breaking change
  • Not relevant

Is it platform specific issue?

  • Yes. Please list the affected platforms.
  • No

Documentation update

  • This change requires a documentation update. Please mark the issue on YouTrack using Documentation Required tag.
  • No documentation update is needed

Testing by Contributor

  • Tests have been added that prove the fix is effective or that the feature works
  • Internal classes added to the test class (e.g. entity or index definition classes) have the lowest possible access modifier (preferable private)
  • It has been verified by manual testing

Testing by RavenDB QA team

  • This change requires a special QA testing due to possible performance or resources usage implications (CPU, memory, IO). Please mark the issue on YouTrack using QA Required tag.
  • No special testing by RavenDB QA team is needed

Is there any existing behavior change of other features due to this change?

  • Yes. Please list the affected features/subsystems and provide appropriate explanation
  • No

UI work

  • It requires further work in the Studio. Please mark the issue on YouTrack using Studio Required tag.
  • No UI work is needed

@github-actions github-actions bot added the v6.0 label May 12, 2024
Copy link
Contributor

@karmeli87 karmeli87 left a comment

Choose a reason for hiding this comment

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

Looks good, most of the pieces are in place.
Can we also add few tests for this?

Comment on lines +48 to +80
var first = true;
foreach (var revision in revisions)
{
if (first)
first = false;
else
writer.WriteComma();

writer.WriteStartObject();

writer.WritePropertyName(nameof(Document.Id));
writer.WriteString(revision.Id);
writer.WriteComma();

writer.WritePropertyName(nameof(Document.Etag));
writer.WriteInteger(revision.Etag);
writer.WriteComma();

writer.WritePropertyName(nameof(Document.LastModified));
writer.WriteDateTime(revision.LastModified, true);
writer.WriteComma();

writer.WritePropertyName(nameof(Document.ChangeVector));
writer.WriteString(revision.ChangeVector);
writer.WriteComma();

writer.WritePropertyName(nameof(Document.Flags));
writer.WriteString(revision.Flags.ToString());

writer.WriteEndObject();
}

writer.WriteEndArray();
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice we could unify this code with the sharded one...
for that I guess we will need to project the revision to something like
(Id, Etag, LastModified, ChangeVector, Flags)

Copy link
Contributor

Choose a reason for hiding this comment

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

handle rest of the comments first and ping about this one at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked about it and decided to pass

@shaharhikri shaharhikri force-pushed the RavenDB-14963 branch 4 times, most recently from 69f4d61 to 6fe675b Compare May 15, 2024 12:47
Comment on lines 1 to 2
using System;
using System.Collections.Generic;
Copy link
Contributor

Choose a reason for hiding this comment

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

revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cannot remove the using System.Collections.Generic;

test/SlowTests/Issues/RavenDB-14963.cs Outdated Show resolved Hide resolved
test/SlowTests/Issues/RavenDB-14963.cs Outdated Show resolved Hide resolved
@karmeli87 karmeli87 requested a review from ppekrol May 15, 2024 13:27
}

if (etag != null)
HttpContext.Response.Headers["ETag"] = "\"" + etag + "\"";
Copy link
Member

Choose a reason for hiding this comment

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

use Constants.Headers.Etag here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

writer.WriteComma();

writer.WritePropertyName(nameof(PreviewRevisionsResult.Results));
await WriteItems(context, writer);
Copy link
Member

Choose a reason for hiding this comment

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

WriteItemsAsync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -21,5 +22,13 @@ public async Task Delete()
using (var processor = new ShardedStudioCollectionHandlerProcessorForDeleteCollection(this))
await processor.ExecuteAsync();
}

[RavenShardedAction("/databases/*/studio/revisions/preview", "GET")]

Copy link
Member

Choose a reason for hiding this comment

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

formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

public IEnumerable<Document> GetRevisionsInReverseEtagOrder(DocumentsOperationContext context, int skip, int take)
{
return GetRevisionsInReverseEtagOrderInternal(context,
table: new Table(RevisionsSchema, context.Transaction.InnerTransaction),
Copy link
Member

Choose a reason for hiding this comment

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

We have CompressedRevisionsSchema as well. Don't we need to distinguish here based on _database.DocumentsCompression.CompressRevisions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

public IEnumerable<Document> GetRevisionsInReverseEtagOrderForCollection(DocumentsOperationContext context, string collection, int skip, int take)
{
var collectionName = _documentsStorage.ExtractCollectionName(context, collection);
var table = EnsureRevisionTableCreated(context.Transaction.InnerTransaction, collectionName);
Copy link
Member

Choose a reason for hiding this comment

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

Here EnsureRevisionTableCreated does the _database.DocumentsCompression.CompressRevisions check under the covers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should do this compression check only on write.
The CompressedRevisionsSchema and the RevisionsSchema are basically the same, except the Compressed property.
We use this property only on write.
On read we look at the page metadata, to see whether it (the page) is compressed or not.
so I reverted those changes.

Copy link
Member

Choose a reason for hiding this comment

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

ok

return table.GetNumberOfEntriesFor(RevisionsSchema.FixedSizeIndexes[CollectionRevisionsEtagsSlice]);
}

internal Table GetOrCreateTable(Transaction tx, CollectionName collection)
Copy link
Contributor

Choose a reason for hiding this comment

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

why not to use EnsureRevisionTableCreated instead ?

{
Collection = RequestHandler.GetStringQueryString("collection", required: false);

if (NotModified(context, out var etag))
Copy link
Contributor

Choose a reason for hiding this comment

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

how can this be before InitializeAsync ? how would the sharded database know it is not modified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants