Dbserver

From OuroDev
Revision as of 11:58, 4 May 2019 by Asuffield (talk | contribs)

A dbserver instance is a "shard", which is known to players as "a server" (Freedom, Defiant, etc). It performs several roles:

  • storing and retrieving objects in the database on behalf of some of the other servers
  • proxying messages between some other servers
  • coordinating player transfers
  • assorted random features that didn't have anywhere else to live

Despite the name, relatively little of dbserver's code is related to managing the database, and it is not the only server which has a database.

Services

dbserver listens on several ports, each one providing a different service. Most services correspond to another server which will connect. All of these services use the common Network protocol, in TCP-only mode.

account

arena

auction

AuctionServer connects to this service. It can receive the following commands:

AUCTION_SVR_CONNECT (2)

The message has no parameters. dbserver will accept only a single connection, and while it has one, it will respond to all further AUCTION_SVR_CONNECT messages by closing the connection.

dbserver responds with AUCTION_CLIENT_CONNECT (2):

packint(1) protocol_version
string shard_name
bits(1) have_inactive_players
something....

AUCTION_SVR_SEND_INV (3)

autobits entity_id
string inventory

dbserver finds the mapserver for entity_id, and proxies the message there as DBSERVER_AUCTION_SEND_INV

inventory is eventually decoded by AuctionInventory_FromStr in the mapserver, but dbserver proxies it without inspecting its value.

AUCTION_SVR_SEND_HISTORYINFO (4)

autobits entity_id
string identifier
autobits buying_count
autobits selling_count
autobits history_count
repeated history_count times:
  autobits date
  autobits price

dbserver finds the mapserver for entity_id, and proxies the message there as DBSERVER_AUCTION_SEND_HIST.

AUCTION_SVR_BATCH_SEND_ITEMINFO (5)

autobits entity_id
zipped data

dbserver finds the mapserver for entity_id, and proxies the message there as DBSERVER_AUCTION_BATCH_INFO. The zipped data is not inspected by dbserver.

After this output packet has been queued, dbserver sends AUCTION_CLIENT_DATAOK to the AuctioServer, with no both. This is a primitive form of flow control. It does not wait for the message to be sent to the mapserver before doing this.

AUCTION_SVR_XACT_CMD (7)

autobits entity_id
autobits type
XactCmd cmd

dbserver finds the mapserver for entity_id. If there is one, it proxies the message there as DBSERVER_AUCTION_XACT_CMD. If there is no mapserver, then dbserver responds to AuctionServer with AUCTION_CLIENT_XACT_UPDATE, sending:

autobits xid
autobits subid
autobits result

Where *xid* and *subid* are taken from *cmd*, and the result is set to *kXactCmdRes_No*.

AUCTION_SVR_RELAY_CMD_BYENT (9)

packint(1) entity_id
packint(1) force
string msg

dbserver finds the mapserver for entity_id. If there is one, it sends DBSERVER_RELAY_CMD there with *msg* as the body. If there is no mapserver, and force is set to 1, then the message is queued for relaying when the entity is available, and dbserver begins attempting to load the entity into a mapserver.

AUCTION_SVR_THROTTLE_ON (10)

This message has no parameters, and dbserver sends no response. It enables throttling, which prevents some (???) messages from being sent to the AuctionServer.

AUCTION_SVR_THROTTLE_OFF (11)

This message has no parameters, and dbserver sends no response. It disables throttling.

AUCTION_SVR_ACCOUNT_SHARDXFER (12)

OrderId order_id
autobits dbid

dbid is interpreted as an entity_id. dbserver will offline (???) and delete (???) the player, and then send AccountServer an ACCOUNT_CLIENT_SHARDXFER with:

OrderId order_id
autobits SHARDXFER_FULFILL_COMMIT_SRC

beacon

client

This service is used for the game client to communicate with dbserver.

db

Despite the name, this service is used to communicate with MapServer.

Every NetLink for the db server has a unique lock_id, starting from 0. They are used to identify current connections to MapServer in order to send messages.

DBCLIENT_INITIAL_CONNECT

optional packint(1) map_protocol

If map_protocol is not present (the body is empty), it is 0. If map_protocol is not equal to DBSERVER_PROTOCOL_VERSION (currently 20110503) then dbserver will respond with DBSERVER_CLIENT_CMD_FAILED and close the NetLink.

Otherwise, dbserver sends these commands back to the MapServer:

DBSERVER_TIMEOFFSET:

bits(32) seconds_since_2000
float32 time_zone_delta

These values are set based on the system clock. time_zone_delta is the difference between UTC and local time, in hours.

DBSERVER_OVERRIDDEN_AUTHBITS

bits(128) overridden_auth_bits

The value of overridden_auth_bits is set based on OverrideAuthBit lines in servers.cfg.

If any DisabledZoneEvents entries are present in servers.cfg, dbserver sends a DBSERVER_DISABLED_ZONE_EVENTS command:

repeated string event

One entry for each DisabledZoneEvents line in servers.cfg

If user reactivation is active, dbserver sends a DBSERVER_NOTIFY_REACTIVATION message, with no body.

DBSERVER_UPDATE_LOG_LEVELS:

repeated LOG_LEVELS times:
  packint(1) log_level

These are the log levels, as managed by log.h, for all logging types in order from 0 to LOG_LEVELS. They are set in servers.cfg with SetLogLevel lines.

DBSERVER_ACCOUNTSERVER_CATALOG:

autobits catalog_timestamp
autobits auth_timeout
string mtx_environment
string play_span_domain
string play_spam_url_home
string play_spam_url_categoryview
string play_spam_url_itemview
string play_spam_url_showcart
string play_spam_url_addtocart
string play_spam_url_manageaccount
string play_spam_url_supportpage
string play_spam_url_supportpage_de
string play_spam_url_supportpage_fr
string play_spam_url_updatetovip
string coh_url_newfeatures
string coh_url_newfeaturesupdate
autobits play_span_store_flags

These appear to be values set in account_server.cfg. Most of them are URLs.

DBCLIENT_READY

DBCLIENT_REGISTER

DBCLIENT_REGISTER_CONTAINER_SERVER

DBCLIENT_REGISTER_CONTAINER_SERVER_NOTIFY

DBCLIENT_READY_FOR_PLAYERS

DBCLIENT_CONTAINER_INFO

DBCLIENT_REQ_CONTAINERS

DBCLIENT_SET_CONTAINERS

DBCLIENT_CONTAINER_RELAY

DBCLIENT_CONTAINER_RECEIPT

DBCLIENT_CONTAINER_REFLECT

DBCLIENT_REQ_CONTAINER_STATUS

DBCLIENT_REQUEST_MAP_XFER

DBCLIENT_MAP_XFER

DBCLIENT_CONTAINER_ACK

DBCLIENT_TEST_MAP_XFER

DBCLIENT_SEND_DOORS

DBCLIENT_SAVELISTS

DBCLIENT_ADDDEL_MEMBERS

DBCLIENT_PLAYER_DISCONNECT

DBCLIENT_SEND_MSG

DBCLIENT_REQ_GROUP_NAMES

DBCLIENT_REQ_ENT_NAMES

DBCLIENT_CONTAINER_FIND_BY_ELEMENT

DBCLIENT_SHUTDOWN

DBCLIENT_WHO

DBCLIENT_SERVER_STATS_UPDATE

DBCLIENT_RELAY_CMD

DBCLIENT_RELAY_CMD_BYENT

DBCLIENT_RELAY_CMD_TOGROUP

DBCLIENT_REQ_ONLINE_ENTS

DBCLIENT_REQ_ONLINE_ENT_COMMENTS

DBCLIENT_PLAYER_KICKED

DBCLIENT_REQ_CUSTOM_DATA

DBCLIENT_EXECUTE_SQL

DBCLIENT_DISCONNECT_MAPSERVER

DBCLIENT_PLAYER_RENAME

DBCLIENT_PLAYER_CHANGETYPE

DBCLIENT_PLAYER_CHANGESUBTYPE

DBCLIENT_PLAYER_CHANGEPRAETORIANPROGRESS

DBCLIENT_PLAYER_CHANGEINFLUENCETYPE

DBCLIENT_DEPRECATED

DBCLIENT_REQ_ARENA_ADDRESS

DBCLIENT_REQ_SG_ELDEST_ON

DBCLIENT_REQ_SG_CHANNEL_INVITE

DBCLIENT_SGRP_STATSADJ

DBCLIENT_DESTROY_BASE

DBCLIENT_MISSION_PLAYER_COUNT

DBCLIENT_SEND_STATSERVER_CMD

DBCLIENT_REQUEST_SHUTDOWN

DBCLIENT_EMERGENCY_SHUTDOWN

DBCLIENT_OFFLINE_CHAR

DBCLIENT_RESTORE_DELETED_CHAR

DBCLIENT_LIST_DELETED_CHARS

DBCLIENT_BACKUP

DBCLIENT_BACKUP_SEARCH

DBCLIENT_BACKUP_APPLY

DBCLIENT_BACKUP_VIEW

DBCLIENT_REQ_SOME_ONLINE_ENTS

DBCLIENT_OVERRIDE_START_ZONE

DBCLIENT_AUCTION_REQ_INV

DBCLIENT_AUCTION_REQ_HISTINFO

DBCLIENT_AUCTION_XACT_REQ

DBCLIENT_AUCTION_XACT_UPDATE

DBCLIENT_AUCTION_PURGE_FAKE

DBCLIENT_AUCTION_XACT_MULTI_REQ

DBCLIENT_MININGDATA_RELAY

DBCLIENT_SEND_AUCTIONSERVER_CMD

DBCLIENT_ACCOUNTSERVER_CMD

DBCLIENT_ACCOUNTSERVER_SHARDXFER

DBCLIENT_ACCOUNTSERVER_ORDERRENAME

DBCLIENT_GET_PLAYNC_AUTH_KEY

DBCLIENT_ACCOUNTSERVER_CHARCOUNT

DBCLIENT_RENAME_RESPONSE

DBCLIENT_CHECK_NAME_RESPONSE

DBCLIENT_ACCOUNTSERVER_GET_INVENTORY

DBCLIENT_ACCOUNTSERVER_CHANGE_INV

DBCLIENT_ACCOUNTSERVER_UPDATE_EMAIL_STATS

DBCLIENT_ACCOUNTSERVER_CERTIFICATION_TEST

DBCLIENT_ACCOUNTSERVER_CERTIFICATION_GRANT

DBCLIENT_ACCOUNTSERVER_CERTIFICATION_CLAIM

DBCLIENT_ACCOUNTSERVER_CERTIFICATION_REFUND

DBCLIENT_ACCOUNTSERVER_MULTI_GAME_TRANSACTION

DBCLIENT_ACCOUNTSERVER_TRANSACTION_FINISH

DBCLIENT_ACCOUNTSERVER_RECOVER_UNSAVED

DBCLIENT_ACCOUNTSERVER_LOYALTY_CHANGE

DBCLIENT_ACCOUNTSERVER_LOYALTY_EARNED_CHANGE

DBCLIENT_ACCOUNTSERVER_LOYALTY_RESET

DBCLIENT_MISSIONSERVER_COMMAND

DBCLIENT_MISSIONSERVER_PUBLISHARC

DBCLIENT_MISSIONSERVER_SEARCHPAGE

DBCLIENT_MISSIONSERVER_ARCINFO

DBCLIENT_MISSIONSERVER_BANSTATUS

DBCLIENT_MISSIONSERVER_ALLARCS

DBCLIENT_MISSIONSERVER_ARCDATA

DBCLIENT_MISSIONSERVER_ARCDATA_OTHERUSER

DBCLIENT_MISSIONSERVER_INVENTORY

DBCLIENT_MISSIONSERVER_CLAIM_TICKETS

DBCLIENT_MISSIONSERVER_BUY_ITEM

DBCLIENT_ACCOUNTSERVER_ORDERRESPEC

DBCLIENT_DELETE_PLAYER

DBCLIENT_QUEUE_FOR_EVENTS

DBCLIENT_REMOVE_FROM_QUEUE

DBCLIENT_EVENT_READY_ACK

DBCLIENT_EVENT_RESPONSE

DBCLIENT_MAP_ID

DBCLIENT_TURNSTILE_PING

DBCLIENT_DEBUG_SHARD_XFER_OUT

DBCLIENT_DEBUG_SHARD_XFER_BACK

DBCLIENT_GROUP_UPDATE

DBCLIENT_EVENTHISTORY_FIND

DBCLIENT_CLOSE_INSTANCE

DBCLIENT_REJOIN_INSTANCE

DBCLIENT_PLAYER_LEAVE

DBCLIENT_MAP_WEEKLY_TF_ADD_TOKEN

DBCLIENT_MAP_WEEKLY_TF_REMOVE_TOKEN

DBCLIENT_MAP_WEEKLY_TF_SET_EPOCH_TIME

DBCLIENT_TEST_LOGGING

DBCLIENT_INCARNATETRIAL_COMPLETE

DBCLIENT_QUEUE_FOR_SPECIFIC_MISSION_INSTANCE

DBCLIENT_TS_ADD_BAN_DBID

DBCLIENT_MAP_SET_MARTY_STATUS

DBCLIENT_GRANT_CHARSLOT

DBCLIENT_PLAYER_UNLOCK

DBCLIENT_ACCOUNT_ADJUST_SERVER_SLOTS

DBCLIENT_UNLOCK_CHARACTER_RESPONSE

DBCLIENT_DEBUG_SET_VIP

launcher

mission

queue

stat

svrmon

turnstile

Command line arguments

-logserver

Start the dbserver as a logserver instead. (This also happens if the executable name is "logserver".)

-noencrypt

Disable encryption between the client and dbserver.

-productionmode

Enable production mode/disable development mode. Document production mode.

-startall

Start all static non-DontAutoStart maps automatically on startup.

-start <n>

Start up to n static maps on startup.

-verbose

Enable verbose logging.

-testcleanshutdown [n]

Run a database shutdown test on the n first containers and then exit. n is 100 by default.

-perfbench

Run a performance benchmark and then exit.

-perfload [n]

Run a load test of n runs on the database and then exit. n is 0 by default.

-perfdup [n]

Run a duplication test of n runs on the database and then exit. n is 0 by default.

-perfupdate [n]

Run an update test of n runs on the database and then exit. n is 0 by default.

-flattosql

Load the on-disk flat format (.defs or .bins) of Ents, Supergroups, Teamups and Leagues to the database, then exit. Only works in development mode.

-sqltoflat

Dump the database containers of Ents, Supergroups, Teamups and Leagues to the on-disk format, then exit. Only works in development mode.

-importdump <dumpfile> [mappingfile brokenfile progressfile splitnames]

Load a dump file. Defaults:

  • mappingfile: conids.map
  • brokenfile: links.bk
  • progressfile: progress.txt
  • splitnames: 0

-fiximport [mappingfile brokenfile progressfile]

Revisit DB (after import?) and fix broken links. Defaults:

  • mappingfile: conids.map
  • brokenfile: links.bk
  • progressfile: progress.txt

-exportdump <dumpfile>

Export a dump file.

-packetdebug

Enable packet debug info (data type and length). Enabled by default if the build is FULLDEBUG, disabled otherwise.

-memlogecho

Echo logs for the generic memlog instance to the console.

-cod

Pass the -cod option to mapservers launched via the launchers connected to this dbserver.