@ref0/git 0.29.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contracts/objects.d.mts +6 -0
- package/dist/core/index-job.mjs +5 -2
- package/dist/lfs/copy.mjs +2 -2
- package/dist/lfs/objects.mjs +55 -12
- package/dist/lfs/ranges.mjs +33 -0
- package/dist/storage/calls.mjs +6 -5
- package/dist/storage/clean-up.mjs +2 -2
- package/dist/storage/index-build.mjs +8 -4
- package/dist/storage/merge.mjs +3 -2
- package/dist/storage/object-rows.mjs +31 -8
- package/dist/storage/pack-receive.d.mts +1 -0
- package/dist/storage/pack-receive.mjs +5 -4
- package/dist/storage/packs.mjs +5 -1
- package/dist/storage/quarantine.d.mts +1 -0
- package/dist/storage/quarantine.mjs +34 -9
- package/dist/storage/receive-bounds.mjs +3 -1
- package/dist/storage/receive-steps.d.mts +1 -2
- package/dist/storage/receive-steps.mjs +9 -20
- package/package.json +3 -3
|
@@ -969,6 +969,12 @@ export interface IndexTryInput extends CallInput {
|
|
|
969
969
|
* it: the try's calls are part spent, so the next try makes its first step.
|
|
970
970
|
*/
|
|
971
971
|
readonly lastCheck?: true;
|
|
972
|
+
/**
|
|
973
|
+
* The step's data is what the step before it answered in the same try, never data a settled
|
|
974
|
+
* try kept. A host may ignore it. A try lost earlier may still have written this step's files,
|
|
975
|
+
* so a step that skips a lookup for them keeps a safe path for one that's there (#2518).
|
|
976
|
+
*/
|
|
977
|
+
readonly chained?: true;
|
|
972
978
|
}
|
|
973
979
|
/**
|
|
974
980
|
* A try's end: another step due now, with the data to keep; the `index` row to commit, after
|
package/dist/core/index-job.mjs
CHANGED
|
@@ -98,7 +98,8 @@ const refusalError = (refusal) => refusal === "spent" ? `git.index ran out of it
|
|
|
98
98
|
* asked once more over a fresh read, with `lastCheck`, and its answer is the try's: no `moved`
|
|
99
99
|
* leaves the job. A `chained` step, one after another in the same try, commits no refusal: its
|
|
100
100
|
* calls are what the steps before it left, so its row ends `withheld`, and the try ends with the
|
|
101
|
-
* step before it kept, for the next try to run first with the whole budget (#2525).
|
|
101
|
+
* step before it kept, for the next try to run first with the whole budget (#2525). Its step is
|
|
102
|
+
* told it's `chained`, as its data is the try's own (#2518).
|
|
102
103
|
*/
|
|
103
104
|
const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, internalId, data, signal, round, options = {}) {
|
|
104
105
|
const { failed, chained } = options;
|
|
@@ -114,7 +115,8 @@ const indexAttempt = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store,
|
|
|
114
115
|
round,
|
|
115
116
|
failed,
|
|
116
117
|
at,
|
|
117
|
-
lastCheck
|
|
118
|
+
lastCheck,
|
|
119
|
+
chained
|
|
118
120
|
});
|
|
119
121
|
const stepOf = (asked) => Effect.flatMap(budgetedInput(asked.input), (input) => index.step(asked.listed, input));
|
|
120
122
|
const first = yield* read();
|
|
@@ -256,6 +258,7 @@ const readTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, inter
|
|
|
256
258
|
if (row !== void 0) input.row = row.value;
|
|
257
259
|
if (roots.size > 0) input.roots = [...roots];
|
|
258
260
|
if (of.lastCheck === true) input.lastCheck = true;
|
|
261
|
+
if (of.chained === true) input.chained = true;
|
|
259
262
|
const [looseRow] = looseRows;
|
|
260
263
|
return {
|
|
261
264
|
record,
|
package/dist/lfs/copy.mjs
CHANGED
|
@@ -195,10 +195,10 @@ const partsPut = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, partBytes,
|
|
|
195
195
|
/** The copy over LFS's registration's rows and its bucket, each put inside `charge`, its `putCharge`. */
|
|
196
196
|
const lfsCopy = (rows, bucket, charge) => {
|
|
197
197
|
const partBytes = Math.max(Number.isFinite(bucket.multipart.partSize) ? bucket.multipart.partSize : 0, copyPartDefault);
|
|
198
|
-
const put = (staging, body, size, oid) => Effect.scoped(Effect.andThen(charge(bucket.multipart, { size }), Effect.asVoid(
|
|
198
|
+
const put = (staging, body, size, oid) => Effect.scoped(Effect.andThen(charge(bucket.multipart, { size }), Effect.asVoid(bucketDo(bucket.put(staging.key, body, {
|
|
199
199
|
size,
|
|
200
200
|
sha256: oid
|
|
201
|
-
})))))
|
|
201
|
+
})))));
|
|
202
202
|
return {
|
|
203
203
|
listed: (repo, oids) => listedOf(rows, repo, oids),
|
|
204
204
|
stage: (repo, objects) => copyStages(rows, bucket, repo, objects),
|
package/dist/lfs/objects.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { CallBudget } from "../store/call-count.mjs";
|
|
|
16
16
|
import { isLfsOid, lfsPointerText } from "../protocol/objects/lfs-pointer.mjs";
|
|
17
17
|
import { ListedRow, UploadRow, largestObject, lfsCollections, linkLife, listedKey, listedRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead } from "./rows.mjs";
|
|
18
18
|
import { BatchRequest, VerifyRequest, batchMost, bodyOf, lfsAnswer } from "./wire.mjs";
|
|
19
|
+
import { askedOf } from "./ranges.mjs";
|
|
19
20
|
import { uploadedRow } from "./uploaded.mjs";
|
|
20
21
|
import { checkedAfterMost, pastMost, uploadPieceBytes } from "./upload-most.mjs";
|
|
21
22
|
import { fail, gitError, httpStatus } from "../contracts/result.mjs";
|
|
@@ -481,10 +482,10 @@ const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
|
481
482
|
if (staging === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("One staging key asked, none made"));
|
|
482
483
|
const { key } = staging;
|
|
483
484
|
const sent = counted(call.request.body, upload.size);
|
|
484
|
-
const put = yield* Effect.result(
|
|
485
|
+
const put = yield* Effect.result(bucketDo(bucket.put(key, sent.body, {
|
|
485
486
|
size: upload.size,
|
|
486
487
|
sha256: oid
|
|
487
|
-
})))
|
|
488
|
+
})));
|
|
488
489
|
if (Result.isFailure(put)) {
|
|
489
490
|
if (sent.past()) return yield* Effect.fail(pastSize(upload.size));
|
|
490
491
|
if (sent.size() < upload.size) return yield* Effect.fail(shortSize(upload.size, sent.size()));
|
|
@@ -630,7 +631,20 @@ const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (registered, call
|
|
|
630
631
|
* rules are asked of it then, before the bucket's stream opens, and their refusal or failure is
|
|
631
632
|
* the read's. `signal` aborted cancels the bucket's stream, opening or open.
|
|
632
633
|
*/
|
|
633
|
-
const objectOf =
|
|
634
|
+
const objectOf = (parts, read) => Effect.flatMap(askedObject(parts, read, () => whole), ({ oid, size, bytes }) => bytes === void 0 ? missingBytes(oid) : Effect.succeed({
|
|
635
|
+
oid,
|
|
636
|
+
size,
|
|
637
|
+
bytes
|
|
638
|
+
}));
|
|
639
|
+
/** A listed object whose bucket holds no bytes. */
|
|
640
|
+
const missingBytes = (oid) => fail("DATA_LOSS", `LFS object ${oid}'s bytes are missing`);
|
|
641
|
+
/** Asks the whole of an object, as `objectOf` does. */
|
|
642
|
+
const whole = { kind: "whole" };
|
|
643
|
+
/**
|
|
644
|
+
* `objectOf`'s read, of what `asked` makes of the object's size: its whole, a part, whose bytes
|
|
645
|
+
* alone the bucket's stream holds, or none, which opens no stream and answers no bytes.
|
|
646
|
+
*/
|
|
647
|
+
const askedObject = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read, asked) {
|
|
634
648
|
const { oid, size, signal } = read;
|
|
635
649
|
if (!isLfsOid(oid)) return yield* fail("NOT_FOUND", "Object does not exist");
|
|
636
650
|
const repo = yield* openFor(read.caller, read.repo, false, read.internalId, "first-read");
|
|
@@ -646,11 +660,20 @@ const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
|
|
|
646
660
|
},
|
|
647
661
|
request: read.request
|
|
648
662
|
});
|
|
649
|
-
const
|
|
650
|
-
if (
|
|
663
|
+
const ask = asked(listed.size);
|
|
664
|
+
if (ask.kind === "none") return {
|
|
665
|
+
oid,
|
|
666
|
+
size: listed.size,
|
|
667
|
+
ask,
|
|
668
|
+
bytes: void 0
|
|
669
|
+
};
|
|
670
|
+
const range = ask.kind === "part" ? ask.range : void 0;
|
|
671
|
+
const bytes = yield* Effect.uninterruptible(Effect.map(bucketStream(parts.bucket, listed.key, range), (stream) => stream === void 0 || signal === void 0 ? stream : bodyUntilAborted(stream, signal)));
|
|
672
|
+
if (bytes === void 0) return yield* missingBytes(oid);
|
|
651
673
|
return {
|
|
652
674
|
oid,
|
|
653
675
|
size: listed.size,
|
|
676
|
+
ask,
|
|
654
677
|
bytes
|
|
655
678
|
};
|
|
656
679
|
});
|
|
@@ -727,22 +750,42 @@ const objectsOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
|
|
|
727
750
|
});
|
|
728
751
|
/**
|
|
729
752
|
* `GET objects/<oid>`, a Worker download: a listed object's bytes, the repo's own or a source's,
|
|
730
|
-
* as `objectOf` reads them
|
|
731
|
-
*
|
|
732
|
-
*
|
|
753
|
+
* as `objectOf` reads them, or the one range of them its `Range` asks, as a 206, so an import
|
|
754
|
+
* resuming a copy from its offset reads ref0 as it reads any other source. Its fetch rules are
|
|
755
|
+
* asked again, though the batch that gave the link asked them: the link outlives that answer, and
|
|
756
|
+
* a signed bucket's link, which the bucket serves, is asked only at the batch.
|
|
733
757
|
*/
|
|
734
758
|
const send = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
735
|
-
const
|
|
759
|
+
const header = call.request.headers.get("range");
|
|
760
|
+
const object = yield* askedObject(parts, {
|
|
736
761
|
caller: call.caller,
|
|
737
762
|
repo: call.repo,
|
|
738
763
|
oid,
|
|
739
764
|
request: call.request
|
|
765
|
+
}, (size) => askedOf(header, size));
|
|
766
|
+
const { ask, size } = object;
|
|
767
|
+
if (ask.kind === "none") return new Response(null, {
|
|
768
|
+
status: 416,
|
|
769
|
+
headers: { "content-range": `bytes */${size}` }
|
|
740
770
|
});
|
|
741
|
-
|
|
771
|
+
const headers = {
|
|
772
|
+
"content-type": "application/octet-stream",
|
|
773
|
+
"accept-ranges": "bytes"
|
|
774
|
+
};
|
|
775
|
+
if (ask.kind === "whole") return new Response(object.bytes, {
|
|
742
776
|
status: 200,
|
|
743
777
|
headers: {
|
|
744
|
-
|
|
745
|
-
"content-length": String(
|
|
778
|
+
...headers,
|
|
779
|
+
"content-length": String(size)
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
const { offset, length } = ask.range;
|
|
783
|
+
return new Response(object.bytes, {
|
|
784
|
+
status: 206,
|
|
785
|
+
headers: {
|
|
786
|
+
...headers,
|
|
787
|
+
"content-length": String(length),
|
|
788
|
+
"content-range": `bytes ${offset}-${offset + length - 1}/${size}`
|
|
746
789
|
}
|
|
747
790
|
});
|
|
748
791
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/lfs/ranges.ts
|
|
2
|
+
const whole = { kind: "whole" };
|
|
3
|
+
const none = { kind: "none" };
|
|
4
|
+
/** One range of bytes: `bytes=<first>-[<last>]`, or a suffix, `bytes=-<length>`. */
|
|
5
|
+
const oneRange = /^bytes=(\d*)-(\d*)$/u;
|
|
6
|
+
/** `text`, digits alone, as a number, or undefined past the safe integers. */
|
|
7
|
+
const numberOf = (text) => {
|
|
8
|
+
const value = Number(text);
|
|
9
|
+
return Number.isSafeInteger(value) ? value : void 0;
|
|
10
|
+
};
|
|
11
|
+
/** The bytes from `first` to `last`, both counted, as a bucket's read takes them. */
|
|
12
|
+
const part = (first, last) => ({
|
|
13
|
+
kind: "part",
|
|
14
|
+
range: {
|
|
15
|
+
offset: first,
|
|
16
|
+
length: last - first + 1
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
/** What `header`, a request's `Range`, asks of an object of `size` bytes, as `Asked` says. */
|
|
20
|
+
const askedOf = (header, size) => {
|
|
21
|
+
const [, first = "", last = ""] = oneRange.exec(header?.trim() ?? "") ?? [];
|
|
22
|
+
if (first === "" && last === "") return whole;
|
|
23
|
+
if (first === "") {
|
|
24
|
+
const length = numberOf(last);
|
|
25
|
+
if (length === void 0) return whole;
|
|
26
|
+
return length === 0 || size === 0 ? none : part(Math.max(0, size - length), size - 1);
|
|
27
|
+
}
|
|
28
|
+
const start = numberOf(first);
|
|
29
|
+
const end = last === "" ? Number.POSITIVE_INFINITY : numberOf(last);
|
|
30
|
+
if (start === void 0 || end === void 0 || end < start) return whole;
|
|
31
|
+
return start >= size ? none : part(start, Math.min(end, size - 1));
|
|
32
|
+
};
|
|
33
|
+
export { askedOf };
|
package/dist/storage/calls.mjs
CHANGED
|
@@ -483,14 +483,15 @@ const bucketReading = (bucket, key, range, read) => Effect.scoped(Effect.gen(fun
|
|
|
483
483
|
}));
|
|
484
484
|
/**
|
|
485
485
|
* A put of `bytes` to `key`, told its size, so the service charges all its calls as it starts. An
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
486
|
+
* interrupt or a deadline stops it as it stops any call: its store's request is aborted, or on R2,
|
|
487
|
+
* whose binding takes no signal, given up `r2PutSettleMost` on, so a stalled put ends its try
|
|
488
|
+
* within `jobLeaseMargin` of its timeout (#2999). A request its store already took can still land
|
|
489
|
+
* after the try's clean-up deleted its key: `dropRefused` leaves a `staged` row, so its pack's keys
|
|
490
|
+
* are deleted again `receiveStepGrace` on.
|
|
490
491
|
*/
|
|
491
492
|
const bucketPut = (bucket, key, bytes) => {
|
|
492
493
|
const parts = bytes instanceof Uint8Array ? [bytes] : bytes;
|
|
493
494
|
const size = parts.reduce((sum, part) => sum + part.byteLength, 0);
|
|
494
|
-
return
|
|
495
|
+
return bucketDo(bucket.put(key, Stream.fromIterable(parts), { size }));
|
|
495
496
|
};
|
|
496
497
|
export { bodyAcross, bodyOfBytes, bodyThrown, bucketBody, bucketBodyIn, bucketCall, bucketCharge, bucketDeleteMany, bucketDo, bucketFailed, bucketPut, bucketReading, bucketStream, bucketStreamScoped, bucketTry, cancelsBody, counting, deleteCharge, headersOnce, heldOnce, joined, madeOwned, objectReader, objectsOnce, oneShotReads, putCharge, putParts, readEach, readOnce, readWhole, retryCharge, scopedReader, scopedReceive, scopedReceiveStep, sizedPutCalls, sizesOnce, startingOnce, streamedPutCalls, walkObjects };
|
|
@@ -4,8 +4,8 @@ import { bucketDeleteMany, bucketDo } from "./calls.mjs";
|
|
|
4
4
|
import { markerKey, markerPrefix, objectCollections } from "./layout.mjs";
|
|
5
5
|
import { mergeKey } from "./merge-row.mjs";
|
|
6
6
|
import { noRows } from "./object-rows.mjs";
|
|
7
|
-
import { deletePackFiles } from "./quarantine.mjs";
|
|
8
|
-
import { deleteStaged, receiveKey
|
|
7
|
+
import { deletePackFiles, stagedRow } from "./quarantine.mjs";
|
|
8
|
+
import { deleteStaged, receiveKey } from "./receive-steps.mjs";
|
|
9
9
|
import { QuarantineRow, StagedRow, decodeHeld, decodeLeft, quarantineKey, quarantineRow, stagedKey } from "./rows.mjs";
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
11
11
|
/**
|
|
@@ -1455,7 +1455,10 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1455
1455
|
kept: Math.min(madeMost, madeAll)
|
|
1456
1456
|
};
|
|
1457
1457
|
if (below !== void 0) bitmapsInput.below = below;
|
|
1458
|
-
if (tipsKey !== void 0) return yield* bitmapsCutTry(parts, files, data, bitmapsInput,
|
|
1458
|
+
if (tipsKey !== void 0) return yield* bitmapsCutTry(parts, files, data, bitmapsInput, {
|
|
1459
|
+
tipsKey,
|
|
1460
|
+
chained: input.chained === true
|
|
1461
|
+
}, allotment);
|
|
1459
1462
|
const already = yield* storedSize(bucket, files.bitmaps);
|
|
1460
1463
|
const written = already === void 0 ? yield* writeBitmaps(bitmapsInput) : yield* storedBitmaps(bucket, files.bitmaps, positions, already);
|
|
1461
1464
|
if (written === void 0) return void 0;
|
|
@@ -1471,9 +1474,9 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1471
1474
|
* from where the last part ended, through the try's bound less `indexBitmapsCallsAfter`, then put
|
|
1472
1475
|
* through the whole bound. Once the parts hold the order, the try joins them into `.bitmaps`. A
|
|
1473
1476
|
* bitmap the bound cuts is left whole for the next try, and a try that makes none refuses, as the
|
|
1474
|
-
* next would spend its calls at the same place.
|
|
1477
|
+
* next would spend its calls at the same place. `chained` says the step's data is its own try's.
|
|
1475
1478
|
*/
|
|
1476
|
-
const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, input, tipsKey, allotment) {
|
|
1479
|
+
const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, input, { tipsKey, chained }, allotment) {
|
|
1477
1480
|
const order = bitmapOrder(input.chosen);
|
|
1478
1481
|
const ordered = orderKey(order);
|
|
1479
1482
|
const cut = data.bitmapsCut?.order === ordered ? data.bitmapsCut : {
|
|
@@ -1484,7 +1487,7 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1484
1487
|
if (cut.done >= order.length) return yield* bitmapsJoined(parts, files, data, cut, input.positions, allotment);
|
|
1485
1488
|
yield* allotment.grow(partBytesMost);
|
|
1486
1489
|
const key = files.bitmapsPart(cut.order, cut.parts.length);
|
|
1487
|
-
const landed = yield* readWhole(parts.bucket, key);
|
|
1490
|
+
const landed = chained ? void 0 : yield* readWhole(parts.bucket, key);
|
|
1488
1491
|
if (landed !== void 0) {
|
|
1489
1492
|
const count = yield* partCount(key, landed);
|
|
1490
1493
|
return {
|
|
@@ -2368,6 +2371,7 @@ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, lis
|
|
|
2368
2371
|
if (input.deleted !== void 0) step.deleted = input.deleted;
|
|
2369
2372
|
if (input.failed !== void 0) step.failed = input.failed;
|
|
2370
2373
|
if (input.lastCheck === true) step.lastCheck = true;
|
|
2374
|
+
if (input.chained === true) step.chained = true;
|
|
2371
2375
|
const roots = new Set(input.roots ?? []);
|
|
2372
2376
|
const ended = yield* indexStep({
|
|
2373
2377
|
...parts,
|
package/dist/storage/merge.mjs
CHANGED
|
@@ -82,7 +82,7 @@ const started = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, option
|
|
|
82
82
|
const write = (bytes) => Effect.suspend(() => put.pollUnsafe() === void 0 ? Effect.andThen(Effect.raceFirst(Queue.offer(queue, bytes), ended), pulled) : ended);
|
|
83
83
|
return {
|
|
84
84
|
write,
|
|
85
|
-
finish: Effect.
|
|
85
|
+
finish: Effect.andThen(Queue.end(queue), Effect.asVoid(Fiber.join(put))),
|
|
86
86
|
abort
|
|
87
87
|
};
|
|
88
88
|
});
|
|
@@ -177,7 +177,8 @@ const writeRows = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
177
177
|
bucket,
|
|
178
178
|
indexes,
|
|
179
179
|
repo,
|
|
180
|
-
pack: opened.pack
|
|
180
|
+
pack: opened.pack,
|
|
181
|
+
at
|
|
181
182
|
})));
|
|
182
183
|
return {
|
|
183
184
|
pack: {
|
|
@@ -147,6 +147,15 @@ const receivedObject = (change, row) => {
|
|
|
147
147
|
*/
|
|
148
148
|
const wholePageRows = 1e3;
|
|
149
149
|
/**
|
|
150
|
+
* Object rows one `rowHeaders` read asks for by key while its reader knows no staged batch: its A
|
|
151
|
+
* read then carries no size markers, so sizing a tree's 1,000 blobs is one store read rather than
|
|
152
|
+
* ten (#2974). A group too large for one answer, or one whose read lists a batch, is answered again
|
|
153
|
+
* as `rowReadBatch` groups, so step B never reads more than `rowReadBatch` IDs' markers. A header
|
|
154
|
+
* read keeps no row past its answer; a whole-object read stays at `rowReadBatch`, so a push's thin
|
|
155
|
+
* bases still stream a group at a time.
|
|
156
|
+
*/
|
|
157
|
+
const headerReadRows = 1e3;
|
|
158
|
+
/**
|
|
150
159
|
* Object rows a store read refused as too large is cut into: as many of the largest as one answer
|
|
151
160
|
* holds, each row's key and version aside, so no read of them passes its 16 MiB.
|
|
152
161
|
*/
|
|
@@ -237,8 +246,10 @@ const batchesMoved = () => fail("UNAVAILABLE", "Other pushes kept publishing lar
|
|
|
237
246
|
});
|
|
238
247
|
/**
|
|
239
248
|
* Each of `ids`' object rows the repo holds, in `objects` or in a published staged batch, handed to
|
|
240
|
-
* `each` a store read at a time: `
|
|
241
|
-
*
|
|
249
|
+
* `each` a store read at a time: `groupSize` IDs to a group while the reader knows no batch,
|
|
250
|
+
* `rowReadBatch` once it does, and the reads end once `each` answers `false`. A wide group's A
|
|
251
|
+
* read hands what `objects` holds, then answers its misses as `rowReadBatch` groups when it listed
|
|
252
|
+
* a batch, and the whole group as them when it was too large. An ID is missing only when its last read of `objects` missed and every batch
|
|
242
253
|
* that read listed was checked for it in a read that already listed that batch: a published
|
|
243
254
|
* batch's rows and size markers are fixed at its publication and leave it only into `objects`,
|
|
244
255
|
* which keeps them while any batch is listed, so the answer holds at that last read. Answers for
|
|
@@ -256,7 +267,7 @@ const batchesMoved = () => fail("UNAVAILABLE", "Other pushes kept publishing lar
|
|
|
256
267
|
* - Recovery: any body key gone (promoted or removed as a duplicate after the marker hit) is read
|
|
257
268
|
* in one call from `objects/<gone>` with `batches`.
|
|
258
269
|
*/
|
|
259
|
-
const eachRead = (store, repo, ids, each) => {
|
|
270
|
+
const eachRead = (store, repo, ids, each, groupSize = 100) => {
|
|
260
271
|
const scope = repoScope(repo);
|
|
261
272
|
const read = (reads) => store.read({
|
|
262
273
|
scope,
|
|
@@ -373,14 +384,26 @@ const eachRead = (store, repo, ids, each) => {
|
|
|
373
384
|
}
|
|
374
385
|
return true;
|
|
375
386
|
});
|
|
376
|
-
|
|
387
|
+
const resolveWide = Effect.fnUntraced(function* (oids) {
|
|
388
|
+
const wide = yield* readSnapshot(oids, []).pipe(orTooLarge);
|
|
389
|
+
if (wide !== void 0 && !(yield* hand(wide.objectRows))) return false;
|
|
390
|
+
if (wide !== void 0) known = wide.listed;
|
|
391
|
+
const rest = wide === void 0 ? oids : known.length === 0 ? [] : wide.misses;
|
|
392
|
+
for (let at = 0; at < rest.length; at += 100) if (!(yield* resolveGroup(rest.slice(at, at + 100)))) return false;
|
|
393
|
+
return true;
|
|
394
|
+
});
|
|
395
|
+
for (let at = 0; at < asked.length;) {
|
|
396
|
+
const group = asked.slice(at, at + (known.length === 0 ? groupSize : 100));
|
|
397
|
+
at += group.length;
|
|
398
|
+
if (!(yield* group.length > 100 ? resolveWide(group) : resolveGroup(group))) return;
|
|
399
|
+
}
|
|
377
400
|
});
|
|
378
401
|
};
|
|
379
402
|
/** Each of `oids`' rows the repo holds, handed to `each` a store read at a time, as `eachRead` reads. */
|
|
380
|
-
const eachRow = (store, listed, oids, each) => eachRead(store, listed.repo, oids, Effect.fnUntraced(function* (rows) {
|
|
403
|
+
const eachRow = (store, listed, oids, each, groupSize = 100) => eachRead(store, listed.repo, oids, Effect.fnUntraced(function* (rows) {
|
|
381
404
|
for (const row of rows) yield* each(row);
|
|
382
405
|
return true;
|
|
383
|
-
}));
|
|
406
|
+
}), groupSize);
|
|
384
407
|
/**
|
|
385
408
|
* Which of `ids` a repo holds as object rows, read by key as `eachRead` reads, each read at
|
|
386
409
|
* `version`: `undefined` once one answers at another, since the repo moved after the read the
|
|
@@ -656,7 +679,7 @@ const rowHeaders = (store, listed, onRow, cache) => Effect.fnUntraced(function*
|
|
|
656
679
|
if (cache !== void 0 && chunkedOf(row.value) === void 0) cache.putRaw(row, header);
|
|
657
680
|
headers.set(row.id, header);
|
|
658
681
|
onRow?.(row, header);
|
|
659
|
-
}));
|
|
682
|
+
}), headerReadRows);
|
|
660
683
|
return headers;
|
|
661
684
|
});
|
|
662
685
|
/** The size of each of `oids`' rows the repo holds, as `rowHeaders` reads it. */
|
|
@@ -769,4 +792,4 @@ const startingOf = (found, most) => {
|
|
|
769
792
|
more: all.length > most
|
|
770
793
|
};
|
|
771
794
|
};
|
|
772
|
-
export { ObjectRow, bodyPackBytes, copyRowsPage, eachHeldRow, eachPageAt, emptyTreeObject, gitObjectOf, headerOfRow, heldIdsAt, heldRows, largeBatch, noRows, objectKey, objectOfRow, objectRow, readStagedRows, readsOwnChunks, receivedObject, receivedRows, rowAt, rowHeaders, rowInflatedBytes, rowSizes, rowValueBytes, rowsInflatedBytes, rowsMoved, rowsStartingWith, startingOf, tooLargeRead, wholePageRows };
|
|
795
|
+
export { ObjectRow, bodyPackBytes, copyRowsPage, eachHeldRow, eachPageAt, emptyTreeObject, gitObjectOf, headerOfRow, headerReadRows, heldIdsAt, heldRows, largeBatch, noRows, objectKey, objectOfRow, objectRow, readStagedRows, readsOwnChunks, receivedObject, receivedRows, rowAt, rowHeaders, rowInflatedBytes, rowSizes, rowValueBytes, rowsInflatedBytes, rowsMoved, rowsStartingWith, startingOf, tooLargeRead, wholePageRows };
|
|
@@ -286,14 +286,15 @@ const receivePack = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
286
286
|
});
|
|
287
287
|
/** `storePack` with a refused pack's runs, marker, files and row deleted. */
|
|
288
288
|
const storeOrDrop = (input, opened) => {
|
|
289
|
-
const { store, bucket, indexes, listed } = input;
|
|
290
|
-
return Effect.scoped(storePack(input, opened)).pipe(Effect.onError(() => bestEffort(Effect.andThen(dropRuns(bucket, opened.pack), dropRefused({
|
|
289
|
+
const { store, bucket, indexes, listed, clock } = input;
|
|
290
|
+
return Effect.scoped(storePack(input, opened)).pipe(Effect.onError(() => bestEffort(Effect.andThen(dropRuns(bucket, opened.pack), Effect.suspend(() => dropRefused({
|
|
291
291
|
store,
|
|
292
292
|
bucket,
|
|
293
293
|
indexes,
|
|
294
294
|
repo: listed.repo,
|
|
295
|
-
pack: opened.pack
|
|
296
|
-
|
|
295
|
+
pack: opened.pack,
|
|
296
|
+
at: clock.currentTimeMillisUnsafe()
|
|
297
|
+
}))))));
|
|
297
298
|
};
|
|
298
299
|
/**
|
|
299
300
|
* A step of `receivePack` under the quarantine `opened` for the run: the staged pack read on from
|
package/dist/storage/packs.mjs
CHANGED
|
@@ -648,6 +648,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
648
648
|
indexes,
|
|
649
649
|
listed,
|
|
650
650
|
at: clock.currentTimeMillisUnsafe(),
|
|
651
|
+
clock,
|
|
651
652
|
prune,
|
|
652
653
|
receive: input,
|
|
653
654
|
memory,
|
|
@@ -790,6 +791,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
790
791
|
staging: input.staging,
|
|
791
792
|
sliceBytes: input.sliceBytes,
|
|
792
793
|
partBytes: input.partBytes,
|
|
794
|
+
at: clock.currentTimeMillisUnsafe(),
|
|
793
795
|
answer: {
|
|
794
796
|
boundary: [],
|
|
795
797
|
needs: [],
|
|
@@ -803,7 +805,8 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
803
805
|
bucket,
|
|
804
806
|
indexes,
|
|
805
807
|
repo,
|
|
806
|
-
pack
|
|
808
|
+
pack,
|
|
809
|
+
at: clock.currentTimeMillisUnsafe()
|
|
807
810
|
})
|
|
808
811
|
};
|
|
809
812
|
/**
|
|
@@ -845,6 +848,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
845
848
|
indexes,
|
|
846
849
|
listed,
|
|
847
850
|
at: clock.currentTimeMillisUnsafe(),
|
|
851
|
+
clock,
|
|
848
852
|
prune,
|
|
849
853
|
receive: {
|
|
850
854
|
pack: new Blob([]).stream(),
|
|
@@ -3,13 +3,29 @@ import { heldAddition } from "../store/repo-record.mjs";
|
|
|
3
3
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
4
4
|
import { bucketDo, bucketPut } from "./calls.mjs";
|
|
5
5
|
import { isPackId, markerKey, newPackId, packFileKeys } from "./layout.mjs";
|
|
6
|
+
import { receiveStepGrace } from "./receive-bounds.mjs";
|
|
6
7
|
import { repackJobRow } from "./repack-job.mjs";
|
|
7
|
-
import { QuarantineRow, decodeHeld, quarantineKey, quarantineRow, removeAt } from "./rows.mjs";
|
|
8
|
+
import { QuarantineRow, decodeHeld, quarantineKey, quarantineRow, removeAt, stagedKey } from "./rows.mjs";
|
|
8
9
|
import { fail } from "../contracts/result.mjs";
|
|
9
10
|
import * as Effect from "effect/Effect";
|
|
10
11
|
// src/storage/quarantine.ts
|
|
11
12
|
/** The marker that keeps `pack`'s bytes for `repo`: empty, under the pack's `by/`. */
|
|
12
13
|
const putMarker = (bucket, pack, repo) => bucketPut(bucket, markerKey(pack, repo), /* @__PURE__ */ new Uint8Array(0));
|
|
14
|
+
/**
|
|
15
|
+
* `pack`'s `staged` row, for the keys a landing, an end or a drop of its receive left, due
|
|
16
|
+
* `receiveStepGrace` after `at`, and its files unless it `landed`. `at` is no earlier than any read
|
|
17
|
+
* of the receive's open quarantine by a step still running: a landing's or a drop's is its own
|
|
18
|
+
* try's, which another try's step read before, since its claim came after that try's lease, and
|
|
19
|
+
* `dropRefused`'s is its write's start or later, after its try's claim. Clean-up's is its own
|
|
20
|
+
* try's, after the commit that abandoned the quarantine, which no step read open past.
|
|
21
|
+
*/
|
|
22
|
+
const stagedRow = (pack, at, landed = false) => ({
|
|
23
|
+
...stagedKey(pack),
|
|
24
|
+
value: landed ? {
|
|
25
|
+
removeAt: at + receiveStepGrace,
|
|
26
|
+
landed
|
|
27
|
+
} : { removeAt: at + receiveStepGrace }
|
|
28
|
+
});
|
|
13
29
|
/** How many markers a fork puts at once. */
|
|
14
30
|
const sharing = 8;
|
|
15
31
|
/** A marker for `repo` that's there already is the one a share would put. */
|
|
@@ -106,22 +122,31 @@ const whileOpen = /* @__PURE__ */ Effect.fnUntraced(function* ({ store, repo, pa
|
|
|
106
122
|
}
|
|
107
123
|
});
|
|
108
124
|
/**
|
|
109
|
-
* After a receive or a merge failed, its kept indexes let go, then its marker
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
125
|
+
* After a receive or a merge failed, its kept indexes let go, then its marker and files deleted
|
|
126
|
+
* before its refusal is answered, marker first, as clean-up orders them, so a refused write keeps
|
|
127
|
+
* nothing. Its `quarantine` row then gives way to a `staged` row, with `git.repack` due when it is:
|
|
128
|
+
* a put the write's interrupt gave up on, on R2 whose binding takes no signal, can still land after
|
|
129
|
+
* these deletes, and clean-up deletes the pack's files and prefix again `receiveStepGrace` on
|
|
130
|
+
* (#2999). Its marker was put before any of them. A row clean-up abandoned meanwhile is clean-up's
|
|
131
|
+
* to end, as it puts its own `staged` row. A delete that fails, or other commits that keep moving
|
|
132
|
+
* the repo, leave the row for clean-up to end at its `removeAt`. Its own failure is dropped: the
|
|
133
|
+
* write's is the one its caller sees.
|
|
114
134
|
*/
|
|
115
135
|
const dropRefused = (input) => bestEffort(Effect.gen(function* () {
|
|
116
|
-
const { store, bucket, repo, pack } = input;
|
|
136
|
+
const { store, bucket, repo, pack, at } = input;
|
|
117
137
|
input.indexes.forget(pack);
|
|
118
138
|
const keys = [markerKey(pack, repo), ...packFileKeys(pack)];
|
|
119
139
|
yield* Effect.forEach(keys, (key) => bucketDo(bucket.remove(key)), { discard: true });
|
|
140
|
+
const staged = stagedRow(pack, at);
|
|
120
141
|
yield* whileOpen({
|
|
121
142
|
store,
|
|
122
143
|
repo,
|
|
123
144
|
pack
|
|
124
|
-
}, {
|
|
145
|
+
}, {
|
|
146
|
+
put: [staged],
|
|
147
|
+
delete: [quarantineKey(pack)],
|
|
148
|
+
jobs: [repackJobRow(staged.value.removeAt)]
|
|
149
|
+
});
|
|
125
150
|
}));
|
|
126
151
|
/**
|
|
127
152
|
* A push that ends with no commit that listed its pack commits its own `quarantine` row
|
|
@@ -139,4 +164,4 @@ const abandonOwn = ({ at, repackJobRow: repackAt, ...input }) => bestEffort(whil
|
|
|
139
164
|
})],
|
|
140
165
|
jobs: [repackAt(at)]
|
|
141
166
|
}));
|
|
142
|
-
export { abandonOwn, deletePackFiles, dropRefused, openQuarantine, putMarker, quarantineOf, quarantineState, sharePacks, stillOpen };
|
|
167
|
+
export { abandonOwn, deletePackFiles, dropRefused, openQuarantine, putMarker, quarantineOf, quarantineState, sharePacks, stagedRow, stillOpen };
|
|
@@ -109,7 +109,9 @@ const importTryTimeout = "13 minutes";
|
|
|
109
109
|
* `staged` row's wait, from the landing, the end or the drop that left them. A step puts them
|
|
110
110
|
* only inside an import's try, which the queue aborts at `importTryTimeout`, or a push upload's,
|
|
111
111
|
* which it aborts sooner, at `jobTryTimeout`, after its claim and its read of its quarantine, so
|
|
112
|
-
* it's bound by how long the longer of those tries' calls can run
|
|
112
|
+
* it's bound by how long the longer of those tries' calls can run. A refused merge's `staged` row
|
|
113
|
+
* waits from its try's start, and a refused push's from its drop, as its request has no try to
|
|
114
|
+
* end its puts, so each waits out the puts it gave up on too (#2999):
|
|
113
115
|
* - On Cloudflare, an alarm's `alarmWallTime`, 15 minutes from before the claim. R2's calls
|
|
114
116
|
* through its binding take no signal, so one started before the try's timeout runs on, but
|
|
115
117
|
* the alarm's end stops it.
|
|
@@ -7,8 +7,7 @@ import "./pack-receive.mjs";
|
|
|
7
7
|
import "./pack-reads.mjs";
|
|
8
8
|
import "./quarantine.mjs";
|
|
9
9
|
import "./layout.mjs";
|
|
10
|
-
import "
|
|
11
|
-
import { Key, Moment, Row } from "@ref0/infra";
|
|
10
|
+
import { Key, Moment } from "@ref0/infra";
|
|
12
11
|
import * as Schema from "effect/Schema";
|
|
13
12
|
import "effect/Effect";
|
|
14
13
|
/** One uploaded multipart receipt kept across staging tries, matching infra's `ListedPart`. */
|
|
@@ -12,12 +12,12 @@ import { putOnce } from "./index-build.mjs";
|
|
|
12
12
|
import { packPutOptions, startPut } from "./merge.mjs";
|
|
13
13
|
import { storeStep } from "./pack-receive.mjs";
|
|
14
14
|
import { pushUploadMost } from "./push-uploads.mjs";
|
|
15
|
-
import { deletePackFiles, dropRefused, openQuarantine, quarantineOf, quarantineState } from "./quarantine.mjs";
|
|
15
|
+
import { deletePackFiles, dropRefused, openQuarantine, quarantineOf, quarantineState, stagedRow } from "./quarantine.mjs";
|
|
16
16
|
import { putStepState, readStepState, stepStateKeys } from "./receive-state.mjs";
|
|
17
17
|
import { isPackId, markerPrefix, objectCollections, packFiles, receivePrefix } from "./layout.mjs";
|
|
18
18
|
import { fileBytesMost } from "./file-limits.mjs";
|
|
19
19
|
import { receiveCpuShare, receiveDropPage, receiveStepFloor, receiveStepGrace } from "./receive-bounds.mjs";
|
|
20
|
-
import { decodeHeld, quarantineKey
|
|
20
|
+
import { decodeHeld, quarantineKey } from "./rows.mjs";
|
|
21
21
|
import * as Schema from "effect/Schema";
|
|
22
22
|
import * as Effect from "effect/Effect";
|
|
23
23
|
import * as Predicate from "effect/Predicate";
|
|
@@ -91,20 +91,6 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
91
91
|
return "lost";
|
|
92
92
|
});
|
|
93
93
|
/**
|
|
94
|
-
* `pack`'s `staged` row, for the keys a landing, an end or a drop of its receive left, due
|
|
95
|
-
* `receiveStepGrace` after `at`, and its files unless it `landed`. `at` is no earlier than any read of the receive's open quarantine
|
|
96
|
-
* by a step still running: a landing's or a drop's is its own try's, which another try's step
|
|
97
|
-
* read before, since its claim came after that try's lease. Clean-up's is its own try's, after the
|
|
98
|
-
* commit that abandoned the quarantine, which no step read open past.
|
|
99
|
-
*/
|
|
100
|
-
const stagedRow = (pack, at, landed = false) => ({
|
|
101
|
-
...stagedKey(pack),
|
|
102
|
-
value: landed ? {
|
|
103
|
-
removeAt: at + receiveStepGrace,
|
|
104
|
-
landed
|
|
105
|
-
} : { removeAt: at + receiveStepGrace }
|
|
106
|
-
});
|
|
107
|
-
/**
|
|
108
94
|
* Every key under `pack`'s prefix but its markers, a page at a time, each page's through one
|
|
109
95
|
* `bucketDeleteMany`, so its calls are charged as its batches are: its runs, its answer and its
|
|
110
96
|
* steps' keys.
|
|
@@ -358,7 +344,8 @@ const stageReceiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
358
344
|
bucket,
|
|
359
345
|
indexes: input.indexes,
|
|
360
346
|
repo,
|
|
361
|
-
pack
|
|
347
|
+
pack,
|
|
348
|
+
at: input.at
|
|
362
349
|
});
|
|
363
350
|
return yield* failed;
|
|
364
351
|
});
|
|
@@ -390,7 +377,8 @@ const stageReceiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
390
377
|
bucket,
|
|
391
378
|
indexes: input.indexes,
|
|
392
379
|
repo,
|
|
393
|
-
pack
|
|
380
|
+
pack,
|
|
381
|
+
at: input.at
|
|
394
382
|
});
|
|
395
383
|
return yield* stageGone(`A staged pack's multipart upload is gone at ${packKey}`);
|
|
396
384
|
});
|
|
@@ -460,7 +448,8 @@ const stageReceiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
460
448
|
bucket,
|
|
461
449
|
indexes: input.indexes,
|
|
462
450
|
repo,
|
|
463
|
-
pack
|
|
451
|
+
pack,
|
|
452
|
+
at: input.at
|
|
464
453
|
}) : Effect.void));
|
|
465
454
|
const answer = {
|
|
466
455
|
...input.answer,
|
|
@@ -699,4 +688,4 @@ const receiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
699
688
|
yield* bestEffort(bucketDeleteMany(bucket, Object.values(keys)));
|
|
700
689
|
return ended;
|
|
701
690
|
});
|
|
702
|
-
export { ReceiveAnswer, ReceiveRow, StagePart, StageProgress, answerKey, commitStep, deleteStaged, dropReceive, newAttempt, openStageReceive, putAnswer, readAnswer, readReceive, receiveKey, receiveStep, stageReceive, stageReceiveStep, stageStepKey, stageStepOf,
|
|
691
|
+
export { ReceiveAnswer, ReceiveRow, StagePart, StageProgress, answerKey, commitStep, deleteStaged, dropReceive, newAttempt, openStageReceive, putAnswer, readAnswer, readReceive, receiveKey, receiveStep, stageReceive, stageReceiveStep, stageStepKey, stageStepOf, stepEntryMostOf, stepInflatedMostOf, stepShareOf, streamStepsMost };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ref0/git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Git hosting as a library: a server, a client and their merges",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@ref0/infra": "0.
|
|
54
|
+
"@ref0/infra": "0.31.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@effect/vitest": "4.1.7",
|
|
58
|
-
"@ref0/xdiff-wasm": "0.
|
|
58
|
+
"@ref0/xdiff-wasm": "0.31.0",
|
|
59
59
|
"effect": "4.1.7",
|
|
60
60
|
"vite-plus": "1.8.0",
|
|
61
61
|
"vitest": "5.1.1",
|