Commit 3246f380 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Better handling of storage operations where OCC is not required.

parent df53dd5d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@ All notable changes to this project are documented below.
The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org).

## [Unreleased]
### Added
- More informational logging when groups are created, updated, or deleted.

### Changed
- Use the Facebook Graph API v11.0 version.
- Move Facebook email import timing after account creation.
@@ -12,6 +15,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Improve tournament lookup behaviour.
- Improve email import semantics when linking social accounts.
- Log IAP provider API response payload when non 200 status code is returned.
- Better handling of storage operations where OCC is not required.

### Fixed
- Fix log level in Lua runtime log calls which use logger fields.
+7 −0
Original line number Diff line number Diff line
@@ -158,6 +158,8 @@ RETURNING id, creator_id, name, description, avatar_url, state, edge_count, lang
		return nil, err
	}

	logger.Info("Group created.", zap.String("group_id", group.Id), zap.String("user_id", userID.String()))

	return group, nil
}

@@ -262,6 +264,9 @@ func UpdateGroup(ctx context.Context, logger *zap.Logger, db *sql.DB, groupID uu
	if rowsAffected == 0 {
		return ErrGroupNotUpdated
	}

	logger.Info("Group updated.", zap.String("group_id", groupID.String()), zap.String("user_id", userID.String()))

	return nil
}

@@ -292,6 +297,8 @@ func DeleteGroup(ctx context.Context, logger *zap.Logger, db *sql.DB, groupID uu
		return err
	}

	logger.Info("Group deleted.", zap.String("group_id", groupID.String()), zap.String("user_id", userID.String()))

	return nil
}

+7 −0
Original line number Diff line number Diff line
@@ -573,6 +573,13 @@ func storageWriteObject(ctx context.Context, logger *zap.Logger, tx *sql.Tx, aut
		if !authoritativeWrite {
			query += " AND write = 1"
		}
	case dbVersion.Valid && object.Version == "":
		// An existing storage object was present, but no OCC of any kind is specified.
		query = "UPDATE storage SET value = $4, version = $5, read = $6, write = $7, update_time = now() WHERE collection = $1 AND key = $2 AND user_id = $3::UUID"
		// Respect permissions in non-authoritative writes.
		if !authoritativeWrite {
			query += " AND write = 1"
		}
	case dbVersion.Valid && object.Version != "*":
		// An existing storage object was present, but no OCC if-not-exists required.
		query = "UPDATE storage SET value = $4, version = $5, read = $6, write = $7, update_time = now() WHERE collection = $1 AND key = $2 AND user_id = $3::UUID AND version = $8"