5 ms·
db.commit() # Give Mycelite time to sync before script exits import time time.sleep(5) This really needs a way to wait for the sync to complet
by 8organicbits 3y ago
db.commit()
# Give Mycelite time to sync before script exits
import time
time.sleep(5)
This really needs a way to wait for the sync to complete. Sleep won't cut it.
- chaxor 3y agoOof
- gnulinux 3y agoFingers crossed there is no network issue. `time.sleep(5)` is ridiculous.
- peteradio 3y agoThen just time.sleep(10) bro, it aint rocket science.
- tarruda 3y agoI would use time.sleep(60) just in case.
- peteradio 3y agotime.sleep(300) allows for a smoke break per sync, please consider my PR
- edvinbesic 3y agoThat depends on what you're smoking, let's just be safe: time.sleep(3600)
- intelVISA 3y agoEntire field of distributed systems solved by this one trick!
- deleted 3y ago[deleted]
- baliex 3y agoRelevant HN post from _yesterday_, https://news.ycombinator.com/item?id=36465085 https://news.ycombinator.com/item?id=36465085
- hahn-kev 3y agoI see so this is a PoC hobby project and nothing to actually use. Thanks for the warning.
- sim7c00 3y agowhere did u find this python stuff.. Languages Rust 100.0% did the link change??
- Hamuko 3y agohttps://mycelial.com/docs/get-started/python#observing-synchronization https://mycelial.com/docs/get-started/python#observing-synch...
- dangoodmanUT 3y agoLink?
- paulgb 3y agohttps://mycelial.com/docs/get-started/python/#observing-synchronization https://mycelial.com/docs/get-started/python/#observing-sync...
- eli 3y agoThat’s just the example client code, not the sync code. It’s showing you how to demo that the sync works. You’re not expected to use that in production. https://mycelial.com/docs/get-started/python#observing-synchronization https://mycelial.com/docs/get-started/python#observing-synch...
- Hamuko 3y agoWhat's the code that you're supposed to use in production to wait for sync then?
- d_watt 3y agoI mean to be fair, even in using something like Postgres logical replication, there's no way to verify whether a particular change has replicated (minus xmin hackery). If I were to write a tutorial on how to set up PG replication and "observe the replication", I think that would probably involve "write to master, sleep for a bit, then see the data is in the secondary."
- bhouston 3y agoCouldn't you just query the replication log positions on the primary and standbys and calculate their delta? I asked this to ChatGPT 4 and it suggested something like this that seems reasonable: Get it from the main server: SELECT * FROM pg_stat_replication, and the write_ls column has the log transaction location; Then get the location of the replication log and how much has been received: SELECT pg_last_wal_receive_lsn(); Then you can figure out the delta from any of these: SELECT pg_wal_lsn_diff(write_ls, pg_last_wal_receive_lsn()); or similar. That seems like it isn't a hack.
- 8organicbits 3y agoThe problem is that Postgres is a long lived server so the app can fire a commit to the DB and then exit. Here, the app needs to perform the sync, so you can't exit. I didn't see a way to confirm the sync was complete either, so when can you safely exit?
- 3y ago
- RATML 3y agoThose silly Internet Protocol guys thought we'd use UDP multicast for such things. That was before everybody knew that "cluster" was just a code word for 5 VMS 1-2 core instances scattered between continents, laptops, and cloud providers.