sliftutils 1.7.27 → 1.7.28
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/index.d.ts +0 -1
- package/package.json +1 -1
- package/storage/IArchives.d.ts +0 -1
- package/storage/IArchives.ts +4 -6
- package/storage/dist/IArchives.ts.cache +6 -7
- package/storage/remoteStorage/createArchives.ts +5 -2
- package/storage/remoteStorage/dist/blobStore.ts.cache +162 -29
- package/storage/remoteStorage/dist/createArchives.ts.cache +25 -8
- package/storage/remoteStorage/dist/deployTakeover.ts.cache +17 -3
- package/storage/remoteStorage/dist/sourceWrapper.ts.cache +12 -2
- package/storage/remoteStorage/dist/storageServerState.ts.cache +149 -46
- package/storage/remoteStorage/spec.md +10 -4
- package/storage/remoteStorage/storageServerState.ts +3 -3
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
This is the reasoning behind the remote storage system (createArchives / storageServer / BlobStore). The code documents the mechanics; this documents the ideas that must survive refactors.
|
|
4
4
|
|
|
5
|
-
## Configuration updates happen only on startup
|
|
6
|
-
|
|
7
|
-
A client adopts a routing config once, during initialization, and then runs on it. Configs never automatically upgrade mid-run: the 5-minute poll picks up whatever the sources currently hold (so a developer's change spreads), but the version-gated *upgrade* — writing a newer configured version over an older stored one — happens only at startup. This is deliberate: config changes are made by a developer running code, and that developer is present at startup. It also prevents reversion loops — if a server briefly held a newer version and then went away, running clients don't cling to that phantom version; they follow what the surviving sources actually hold, and only a fresh startup with an explicitly newer configured version moves things forward again.
|
|
8
|
-
|
|
9
5
|
## Scanning + tombstones + versions make any two sources mergeable
|
|
10
6
|
|
|
11
7
|
Every store fully rescans its sources' metadata (on startup and periodically), and every write — including deletions — is ordered by last-write time. Deletions are tombstones: an empty file IS a missing file, kept as a size-0 index entry (for a week) so the deletion itself propagates and reconciles like any other write. Because everything is a timestamped write and scans are bidirectional (pull what they have, push what they're missing), any two sources can be merged in any order and converge to the same state: newest write time wins, per file. There is no operation whose loss corrupts the system — a failed background write, a missed delete, a source that was down for a day — the next scan reconciles it.
|
|
@@ -16,6 +12,16 @@ Each bucket stores its complete routing config (the full redundancy list) inside
|
|
|
16
12
|
|
|
17
13
|
If the client tries to do a write where the valid state is far enough away or the sharding is wrong, it will re-download the routing config throttled, so it only does this at most once every 30 seconds, and retry the request.
|
|
18
14
|
|
|
15
|
+
Storage routing JSON is only written to if we have write access and it's only written to on startup, it doesn't propagate. that way things don't revert without the developer intentionally rerunning it.
|
|
16
|
+
|
|
17
|
+
## Redundancy, sharding, and deployment
|
|
18
|
+
|
|
19
|
+
For redundancy, we can just have multiple different configurations that will satisfy the same request. The first one is the one that we write to. If that one's down, we don't do writes.
|
|
20
|
+
|
|
21
|
+
However, there's also sharding, where we have different route ranges that values can hash to. Values can explicitly try to write to a specific value via a special like hash override key. This allows us to sometimes make our rights hit a server which has less latency. In the case that the client writer will accept the fact that we might change the key.
|
|
22
|
+
|
|
23
|
+
The valid windows allow us to schedule deployments, so the nodes can switch over gracefully.
|
|
24
|
+
|
|
19
25
|
## BulkDatabase2 index + our own disk as just another source
|
|
20
26
|
|
|
21
27
|
Each bucket's store keeps a BulkDatabase2 index of every file (path, write time, size, holding source), served from memory — existence checks and listings are extremely fast, never touching a source. The trick that keeps the index accurate: our own disk is not special-cased, it is simply the first synchronization source. The same scan/reconcile code that synchronizes remote sources also synchronizes the disk with the index, so the index self-heals from the same machinery instead of needing separate consistency logic.
|
|
@@ -8,7 +8,7 @@ import { BlobStore, IBucketStore, DEFAULT_FAST_WRITE_DELAY, WINDOW_END_FLUSH_MAR
|
|
|
8
8
|
import {
|
|
9
9
|
RemoteConfig, HostedConfig, BackblazeConfig, IArchives, ArchivesSource, ArchiveFileInfo, ArchivesConfig,
|
|
10
10
|
ArchivesSyncStatus,
|
|
11
|
-
|
|
11
|
+
STORAGE_WRONG_VALID_WINDOW, STORAGE_WRONG_ROUTE, FULL_ROUTE,
|
|
12
12
|
} from "../IArchives";
|
|
13
13
|
import { ROUTING_FILE, parseRoutingData, parseHostedUrl, buildFileUrl, getConfigVersion, getRoute, routeContains, routeIntersection } from "./remoteConfig";
|
|
14
14
|
import { applyDeployRemap, getTakeoverAltPort, getOwnWindowEndClip, onTakeoverEvent } from "./deployTakeover";
|
|
@@ -696,9 +696,9 @@ export async function writeBucketFile(account: string, bucketName: string, fileP
|
|
|
696
696
|
// target from a stale view - it must re-resolve and retry at the correct source.
|
|
697
697
|
let route = getRoute(filePath);
|
|
698
698
|
if (!config?.lastModified && loaded.selfEntries.length) {
|
|
699
|
-
let timeValid = loaded.selfEntries.filter(x => writeTime >= x.validWindow[0]
|
|
699
|
+
let timeValid = loaded.selfEntries.filter(x => writeTime >= x.validWindow[0] && writeTime < x.validWindow[1]);
|
|
700
700
|
if (!timeValid.length) {
|
|
701
|
-
logWrongTargetRejection(`Rejecting fresh write of ${JSON.stringify(filePath)} to bucket ${account}/${bucketName}: writeTime ${writeTime} (${new Date(writeTime).toISOString()}) is outside all our valid windows ${JSON.stringify(loaded.selfEntries.map(x => x.validWindow))}
|
|
701
|
+
logWrongTargetRejection(`Rejecting fresh write of ${JSON.stringify(filePath)} to bucket ${account}/${bucketName}: writeTime ${writeTime} (${new Date(writeTime).toISOString()}) is outside all our valid windows ${JSON.stringify(loaded.selfEntries.map(x => x.validWindow))} (a switchover moved the write target)`);
|
|
702
702
|
throw new Error(`${STORAGE_WRONG_VALID_WINDOW} This server is not a valid write target at ${writeTime} for bucket ${account}/${bucketName} (our valid windows: ${JSON.stringify(loaded.selfEntries.map(x => x.validWindow))}). Re-resolve the currently valid source and retry.`);
|
|
703
703
|
}
|
|
704
704
|
if (!timeValid.some(x => routeContains(x.route, route))) {
|