prologic revised this gist . Go to revision
1 file changed, 97 insertions
what-breaks.md(file created)
@@ -0,0 +1,97 @@ | |||
1 | + | The following is a non-exhaustive list of things that break if we change the ways Twts are identified to be "location addressed": | |
2 | + | ||
3 | + | 1. Archinving breaks | |
4 | + | ||
5 | + | ``` | |
6 | + | ERRO[0076] error computing archive file for twt error="error: invalid twt hash" | |
7 | + | ``` | |
8 | + | ||
9 | + | Fixing this with the patch: | |
10 | + | ||
11 | + | ```patch | |
12 | + | diff --git a/internal/archive.go b/internal/archive.go | |
13 | + | index 9f8448c6..d7aaab5d 100644 | |
14 | + | --- a/internal/archive.go | |
15 | + | +++ b/internal/archive.go | |
16 | + | @@ -25,7 +25,6 @@ const ArchiveDir = "archive" | |
17 | + | var ( | |
18 | + | ErrTwtAlreadyArchived = errors.New("error: twt already archived") | |
19 | + | ErrTwtNotArchived = errors.New("error: twt not found in archived") | |
20 | + | - ErrInvalidTwtHash = errors.New("error: invalid twt hash") | |
21 | + | ) | |
22 | + | ||
23 | + | func ReadArchivedTwt(p string) (types.Twt, error) { | |
24 | + | @@ -121,10 +120,6 @@ func (a *DiskArchiver) makePath(hash string) (string, error) { | |
25 | + | return "", err | |
26 | + | } | |
27 | + | ||
28 | + | - if len(bs) < 2 { | |
29 | + | - return "", ErrInvalidTwtHash | |
30 | + | - } | |
31 | + | - | |
32 | + | // Produces a path structure of: | |
33 | + | // ./data/archive/[0-9a-f]{2,}/[0-9a-f]+.json | |
34 | + | components := []string{a.path, fmt.Sprintf("%x", bs[0:1]), fmt.Sprintf("%x.json", bs[1:])} | |
35 | + | diff --git a/internal/utils.go b/internal/utils.go | |
36 | + | index f09c59f4..de86166e 100644 | |
37 | + | --- a/internal/utils.go | |
38 | + | +++ b/internal/utils.go | |
39 | + | @@ -134,8 +134,7 @@ func GenerateRandomToken() string { | |
40 | + | } | |
41 | + | ||
42 | + | func DecodeHash(hash string) ([]byte, error) { | |
43 | + | - encoding := base32.StdEncoding.WithPadding(base32.NoPadding) | |
44 | + | - return encoding.DecodeString(strings.ToUpper(hash)) | |
45 | + | + return []byte(hash), nil | |
46 | + | } | |
47 | + | ||
48 | + | func FastHash(data []byte) string { | |
49 | + | ``` | |
50 | + | ||
51 | + | Results in the following Go panic (_crash_): | |
52 | + | ||
53 | + | ```console | |
54 | + | INFO[0008] converging cache with 1 potential peers | |
55 | + | panic: runtime error: slice bounds out of range [:1] with capacity 0 | |
56 | + | ||
57 | + | goroutine 134 [running]: | |
58 | + | git.mills.io/yarnsocial/yarn/internal.(*DiskArchiver).makePath(0x14000132e70, {0x0?, 0xffffffffffffffff?}) | |
59 | + | /Users/prologic/Projects/yarnsocial/yarn/internal/archive.go:125 +0x158 | |
60 | + | git.mills.io/yarnsocial/yarn/internal.(*DiskArchiver).Has(0x103aedf20?, {0x0, 0x0}) | |
61 | + | /Users/prologic/Projects/yarnsocial/yarn/internal/archive.go:152 +0x24 | |
62 | + | git.mills.io/yarnsocial/yarn/internal.(*Cache).Converge(0x1400060e150, {0x103c37ff0, 0x14000132e70}) | |
63 | + | /Users/prologic/Projects/yarnsocial/yarn/internal/cache.go:1418 +0x1ac | |
64 | + | git.mills.io/yarnsocial/yarn/internal.(*UpdateFeedsJob).Run(0x14001001340) | |
65 | + | /Users/prologic/Projects/yarnsocial/yarn/internal/jobs.go:167 +0x6c8 | |
66 | + | git.mills.io/yarnsocial/yarn/internal.(*Server).runStartupJobs(0x140003e2180) | |
67 | + | /Users/prologic/Projects/yarnsocial/yarn/internal/server.go:723 +0x1cc | |
68 | + | created by git.mills.io/yarnsocial/yarn/internal.NewServer in goroutine 1 | |
69 | + | /Users/prologic/Projects/yarnsocial/yarn/internal/server.go:1257 +0x2e34 | |
70 | + | ``` | |
71 | + | ||
72 | + | So fixing this assumption that Twts are valid hashes alone isn't as easy | |
73 | + | as one might think... | |
74 | + | ||
75 | + | Trying to debug this is going to be a bit tricky: | |
76 | + | ||
77 | + | For some reason the identity of Twts are now empty: | |
78 | + | ||
79 | + | ``` | |
80 | + | DEBU[0024] hash: | |
81 | + | DEBU[0024] bs: | |
82 | + | ``` | |
83 | + | ||
84 | + | And even starting with a fresh instance results in broken template logic: | |
85 | + | ||
86 | + | ``` | |
87 | + | ERRO[0024] error executing template error="template: timeline:217:12: executing \"twt\" at <urlForRootConv $.Twt $.User>: error calling urlForRootConv: runtime error: slice bounds out of range [:1] with capacity 0" name=timeline | |
88 | + | ERRO[0024] error executing template error="error executing template timeline: template: timeline:217:12: executing \"twt\" at <urlForRootConv $.Twt $.User>: error calling urlForRootConv: runtime error: slice bounds out of range [:1] with capacity 0" | |
89 | + | ``` | |
90 | + | ||
91 | + | At this point I can't quite figure out why Twt identiies (_were hases_) are coming | |
92 | + | through as null. Hmmm So, going to continue on for a bit with `--disable-archive` | |
93 | + | because that's what's failing right now... | |
94 | + | ||
95 | + | 2. The threading model is as expected now completely broken... | |
96 | + | ||
97 | + | This _may_ take a while to figure out why :/ |
Newer
Older