fix site replication resync status (#18245)

To persist status changes on disk upon completion.

Adds new tests to handle this functionality.
This commit is contained in:
Poorna 2023-10-13 22:17:22 -07:00 committed by GitHub
parent e1e33077e8
commit 78f1f69d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 6 deletions

View File

@ -198,9 +198,9 @@ func (sm *siteResyncMetrics) save(ctx context.Context) {
}
// update overall site resync state
func (sm *siteResyncMetrics) updateState(s SiteResyncStatus) {
func (sm *siteResyncMetrics) updateState(s SiteResyncStatus) error {
if !globalSiteReplicationSys.isEnabled() {
return
return nil
}
sm.Lock()
defer sm.Unlock()
@ -213,9 +213,12 @@ func (sm *siteResyncMetrics) updateState(s SiteResyncStatus) {
if ok {
st.LastUpdate = s.LastUpdate
st.Status = s.Status
return nil
}
sm.resyncStatus[s.ResyncID] = st
return saveSiteResyncMetadata(GlobalContext, st, newObjectLayerFn())
}
return nil
}
// increment SyncedBuckets count

View File

@ -5157,8 +5157,7 @@ func (c *SiteReplicationSys) startResync(ctx context.Context, objAPI ObjectLayer
}
}()
globalSiteResyncMetrics.updateState(rs)
if err := saveSiteResyncMetadata(ctx, rs, objAPI); err != nil {
if err := globalSiteResyncMetrics.updateState(rs); err != nil {
return res, err
}
@ -5408,6 +5407,9 @@ func loadSiteResyncMetadata(ctx context.Context, objAPI ObjectLayer, dID string)
// save resync status of peer to resync/depl-id.meta
func saveSiteResyncMetadata(ctx context.Context, ss SiteResyncStatus, objectAPI ObjectLayer) error {
if objectAPI == nil {
return errSRObjectLayerNotReady
}
data := make([]byte, 4, ss.Msgsize()+4)
// Initialize the resync meta header.

View File

@ -247,7 +247,7 @@ if [ $? -ne 0 ]; then
echo "expecting object to be present. exiting.."
exit_1
fi
./mc tag set --version-id "${vID}" minio2/newbucket/README.md "k=v"
./mc tag set --version-id "${vID}" minio2/newbucket/README.md "key=val"
if [ $? -ne 0 ]; then
echo "expecting tag set to be successful. exiting.."
exit_1
@ -353,4 +353,21 @@ if [ $? -ne 0 ]; then
exit_1
fi
# force a resync after removing all site replication
./mc admin replicate rm --all --force minio1
./mc rb minio2 --force --dangerous
./mc admin replicate add minio1 minio2
./mc admin replicate resync start minio1 minio2
sleep 30
./mc ls -r --versions minio1/newbucket >/tmp/minio1.txt
./mc ls -r --versions minio2/newbucket >/tmp/minio2.txt
out=$(diff -qpruN /tmp/minio1.txt /tmp/minio2.txt)
ret=$?
if [ $ret -ne 0 ]; then
echo "BUG: expected no missing entries after replication resync: $out"
exit 1
fi
cleanup

View File

@ -234,7 +234,7 @@ if [ $? -ne 0 ]; then
echo "expecting object to be present. exiting.."
exit_1
fi
./mc tag set --version-id "${vID}" minio2/newbucket/README.md "k=v"
./mc tag set --version-id "${vID}" minio2/newbucket/README.md "key=val"
if [ $? -ne 0 ]; then
echo "expecting tag set to be successful. exiting.."
exit_1
@ -370,3 +370,20 @@ if [ $? -ne 0 ]; then
echo "expected 'bucket2' delete and 'newbucket2' creation to have replicated, exiting..."
exit_1
fi
# force a resync after removing all site replication
./mc admin replicate rm --all --force minio1
./mc rb minio2 --force --dangerous
./mc admin replicate add minio1 minio2
./mc admin replicate resync start minio1 minio2
sleep 30
./mc ls -r --versions minio1/newbucket >/tmp/minio1.txt
./mc ls -r --versions minio2/newbucket >/tmp/minio2.txt
out=$(diff -qpruN /tmp/minio1.txt /tmp/minio2.txt)
ret=$?
if [ $ret -ne 0 ]; then
echo "BUG: expected no missing entries after replication resync: $out"
exit 1
fi

View File

@ -293,3 +293,20 @@ if [ $? -ne 0 ]; then
echo "expected 'bucket2' delete and 'newbucket2' creation to have replicated, exiting..."
exit_1
fi
# force a resync after removing all site replication
./mc admin replicate rm --all --force minio1
./mc rb minio2 --force --dangerous
./mc admin replicate add minio1 minio2
./mc admin replicate resync start minio1 minio2
sleep 30
./mc ls -r --versions minio1/newbucket >/tmp/minio1.txt
./mc ls -r --versions minio2/newbucket >/tmp/minio2.txt
out=$(diff -qpruN /tmp/minio1.txt /tmp/minio2.txt)
ret=$?
if [ $ret -ne 0 ]; then
echo "BUG: expected no missing entries after replication resync: $out"
exit 1
fi