Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  IntBlob: Add debug log when storing value on ref
  RepoSequence: Add debug log when acquiring new sequence batch
  Bazel: Remove version suffix from servlet-api-3_1 rule
  Update no-new-changes error doc
  Ignore WIP changes in "CCed on" dashboard section
  Sequences: Introduce constants for configuration keys/values
  RepoSequence: Add debug log of batch size
  Move Flogger to nongoogle.bzl
  DefaultRefFilter#canSeeSingleChangeRef: Do not fail for invalid change refs
  Upgrade testcontainers to 1.14.3
  Add missing documentation of notedb.changes.sequenceBatchSize

Change-Id: I9e135202b7f520a6267b9ad94c97ed58c8f67233
This commit is contained in:
Marco Miller
2020-06-04 13:52:08 -04:00
10 changed files with 96 additions and 34 deletions

View File

@@ -3612,6 +3612,18 @@ each process retrieves at once.
+
By default, 1.
[[notedb.changes.sequenceBatchSize]]notedb.changes.sequenceBatchSize::
+
The next available change sequence number is stored as UTF-8 text in a
blob pointed to by the `refs/sequences/changes` ref in the `All-Projects`
repository. Multiple processes share the same sequence by incrementing
the counter using normal git ref updates. To amortize the cost of these
ref updates, processes increment the counter by a larger number and
hand out numbers from that range in memory until they run out. This
configuration parameter controls the size of the change ID batch that
each process retrieves at once.
+
By default, 20.
[[oauth]]
=== Section oauth

View File

@@ -22,8 +22,8 @@ commit ID and search for the corresponding change in Gerrit. To do
this simply paste the commit ID in the Gerrit Web UI into the search
field. Details about how to search in Gerrit are explained link:user-search.html[here].
Please note that each commit can really be pushed only once. This
means:
Please note that generally it only makes sense for each commit to
be pushed only once. This means:
. you cannot push a commit again even if the change for which the
commit was pushed before was abandoned (but you may restore the
@@ -31,14 +31,18 @@ means:
. you cannot reset a change to an old patch set by pushing the old
commit for this change again
. if a commit was pushed to one branch you cannot push this commit
to another branch in project scope.
to another branch in project scope (see link:user-upload.html#base[exception]).
. if a commit was pushed directly to a branch (without going through
code review) you cannot push this commit once again for code
review (please note that in this case searching by the commit ID
in the Gerrit Web UI will not find any change)
in the Gerrit Web UI will not find any change), see
link:user-upload.html#base[exception].
If you need to re-push a commit you may rewrite this commit by
link:http://www.kernel.org/pub/software/scm/git/docs/git-commit.html[amending] it or doing an interactive link:http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html[git rebase]. By rewriting the
link:http://www.kernel.org/pub/software/scm/git/docs/git-commit.html[amending]
it or doing an interactive
link:http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html[git
rebase], or see link:user-upload.html#base[exception]. By rewriting the
commit you actually create a new commit (with a new commit ID in
project scope) which can then be pushed to Gerrit.
@@ -46,6 +50,13 @@ If you are pushing the new change to the same destination branch as
the old commit (case 1 above), you also need to replace it with a new
Change-Id, otherwise the push will fail with another error message.
Sometimes a change no longer makes sense to be destined for a specific
branch, and instead of trying to re-push the commit for a different
branch, it makes more sense to move the change to the preferred branch
(where it will now likely need a rebase). Moving the change instead of
pushing a rebased commit to the preferred branch helps to retain code
review comments and any previous patchsets on the original change.
== Fast-forward merges
You will also encounter this error if you did a Fast-forward merge

View File

@@ -193,26 +193,6 @@ maven_jar(
sha1 = "42aa5155a54a87d70af32d4b0d06bf43779de0e2",
)
FLOGGER_VERS = "0.4"
maven_jar(
name = "flogger",
artifact = "com.google.flogger:flogger:" + FLOGGER_VERS,
sha1 = "9c8863dcc913b56291c0c88e6d4ca9715b43df98",
)
maven_jar(
name = "flogger-log4j-backend",
artifact = "com.google.flogger:flogger-log4j-backend:" + FLOGGER_VERS,
sha1 = "17aa5e31daa1354187e14b6978597d630391c028",
)
maven_jar(
name = "flogger-system-backend",
artifact = "com.google.flogger:flogger-system-backend:" + FLOGGER_VERS,
sha1 = "287b569d76abcd82f9de87fe41829fbc7ebd8ac9",
)
maven_jar(
name = "gson",
artifact = "com.google.code.gson:gson:2.8.5",

View File

@@ -20,6 +20,7 @@ import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.CharMatcher;
import com.google.common.flogger.FluentLogger;
import com.google.common.primitives.Ints;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.entities.Project;
@@ -41,6 +42,8 @@ import org.eclipse.jgit.revwalk.RevWalk;
@AutoValue
public abstract class IntBlob {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
public static Optional<IntBlob> parse(Repository repo, String refName) throws IOException {
try (ObjectReader or = repo.newObjectReader()) {
return parse(repo, refName, or);
@@ -84,8 +87,13 @@ public abstract class IntBlob {
throws IOException {
ObjectId newId;
try (ObjectInserter ins = repo.newObjectInserter()) {
logger.atFine().log(
"storing value %d on %s in %s (oldId: %s)",
val, refName, projectName, oldId == null ? "null" : oldId.name());
newId = ins.insert(OBJ_BLOB, Integer.toString(val).getBytes(UTF_8));
ins.flush();
logger.atFine().log(
"successfully stored %d on %s as %s in %s", val, refName, newId.name(), projectName);
}
RefUpdate ru = repo.updateRef(refName);
if (oldId != null) {

View File

@@ -30,6 +30,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.flogger.FluentLogger;
import com.google.common.util.concurrent.Runnables;
import com.google.gerrit.entities.Project;
import com.google.gerrit.entities.RefNames;
@@ -64,6 +65,8 @@ import org.eclipse.jgit.transport.ReceiveCommand;
* numbers.
*/
public class RepoSequence {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@FunctionalInterface
public interface Seed {
int get();
@@ -185,6 +188,7 @@ public class RepoSequence {
this.afterReadRef = requireNonNull(afterReadRef, "afterReadRef");
this.retryer = requireNonNull(retryer, "retryer");
logger.atFine().log("sequence batch size for %s is %s", name, batchSize);
counterLock = new ReentrantLock(true);
}
@@ -263,6 +267,7 @@ public class RepoSequence {
private void acquire(int count) {
try (Repository repo = repoManager.openRepository(projectName);
RevWalk rw = new RevWalk(repo)) {
logger.atFine().log("acquire %d ids on %s in %s", count, refName, projectName);
Optional<IntBlob> blob = IntBlob.parse(repo, refName, rw);
afterReadRef.run();
ObjectId oldId;

View File

@@ -32,6 +32,11 @@ import org.eclipse.jgit.lib.Config;
@Singleton
public class Sequences {
private static final String SECTION_NOTEDB = "noteDb";
private static final String KEY_SEQUENCE_BATCH_SIZE = "sequenceBatchSize";
private static final int DEFAULT_ACCOUNTS_SEQUENCE_BATCH_SIZE = 1;
private static final int DEFAULT_CHANGES_SEQUENCE_BATCH_SIZE = 20;
public static final String NAME_ACCOUNTS = "accounts";
public static final String NAME_GROUPS = "groups";
public static final String NAME_CHANGES = "changes";
@@ -60,7 +65,12 @@ public class Sequences {
AllUsersName allUsers,
MetricMaker metrics) {
int accountBatchSize = cfg.getInt("noteDb", "accounts", "sequenceBatchSize", 1);
int accountBatchSize =
cfg.getInt(
SECTION_NOTEDB,
NAME_ACCOUNTS,
KEY_SEQUENCE_BATCH_SIZE,
DEFAULT_ACCOUNTS_SEQUENCE_BATCH_SIZE);
accountSeq =
new RepoSequence(
repoManager,
@@ -70,7 +80,12 @@ public class Sequences {
() -> FIRST_ACCOUNT_ID,
accountBatchSize);
int changeBatchSize = cfg.getInt("noteDb", "changes", "sequenceBatchSize", 20);
int changeBatchSize =
cfg.getInt(
SECTION_NOTEDB,
NAME_CHANGES,
KEY_SEQUENCE_BATCH_SIZE,
DEFAULT_CHANGES_SEQUENCE_BATCH_SIZE);
changeSeq =
new RepoSequence(
repoManager,

View File

@@ -565,7 +565,12 @@ class DefaultRefFilter {
// even if the change is not part of the set of most recent changes that
// SearchingChangeCacheImpl returns.
Change.Id cId = Change.Id.fromRef(refName);
requireNonNull(cId, () -> String.format("invalid change id for ref %s", refName));
if (cId == null) {
// The ref is not a valid change ref. Treat it as non-visible since it's not representing a
// change.
logger.atWarning().log("invalid change ref %s is not visible", refName);
return false;
}
ChangeNotes notes;
try {
notes = changeNotesFactory.create(projectState.getNameKey(), cId);

View File

@@ -16,6 +16,9 @@ dropwizard-core
duct-tape
eddsa
elasticsearch-rest-client
flogger
flogger-log4j-backend
flogger-system-backend
httpasyncclient
httpcore-nio
j2objc

View File

@@ -144,10 +144,10 @@ limitations under the License.
suffixForDashboard: 'limit:25',
},
{
// Open changes the viewed user is CCed on. Changes ignored by the viewing
// user are filtered out.
// Non-WIP open changes the viewed user is CCed on. Changes ignored by the
// viewing user are filtered out.
name: 'CCed on',
query: 'is:open -is:ignored cc:${user}',
query: 'is:open -is:wip -is:ignored cc:${user}',
suffixForDashboard: 'limit:10',
},
{

View File

@@ -112,6 +112,29 @@ def declare_nongoogle_deps():
sha1 = "f84302e14648f9f63c0c73951054aeb2ff0b810a",
)
# Google internal dependencies: these are developed at Google, so there is
# no concern about version skew.
FLOGGER_VERS = "0.4"
maven_jar(
name = "flogger",
artifact = "com.google.flogger:flogger:" + FLOGGER_VERS,
sha1 = "9c8863dcc913b56291c0c88e6d4ca9715b43df98",
)
maven_jar(
name = "flogger-log4j-backend",
artifact = "com.google.flogger:flogger-log4j-backend:" + FLOGGER_VERS,
sha1 = "17aa5e31daa1354187e14b6978597d630391c028",
)
maven_jar(
name = "flogger-system-backend",
artifact = "com.google.flogger:flogger-system-backend:" + FLOGGER_VERS,
sha1 = "287b569d76abcd82f9de87fe41829fbc7ebd8ac9",
)
# Test-only dependencies below.
maven_jar(
@@ -126,18 +149,18 @@ def declare_nongoogle_deps():
sha1 = "dc13ae4faca6df981fc7aeb5a522d9db446d5d50",
)
TESTCONTAINERS_VERSION = "1.14.2"
TESTCONTAINERS_VERSION = "1.14.3"
maven_jar(
name = "testcontainers",
artifact = "org.testcontainers:testcontainers:" + TESTCONTAINERS_VERSION,
sha1 = "d74bc045fb5f30988b0adff20244412972a9f564",
sha1 = "071fc82ba663f469447a19434e7db90f3a872753",
)
maven_jar(
name = "testcontainers-elasticsearch",
artifact = "org.testcontainers:elasticsearch:" + TESTCONTAINERS_VERSION,
sha1 = "66e1a6da0362beee83673b877c9c2e0536d6912c",
sha1 = "3709e2ebb0b6aa4e2ba2b6ca92ffdd3bf637a86c",
)
maven_jar(