You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
%% some other write makes the file roll over and delete everything from the cache NOPE NOT EVERYTHING IT DOESN'T DELETE IF ENTRY WASN'T WRITTEN YET (or ignored)
517
-
%% read from cache: entry not there
518
-
%% read from index: {write,...} not processed yet
519
-
%% crash NOPE!!! SEE ABOVE
520
-
521
-
%% So the not_found is impossible unless there's a bug.
522
-
523
-
%% what we want: the cache shouldn't be completely wiped, only the entries that don't match the current file
524
-
%% maybe use a timestamp to allow us to only remove what was fully written and set that timestamp in both cache entry and {write,...} but I don't think that is good enough
525
-
%% nope. OK what else can be used. We can track what messages were truly written and only remove those from the cache?
526
-
%% but doing that in the main process could be slow, maybe do that in the GC process?
%% @todo I think we don't need the flying table as long as we use the value from the cache instead.
899
-
%% We only need to write the message if it wasn't already written in the current file (keep keys?)
900
-
%% and the cache is > 0. We should NOT worry about messages in previous files (?) well we should
901
-
%% because the index can only have a single value so writing to another file doesn't work.
902
-
%% Can we just update_counter the index and if it doesn't exist then write?
903
-
%%
904
-
%% client: - write to ets cache OR increase refc if already exists (which one takes priority? write if not fan-out, refc if fan-out, but can't know yet so write)
905
-
%% - send {write...}
906
-
%% DON'T update_flying anymore! The refc is doing it for us
907
-
%% how does the refc work? we probably should +2 the refc on client_write because it will be decreased by both client ack and write?
908
-
%%
909
-
%% server: - -1 the cache; if result is 0 then we don't need to write (it was already acked)
910
-
%% HMMM but we can't figure things out like this if there's fan-out
911
-
%% so if fan-out we just increase/decrease the index (assuming non-zero) like we do before,
912
-
%% we will just not have the flying optimisation in that case?
913
-
%%
914
-
%%
915
-
%% remove: how do we know it was not written? we just read from the cache and if value is 0... Nope
916
-
%% we want to just -1 client-side and only tell the message store the message is gone if the value is 0 ideally or if the value isn't in the cache (of course)
917
-
%%
918
-
%%
919
-
%% when should values be removed from the cache in that case? when the file rolls over I guess? I guess that's why flying and refc are separate
920
-
921
-
922
-
923
-
924
-
%% we write to cache everytime we do a {write,...}
925
-
%% we want to avoid writing to disk if not necessary
926
-
927
-
%% write: to cache with +1 refc and +1 pending_write
928
-
%% {write,...}: +0 refc -1 pending_write
929
-
%% if refc == 0 -> don't write
930
-
%% do we need to track pending_write at all?
931
-
%% what about confirms? maybe never try to do them early?
%% Check if MsgId is in there. Hmm no we can't assume we process in that case...
1168
-
%% OK we NEVER remove the entry before we look in the case of write. So for write we will always have MsgId in there if it has 0.
1169
-
%% So if MsgId is in there we delete the objects and we ignore.
1170
-
%% But we can't delete the objects randomly since the counter may get updated we have to delete the objects we found explicitly (and only if they still say 0).
1171
-
%% OK but how do we avoid sending confirms multiple times then? The write message is coming anyway...
1172
-
%% Hmmm....
1173
-
%% We need to get rid of gen_server2? Probably too hard right now.
1174
-
%% We could keep track of which MsgIds were already processed and ignore the message in that case.
1175
-
%% Or since we delete_object we could just update_flying like before? But if the message was
1176
-
%% already processed we will ignore it and we don't want to send a confirm again... Tough.
1177
-
%% (ignore) But we can do the ets:lookup and then if it's an ignore we match for the other ones?
1178
-
%% (ignore) But we'll have MORE ets operations in that case because we still have incoming write/remove...
0 commit comments